]> git.donarmstrong.com Git - lilypond.git/commitdiff
* python/musicxml.py (Part.interpret): don't complain about
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 16 May 2006 11:58:58 +0000 (11:58 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 16 May 2006 11:58:58 +0000 (11:58 +0000)
incomplete measures.

* scripts/musicxml2ly.py (musicxml_voice_to_lily_voice): only add
new music if last_event_chord() returned None.

* python/musicxml.py (Part.interpret): skip back over chord notes.

ChangeLog
python/musicxml.py
scripts/musicxml2ly.py

index 4f9d2aa07c6810847dda33aee7bf499a12bc988d..1a83f27d01a6bf1e52cc36ab4b9c9a247fbf05a8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,15 @@
+2006-05-16  Han-Wen Nienhuys  <hanwen@lilypond.org>
+
+       * python/musicxml.py (Part.interpret): don't complain about
+       incomplete measures.
+
+       * scripts/musicxml2ly.py (musicxml_voice_to_lily_voice): only add
+       new music if last_event_chord() returned None.
+
+       * python/musicxml.py (Part.interpret): skip back over chord notes.
+
 2006-05-16  Erik Sandberg  <mandolaerik@gmail.com>
+       
        * lily/percent-repeat-engraver.cc, lily/parser.yy,
        lily/define-music-types.cc, lily/percent-repeat-iterator.cc,
        lily/slash-repeat-engraver.cc,
index b390485c5b9c708f91535ab023d9827ed789593e..519a0c3f6c531e80512987a1cbbbf00f0187da42 100644 (file)
@@ -276,7 +276,8 @@ class Part (Music_xml_node):
        attributes_dict = {}
         attributes_object = None
        measures = self.get_typed_children (Measure)
-        
+        last_moment = Rational (-1)
+        last_measure_position = Rational (-1)
        for m in measures:
             measure_start_moment = now
             measure_position = Rational (0)
@@ -291,9 +292,9 @@ class Part (Music_xml_node):
                     
                    factor = Rational (1,
                                       int (attributes_dict['divisions'].get_text ()))
-               elif (n.get_maybe_exist_typed_child (Duration)
-                     and not n.get_maybe_exist_typed_child (Chord)):
-                    
+
+                
+               if (n.get_maybe_exist_typed_child (Duration)):
                    mxl_dur = n.get_maybe_exist_typed_child (Duration)
                    dur = mxl_dur.get_length () * factor
                     
@@ -308,7 +309,14 @@ class Part (Music_xml_node):
                         and attributes_object.get_measure_length () == dur):
 
                         rest._is_whole_measure = True
-                        
+
+                if (dur > Rational (0) 
+                    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._measure_position = measure_position
@@ -328,8 +336,10 @@ class Part (Music_xml_node):
                     problem = 'incomplete'
                     if now > new_now:
                         problem = 'overfull'
-                        
-                    m.message ('%s measure? Expected: %s, Difference: %s' % (problem, now, new_now - now))
+
+                    ## only for verbose operation.
+                    if problem <> 'incomplete':
+                        m.message ('%s measure? Expected: %s, Difference: %s' % (problem, now, new_now - now))
 
                 now = new_now
 
index c24dccb5bdb7e068b0f3ec629b7db83ab74f8109..a8bada64ac7705d7a6206c1c75908516d1841050 100644 (file)
@@ -195,6 +195,7 @@ instrument_drumtype_dict = {
     'Acoustic Snare Drum': 'acousticsnare',
     'Side Stick': 'sidestick',
     'Open Triangle': 'opentriangle',
+    'Mute Triangle': 'mutetriangle',
     'Tambourine': 'tambourine',
     
 }
@@ -287,13 +288,18 @@ class LilyPondVoiceBuilder:
             self.add_music (evc, diff)
                 
     def last_event_chord (self, starting_at):
+
+        value = None
         if (self.elements
             and isinstance (self.elements[-1], musicexp.EventChord)
             and self.begin_moment == starting_at):
-            return self.elements[-1]
+            value = self.elements[-1]
         else:
             self.jumpto (starting_at)
-            return None
+            value = None
+
+        return value
+        
     def correct_negative_skip (self, goto):
         self.end_moment = goto
         self.begin_moment = goto
@@ -305,15 +311,17 @@ def musicxml_voice_to_lily_voice (voice):
     modes_found = {}
 
     voice_builder = LilyPondVoiceBuilder()
+
     for n in voice._elements:
         if n.get_name () == 'forward':
             continue
 
-        try:
-            voice_builder.jumpto (n._when)
-        except NegativeSkip, neg:
-            voice_builder.correct_negative_skip (n._when)
-            n.message ("Negative skip? from %s to %s, diff %s" % (neg.here, neg.dest, neg.dest - neg.here))
+        if not n.get_maybe_exist_named_child ('chord'):
+            try:
+                voice_builder.jumpto (n._when)
+            except NegativeSkip, neg:
+                voice_builder.correct_negative_skip (n._when)
+                n.message ("Negative skip? from %s to %s, diff %s" % (neg.here, neg.dest, neg.dest - neg.here))
             
         if isinstance (n, musicxml.Attributes):
             if n.is_first () and n._measure_position == Rational (0):
@@ -349,10 +357,9 @@ def musicxml_voice_to_lily_voice (voice):
         ev_chord = voice_builder.last_event_chord (n._when)
         if not ev_chord: 
             ev_chord = musicexp.EventChord()
+            voice_builder.add_music (ev_chord, n._duration)
 
-        
         ev_chord.append (main_event)
-        voice_builder.add_music (ev_chord, n._duration)
         
         notations = n.get_maybe_exist_typed_child (musicxml.Notations)
         tuplet_event = None