From f0b6bdf9075fb404a6e4f25978d32f3ee44c4d46 Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Fri, 15 Aug 2008 13:27:43 +0000 Subject: [PATCH] Handle slurs in Lilypond input --- Filters/VLLilypondType.reader | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/Filters/VLLilypondType.reader b/Filters/VLLilypondType.reader index e3350cd..efdd1c9 100755 --- a/Filters/VLLilypondType.reader +++ b/Filters/VLLilypondType.reader @@ -204,6 +204,7 @@ def parseLilypond tied = false repeat = 0 lyricFlags= 0 + slur = false while tokens.length > 0 token = tokens.shift @@ -274,11 +275,28 @@ def parseLilypond lastDur = dur d = lyDur(dur) + if slur + # + # We don't support slurs, so we turn them into tied notes at the + # final pitch + # + ix = NOTES.size + tie= true + while tie do + break if ix == 0 + note = NOTES[ix -= 1] + note['pitch'] = pitch; + note['tied'] ||= 0 + note['tied'] |= VL::TiedWithNext + tie = (note['tied'] & VL::TiedWithPrev) != 0 + end + tied = true + end note = {'pitch' => pitch, 'durNum'=> d[0], 'durDenom' => d[1]} note['tied'] = VL::TiedWithPrev if tied p token, note if $DEBUG - NOTES.push(note) tied = false + NOTES.push(note) redo elsif token == '~' if note = NOTES.last @@ -286,6 +304,10 @@ def parseLilypond note['tied'] |= VL::TiedWithNext end tied = true + elsif token == '(' + slur = true + elsif token == ')' + slur = false elsif token == '\repeat' && (tokens[0] == 'volta' || tokens[0] == fold) && tokens[1] =~ /^\d+$/ stack.push([block, level, "repeat"])