From 2129b7b7f8493649bc00b5d4ea0ecda8a5bdef33 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Tue, 16 May 2006 11:58:58 +0000 Subject: [PATCH] * 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. --- ChangeLog | 11 +++++++++++ python/musicxml.py | 24 +++++++++++++++++------- scripts/musicxml2ly.py | 25 ++++++++++++++++--------- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4f9d2aa07c..1a83f27d01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,15 @@ +2006-05-16 Han-Wen Nienhuys + + * 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 + * lily/percent-repeat-engraver.cc, lily/parser.yy, lily/define-music-types.cc, lily/percent-repeat-iterator.cc, lily/slash-repeat-engraver.cc, diff --git a/python/musicxml.py b/python/musicxml.py index b390485c5b..519a0c3f6c 100644 --- a/python/musicxml.py +++ b/python/musicxml.py @@ -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 diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index c24dccb5bd..a8bada64ac 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -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 -- 2.39.5