From: hanwen Date: Sat, 30 Jul 2005 17:24:09 +0000 (+0000) Subject: (add_key_sig): add key sig if not at start. X-Git-Tag: ikebana/2.7.1~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=701ff16f71b1a7e77cc476803ee6dd20cb067868;p=lilypond.git (add_key_sig): add key sig if not at start. --- diff --git a/ChangeLog b/ChangeLog index c4e90c10d1..38091f53b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-07-30 Han-Wen Nienhuys + + * notation.py (add_key_sig): add key sig if not at start. + 2005-07-29 Han-Wen Nienhuys * notation.py (Notation.change_duration_log): duration logs of all diff --git a/ikebana.py b/ikebana.py index 2d4ab757bb..0ab6977461 100644 --- a/ikebana.py +++ b/ikebana.py @@ -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) diff --git a/music.py b/music.py index cd804b3c4a..9949f40ab1 100644 --- 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) diff --git a/notation.py b/notation.py index b06513765a..0e7ccf8f30 100644 --- a/notation.py +++ b/notation.py @@ -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 diff --git a/notationcanvas.py b/notationcanvas.py index 24a965376a..67f625c775 100644 --- a/notationcanvas.py +++ b/notationcanvas.py @@ -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,