Paul Scott wrote: > It doesn't work. At first I didn't use \unfoldRepeats for the > graphical output as you show above. But adding the > \unfoldRepeats to the first (graphical) part the graphical music > is unfolded in a strange way. The graphical music is generated > with the repeat signs omitted but nothing unfolded. The music > would be 16 bars long and it is but the last 6 bars are blank.
Okay, I looked into this, and here's what I've learned. > global = { \repeat volta 2 s1*6 \alternative { { s1*2 } { s1*2 } } } Change s1*6 to { s1*6 }. The \repeat syntax is \repeat volta repeatcount musicexpr and all music expressions require curly braces. > \score { > << > \new Staff = soprano << > \context Voice = soprano { << { \unfoldRepeats \global } \melody >> } > >> > >> > \layout{ } > } If you're going to use \unfoldRepeats in a \score with \layout, it doesn't make sense to apply it to only one music expression if there are other simultaneous expressions. Since \global and \melody are simultaneous expressions, move \unfoldRepeats outside: \score { << \new Staff = soprano << \context Voice = soprano \unfoldRepeats { << \global \melody >> } >> >> \layout{ } } However, it may make even more sense to apply \unfoldRepeats to the whole score, so you don't have to keep applying it to other voices (should there be any)... \score { \unfoldRepeats << \new Staff = soprano << \context Voice = soprano { << \global \melody >> } >> >> \layout{ } } Also consider Staff and Voice naming. Are you going to have non-soprano Voices in the soprano Staff? If not, you probably don't need the \context Voice = soprano since a Voice context is implicitly created with any music expression (though there are reasons for explicitly instantiating the Voice context). Either way (and honestly I don't know if this makes a difference), I wouldn't want two different contexts with the same name, even if they are nested within each other. You might consider sopranoStaff and sopranoVoice, for instance. Also, << and >> are only needed when there's more than one simultaneous expression. So if sopranoStaff will only contain sopranoVoice, you could do this: \score { \unfoldRepeats << \new Staff = sopranoStaff \context Voice = sopranoVoice { << \global \melody >> } >> \layout { } } And if << and >> enclose simultaneous expressions which already have curly braces built into their definition -- like \global and \melody do, you don't need an extra pair of curly braces around the << >>. \score { \unfoldRepeats << \new Staff = sopranoStaff \context Voice = sopranoVoice << \global \melody >> >> \layout { } } I've left the outer << >> with the assumption that other voices will eventually be added, but if not, you could remove those too. Unfortunately, after all this, I've learned that \unfoldRepeats doesn't natively work when the repeats are in an expression separate from the notes, even if they're funneled together before calling \unfoldRepeats. See http://lists.gnu.org/archive/html/lilypond-devel/2009-06/msg00161.html for a response to my post on the developers mailing-list regarding this question. So you must do something like this: global = { \key d \major } melody = \relative c' { \repeat volta 2 { fs2 fs4. fs8 g4 fs e d d2( ~ d8 e8 d4) a2 a8 b d4 fs e2. fs4 e d e } \alternative { { fs2 ~ fs8 g fs4 e1 } { e8 d ~ d2. ~ d1 } } } \score { \unfoldRepeats << \new Staff = sopranoStaff \context Voice = sopranoVoice << \global \melody >> >> \layout { } } Also, in your \score with the \midi block, you have this line: > \new Score{ << { \unfoldRepeats \global } \melody >> } I don't think \new Score is used anymore. You could reduce this line to \unfoldRepeats << \melody >> I've left the << >> with the assumption that other voices will eventually be added, and if so, consider renaming "melody" to something like "sopMusic". If "melody" is the only voice, then of course you don't need the << >>, and you can just do \unfoldRepeats \melody \score { \unfoldRepeats << \melody >> \midi { \context { \Score tempoWholesPerMinute = #(ly:make-moment 120 4) } } } Also, use \new instead of \context when a Voice first appears. Not strictly necessary, but in complex scores, it's helpful to be able to find the first instance of a specific context. One last note: it may save space to put a lot of notes on one line in your ly file, but it's easier for others to read your code if it's nicely indented. I've attached a working version of the file. HTH. - Mark
\version "2.13.1" \include "english.ly" #(set-global-staff-size 24) % I need to add this line using LilyPondTool on Windows: % #(ly:set-option 'midi-extension "midi") global = { \key d \major } sopMusic = \relative c' { \repeat volta 2 { fs2 fs4. fs8 g4 fs e d d2( ~ d8 e8 d4) a2 a8 b d4 fs e2. fs4 e d e } \alternative { { fs2 ~ fs8 g fs4 e1 } { e8 d ~ d2. ~ d1 } } } \score { \unfoldRepeats << \new Staff = sopranoStaff \new Voice = sopranoVoice << \global \sopMusic >> >> \layout { } } \score { \unfoldRepeats << \sopMusic >> \midi { \context { \Score tempoWholesPerMinute = #(ly:make-moment 120 4) } } }
_______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user