]> git.donarmstrong.com Git - lilypond.git/commitdiff
MusicXML: Fine-tune chord detection in combination with dynamics
authorReinhold Kainhofer <reinhold@kainhofer.com>
Mon, 3 Sep 2007 23:47:26 +0000 (01:47 +0200)
committerReinhold Kainhofer <reinhold@kainhofer.com>
Thu, 6 Sep 2007 14:21:00 +0000 (16:21 +0200)
When trying to find the corresponding notes for notes with the <chord>
indicator, we need to skip all dynamics, but must not cross bar lines. In
particular, since we now also add dynamics events, we cannot automatically
take the last event, but have to look for the last EventChord.

Also some small bug fixes (need to quote texts with _, missing param in dead
code, style, etc.)

Signed-off-by: Reinhold Kainhofer <reinhold@kainhofer.com>
python/musicexp.py
python/musicxml.py
scripts/musicxml2ly.py

index 797494ddb1f2637c95115edbd44ed45b2f28fc8a..5c3b91a804cda65ce59d45f26418ea4c217f6ce5 100644 (file)
@@ -433,7 +433,7 @@ class Lyrics:
         return lstr
 
 
-class EventChord(NestedMusic):
+class EventChord (NestedMusic):
     def get_length (self):
         l = Rational (0)
         for e in self.elements:
@@ -699,7 +699,7 @@ class NoteEvent(RhythmicEvent):
         self.forced_accidental = False
         
     def get_properties (self):
-        str = RhythmicEvent.get_properties ()
+        str = RhythmicEvent.get_properties (self)
         
         if self.pitch:
             str += self.pitch.lisp_expression ()
index 86d3120958181424941a76a87223131b2600d352..e4d06a2a0af3411a5fbab252f22f84570a40dcd0 100644 (file)
@@ -5,7 +5,7 @@ import re
 
 def escape_ly_output_string (input_string):
     return_string = input_string
-    needs_quotes = re.search ("[0-9\" ,.]", return_string);
+    needs_quotes = re.search ("[0-9\" ,._-]", return_string);
     return_string = string.replace (return_string, "\"", "\\\"")
     if needs_quotes:
         return_string = "\"" + return_string + "\""
@@ -465,15 +465,15 @@ class Part (Music_xml_node):
                     and n.get_maybe_exist_typed_child (Chord)):
                     now = last_moment
                     measure_position = last_measure_position
-                    
-                last_moment = now
-                last_measure_position = measure_position
 
-               n._when = now
+                n._when = now
                 n._measure_position = measure_position
-               n._duration = dur
-               now += dur
-                measure_position += dur
+                n._duration = dur
+                if dur > Rational (0):
+                    last_moment = now
+                    last_measure_position = measure_position
+                    now += dur
+                    measure_position += dur
                 if n._name == 'note':
                     instrument = n.get_maybe_exist_named_child ('instrument')
                     if instrument:
index 3f44e71c4fa80c8153b372a34aee5b6f6c7a7e71..d0bd4183991575e40c60c8f7d0110ea811315e95 100644 (file)
@@ -518,10 +518,19 @@ class LilyPondVoiceBuilder:
     def last_event_chord (self, starting_at):
 
         value = None
+
+        # if the position matches, find the last EventChord, do not cross a bar line!
+        at = len( self.elements ) - 1
+        while (at >= 0 and
+               not isinstance (self.elements[at], musicexp.EventChord) and
+               not isinstance (self.elements[at], musicexp.BarCheck)):
+            at -= 1
+
         if (self.elements
-            and isinstance (self.elements[-1], musicexp.EventChord)
+            and at >= 0
+            and isinstance (self.elements[at], musicexp.EventChord)
             and self.begin_moment == starting_at):
-            value = self.elements[-1]
+            value = self.elements[at]
         else:
             self.jumpto (starting_at)
             value = None