]> git.donarmstrong.com Git - lilypond.git/commitdiff
(add_key_sig): add key sig if not at start.
authorhanwen <hanwen>
Sat, 30 Jul 2005 17:24:09 +0000 (17:24 +0000)
committerhanwen <hanwen>
Sat, 30 Jul 2005 17:24:09 +0000 (17:24 +0000)
ChangeLog
ikebana.py
music.py
notation.py
notationcanvas.py

index c4e90c10d1665335a00057df9341fb0451616901..38091f53b3199cd82c90129159fedb1082b50d57 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2005-07-30  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * notation.py (add_key_sig): add key sig if not at start.
+
 2005-07-29  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
        * notation.py (Notation.change_duration_log): duration logs of all
index 2d4ab757bbcc7f9134c34f682477a0ed8d82d67d..0ab697746162335e8c8a59d36f02b771f953c4f6 100644 (file)
@@ -33,7 +33,7 @@ class NotationApplication:
         
     def create_tree_window (self):
         win = gtk.Window ()
-        (w,h) = (500,300)
+        (w,h) = (500,200)
         win.set_size_request (w, h) 
         
         win.connect ('destroy', mainquit)
index cd804b3c4a292927d14c4e5c10b3753a251d6740..9949f40ab1904b3bd87fe9fe18e09f218322c66d 100644 (file)
--- a/music.py
+++ b/music.py
@@ -62,11 +62,11 @@ class Pitch:
                return self.step + self.octave * 7
        
        def ly_step_expression (self): 
-               str = 'cdefgab'[self.step]
+               str = 'CDEFGAB'[self.step]
                if self.alteration > 0:
-                       str += 'is'* (self.alteration/2)
+                       str += '-Sharp'* (self.alteration/2)
                elif self.alteration < 0:
-                       str += 'es'* (-self.alteration/2)
+                       str += '-Flat'* (-self.alteration/2)
                return str
        
        def ly_expression (self):
@@ -349,7 +349,7 @@ class ClefEvent (Event):
 
 def test_expr ():
        m = SequentialMusic()
-       l =2 
+       l = 2  
        evc = EventChord()
        n = NoteEvent()
        n.duration.duration_log = l
@@ -359,7 +359,7 @@ def test_expr ():
 
        evc = EventChord()
        n = NoteEvent()
-       n.duration.duration_log = 0
+       n.duration.duration_log = l
        n.pitch.step = 3
        evc.insert_around (None, n, 0)
        m.insert_around (None, evc, 0)
index b06513765a57137e9dc4f8209ee6b5eb816df830..0e7ccf8f304e865d2babc8f819b71f4dda0dac54 100644 (file)
@@ -53,7 +53,8 @@ def talk_to_lilypond (expression_str):
            break
        cont = len (data) > 0
        retval += data
+
+#    print retval
     return retval
 
 def set_measure_number (str, num):
@@ -81,14 +82,27 @@ myNotes = %s
     os.system ('(lilypond %s && gv %s)&  ' % (filename, base))
 
 def add_start_skip (str, start_skip):
-    return """(make-music 'SequentialMusic 'elements
+    str = """(make-music 'SequentialMusic 'elements
                (list
                 (make-music 'SkipMusic
                             'duration (ly:make-duration 0 0 %d %d))
                 %s))
 """ % (start_skip.num, start_skip.den, str)
+
+
+    return str
+
+def add_key_sig (str):
+    e_flat = music.Pitch()
+    e_flat.step = 2
+    e_flat.alteration = -2
+    ev = music.KeySignatureEvent (e_flat, scale_alterations)
     
-    
+    str = """(make-music 'SequentialMusic 'elements
+    (list (make-music 'EventChord 'elements (list
+    %s))
+    %s))""" % (ev.lisp_expression (), str)
+    return str
 
 class Lilypond_socket_parser:
     """Maintain state of reading multi-line lilypond output for socket transport."""
@@ -165,9 +179,12 @@ class Notation_controller:
         
        str = expr.lisp_sub_expression (sub)
         str = add_start_skip (str, start_skip)
-        
+
         bar_count = (self.start_moment / measure_length).floor()
-        str = set_measure_number (str, bar_count.num)
+        str = set_measure_number (str, 1 + bar_count.num)
+        if bar_count.num > 0:
+            str = add_key_sig (str)
+        
        str = talk_to_lilypond (str)
         self.parse_socket_file (str)
 
@@ -425,8 +442,10 @@ class Notation:
             
     def ensure_rest (self):
         if self.music_cursor.name() == 'NoteEvent':
+            dur = self.music_cursor.duration
             m = self.music_cursor
             rest = music.RestEvent()
+            rest.duration = dur.copy()
             m.parent.insert_around (None, rest, 1)
             m.parent.delete_element (m)
             self.music_cursor = rest  
index 24a965376af5a365ba91ee88c19ee66a3e8b00dc..67f625c77566d0567636c67b8045bf2a850acda7 100644 (file)
@@ -150,7 +150,7 @@ class Notation_canvas (gnomecanvas.Canvas):
                self.set_scroll_region (0, 0, w, h)
                root = self.root ()
                root.affine_relative ((1,0,0,-1,0, 5))
-               self.pixel_scale = 10
+               self.pixel_scale = 11
                self.set_pixels_per_unit (self.pixel_scale)
                i = root.add (gnomecanvas.CanvasRect,
                              y1 = 5,
@@ -267,9 +267,7 @@ class Notation_canvas (gnomecanvas.Canvas):
            (index, font_name, magnification, name) = tuple (item.args)
            (family, style) = string.split (font_name, '-')
 
-           sz = canvas.pixel_scale * 0.75 * magnification
-           sz *= 1.2
-
+           sz = canvas.pixel_scale * 15.5/16 * magnification
            w = canvas.root().add (type,
                                   fill_color = 'black',
                                   family = family,