From: Reinhold Kainhofer Date: Tue, 11 Nov 2008 20:50:50 +0000 (+0100) Subject: MusicXML: Fix notes that end a slur and start a slur at the same time X-Git-Tag: release/2.11.64-1~49 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b53afdff2ebd8b7e7f0ebe1fdf0dd31e6e3ee193;p=lilypond.git MusicXML: Fix notes that end a slur and start a slur at the same time --- diff --git a/input/regression/musicxml/04f-Slurs.xml b/input/regression/musicxml/04f-Slurs.xml new file mode 100644 index 0000000000..f500d934d8 --- /dev/null +++ b/input/regression/musicxml/04f-Slurs.xml @@ -0,0 +1,154 @@ + + + + Slurs + + Reinhold Kainhofer + Public Domain + + Finale 2008 for Windows + Dolet Light for Finale 2008 + 2008-11-11 + + + + + MusicXML Part + + Grand Piano + + + 1 + 1 + + + + + + + + 1 + + 0 + major + + + + G + 2 + + + + + G + 4 + + 1 + 1 + quarter + + + + + + + C + 5 + + 1 + 1 + quarter + + + + + + + + A + 4 + + 1 + 1 + quarter + + + + + + + + G + 4 + + 1 + 1 + quarter + + + + + + + + + + G + 4 + + 1 + 1 + quarter + + + + + + + C + 5 + + 1 + 1 + quarter + + + + + + + A + 4 + + 1 + 1 + quarter + up + + + + + + + G + 4 + + 1 + 1 + quarter + up + + + + + + light-heavy + + + + + diff --git a/scripts/musicxml2ly.py b/scripts/musicxml2ly.py index 2a48cd12c1..b015072732 100644 --- a/scripts/musicxml2ly.py +++ b/scripts/musicxml2ly.py @@ -1909,20 +1909,36 @@ def musicxml_voice_to_lily_voice (voice): tuplet_events.append ((ev_chord, tuplet_event, frac)) - slurs = [s for s in notations.get_named_children ('slur') - if s.get_type () in ('start','stop')] - if slurs: - if len (slurs) > 1: - error_message (_ ('cannot have two simultaneous slurs')) + # First, close all open slurs, only then start any new slur + # TODO: Record the number of the open slur to dtermine the correct + # closing slur! + endslurs = [s for s in notations.get_named_children ('slur') + if s.get_type () in ('stop')] + if endslurs and not inside_slur: + endslurs[0].message (_ ('Encountered closing slur, but no slur is open')) + elif endslurs: + if len (endslurs) > 1: + endslurs[0].message (_ ('Cannot have two simultaneous (closing) slurs')) # record the slur status for the next note in the loop 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]) + inside_slur = False + lily_ev = musicxml_spanner_to_lily_event (endslurs[0]) ev_chord.append (lily_ev) + startslurs = [s for s in notations.get_named_children ('slur') + if s.get_type () in ('start')] + if startslurs and inside_slur: + startslurs[0].message (_ ('Cannot have a slur inside another slur')) + elif startslurs: + if len (startslurs) > 1: + startslurs[0].message (_ ('Cannot have two simultaneous slurs')) + # record the slur status for the next note in the loop + if not grace: + inside_slur = True + lily_ev = musicxml_spanner_to_lily_event (startslurs[0]) + ev_chord.append (lily_ev) + + if not grace: mxl_tie = notations.get_tie () if mxl_tie and mxl_tie.type == 'start':