From 99b3fe7876cdf739199cb92ea2f42470b8f082d6 Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Sat, 27 Oct 2007 22:45:17 +0200 Subject: [PATCH] MusicXML: Fix problem with lyrics on notes with grace notes When a note had grace notes (and it was tied or part of a slur), sometimes the lyrics for that note were completely ignored and all subsequent lyrics were one note off. Now I simply ignore all slurs/ties of grace notes and everything works just fine. Also, clean up the staff change code. Now a staff change is not only applied before a note, but also before other stuff (like clef change). --- .../06f-Lyrics-GracedNotes-Finale.xml | 232 ++++++++++++++++++ scripts/musicxml2ly.py | 34 +-- 2 files changed, 250 insertions(+), 16 deletions(-) create mode 100644 input/regression/musicxml/06f-Lyrics-GracedNotes-Finale.xml diff --git a/input/regression/musicxml/06f-Lyrics-GracedNotes-Finale.xml b/input/regression/musicxml/06f-Lyrics-GracedNotes-Finale.xml new file mode 100644 index 0000000000..d6fa55c1c0 --- /dev/null +++ b/input/regression/musicxml/06f-Lyrics-GracedNotes-Finale.xml @@ -0,0 +1,232 @@ + + + + Lyrics on notes with graces + + + Finale 2007 for Windows + Dolet Light for Finale 2007 + 2007-10-27 + + + + + MusicXML Part + + Grand Piano + + + 1 + 1 + + + + + + + + 2 + + 0 + major + + + + G + 2 + + + + + + G + 4 + + 2 + 1 + quarter + up + + + + + begin + Ly + + + + + + D + 5 + + 1 + eighth + up + + + + C + 5 + + 2 + 1 + quarter + down + + + + + + + C + 5 + + 2 + 1 + quarter + down + + end + rics + + + + + + D + 5 + + + 1 + eighth + up + + + + + + + C + 5 + + 2 + 1 + quarter + down + + single + on + + + + + + + + C + 5 + + 2 + + 1 + quarter + down + + + + + single + notes + + + + + + + E + 5 + + + 1 + eighth + up + begin + + + + + + + + D + 5 + + 1 + eighth + up + end + + + + C + 5 + + 2 + + 1 + quarter + down + + + + + + + + D + 5 + + 1 + eighth + up + + + + C + 5 + + 2 + 1 + quarter + down + + single + with + + + + + C + 5 + + 2 + 1 + quarter + down + + single + graces + + + + light-heavy + + + + + diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index 8bb9b2560a..4a8548630b 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -961,6 +961,12 @@ def musicxml_voice_to_lily_voice (voice): for n in voice._elements: if n.get_name () == 'forward': continue + staff = n.get_maybe_exist_named_child ('staff') + if staff: + staff = staff.get_text () + if current_staff and staff <> current_staff and not n.get_maybe_exist_named_child ('chord'): + voice_builder.add_command (musicexp.StaffChange (staff)) + current_staff = staff if isinstance (n, musicxml.Partial) and n.partial > 0: a = musicxml_partial_to_lily (n.partial) @@ -986,12 +992,6 @@ def musicxml_voice_to_lily_voice (voice): is_chord = n.get_maybe_exist_named_child ('chord') if not is_chord: - s = n.get_maybe_exist_named_child ('staff') - if s: - staff = s.get_text () - if current_staff and staff <> current_staff: - voice_builder.add_command (musicexp.StaffChange (staff)) - current_staff = staff try: voice_builder.jumpto (n._when) except NegativeSkip, neg: @@ -1103,19 +1103,21 @@ def musicxml_voice_to_lily_voice (voice): if len (slurs) > 1: error_message ('more than 1 slur?') # record the slur status for the next note in the loop - if slurs[0].get_type () == 'start': - inside_slur = True - elif slurs[0].get_type () == 'stop': - inside_slur = False + if not grace: + if slurs[0].get_type () == 'start': + inside_slur = True + elif slurs[0].get_type () == 'stop': + inside_slur = False lily_ev = musicxml_spanner_to_lily_event (slurs[0]) ev_chord.append (lily_ev) - mxl_tie = notations.get_tie () - if mxl_tie and mxl_tie.type == 'start': - ev_chord.append (musicexp.TieEvent ()) - is_tied = True - else: - is_tied = False + if not grace: + mxl_tie = notations.get_tie () + if mxl_tie and mxl_tie.type == 'start': + ev_chord.append (musicexp.TieEvent ()) + is_tied = True + else: + is_tied = False fermatas = notations.get_named_children ('fermata') for a in fermatas: -- 2.39.2