1

I have been unable to get even the simplest example to use volta repeats, the \alternative construct, and parallel music, without Lilypond producing an extra context (stave), starting at the first repeat.

I've tried every variation of this I can think of, especially with bracket groupings. No luck. Is it not possible? Am I reading the documentation wrong? Is there some subtle error I'm overlooking?

In the real-world piece of music, the note strings are deeply nested variables, and what I'm trying to accomplish is to put the repeats up at the score level, and not buried in some variable that may be used by multiple other variables. HideEmptyStaves hides parts of the music I don't want hidden - parts with eight-bar rests and such.

\score {{
  <<
    \new Staff = "S" \new Voice = "V" {\fixed c' e1 }
    \new Staff = "T" \new Voice = "W" {\fixed c' c1 }
  >>
  \\
  \repeat volta 2 
    <<  
    \context Staff = "S" \context Voice = "V" {\fixed c' f1 }
    \context Staff = "T" \context Voice = "W" {\fixed c' d1 }
    >>
  \alternative {
    <<  
      \context Staff = "S" \context Voice = "V" {\fixed c' g1 }
      \context Staff = "T" \context Voice = "W" {\fixed c' e1 }
    >>
    <<  
      \context Staff = "S" \context Voice = "V" {\fixed c' f1 }
      \context Staff = "T" \context Voice = "W" {\fixed c' d1 }
    >>
  }
  \\
  <<  
    \context Staff = "S" \context Voice = "V" {\fixed c' e1 1 1 1}
    \context Staff = "T" \context Voice = "W" {\fixed c' c1 1 1 1}
  >>
}}

3 Answers 3

2

No, it is not possible the way you do it. But you can do something like this

<<
  \new Staff { c' d' e' d' c' d' e' f' g' a' b' c'' d'' e'' f'' g'' }
  \new Staff { c' d' e' d' c' d' e' f' g' a' b' c'' d'' e'' f'' g'' }
  \new Devnull { \repeat volta 2 s1*2 \alternative { s1 s1 } }
>>

to specify the repeat separately.

6
  • That's easier and less messy to simply do with an existing staff. That way it doesn't require me to count measures manually, which your method does, unless there's a function that returns the length of a musical variable in measures. I think I'll accept the "no, it is not possible" as a complete answer. I can force it to print correctly inserting the repeat bars manually, and as yet I don't need it to play or otherwise unfold properly.
    – KFW
    Feb 2, 2022 at 10:12
  • @KFW That is true. It is indeed possible to get the length of a music expression, and even create a skip of exactly that length. But if you already do have all sections in different variables then this does not offer much of a benefit. I just proposed this as you wanted to specify the repeats at a score level. But instead (if you have the music in sections) you can do \new Staff { \something \repeat volta 2 \rep \alternative { \altI \alt II } \somethingelse }.
    – Lazy
    Feb 2, 2022 at 10:42
  • @KFW Also it should be pointed out that what you want to do becomes possible if you choose to use the current development version.
    – Lazy
    Feb 2, 2022 at 12:11
  • Currently using 2.23.5 - don't know why it isn't at the top of the example. At any rate, I found something that worked for simple examples, but it fails with my larger files. So I deleted it - when I tried it again, I couldn't get my example to work. Back to the drawing board.
    – KFW
    Feb 2, 2022 at 23:10
  • @KFW It will work with 2.23.6. That one should release in the near future, if you cannot wait, check out the current git master. gitlab.com/lilypond/lilypond
    – Lazy
    Feb 3, 2022 at 10:37
0

My previous answer failed for larger/more complex files. My current solution is a stave of nothing but rests, repeats, and bar markers, but made up of variables of the same length as my data. This does not allow the block editing (so no real solution yet) but it works with manual repeats as well as the repeat-alternative construct, and the repeat structure is cleanly separated from the music.

0

Since you are trying to write music in parallel, have you considered using the \parallelMusic construct? (See the writing-music-in-parallel documentation)

In this construct each measure (or group of measures) is filled out for one voice at a time. NB Bar checks (|) are not optional, they now mark the end of a voice string.

I haven't had cause to use it before, but it certainly looks like it will clean up your code:

\parallelMusic voiceV, voiceW { 
% m. 1 
    e1 | % V
    c1 | % W
    \repeat volta 2 {
% m. 2
        f1 | % V
        d1 | % W
    }
    \alternative {
        {
% m. 3
            g1 | % V
            e1 | % W
        }
        {
% m. 4
            f1 | % V
            d1 | % W
        }
    }
% mm. 5-8 
    e1 1 1 1 | % V
    c1 1 1 1 | % W
}

\score { 
    <<
        \new Staff {
            \fixed c' \voiceV
        }
        \new Staff {
            \fixed c' \voiceW
        }
    >>
}

rendering of above code

1
  • This example has the problem I was trying to fix - the volta spec is in one of the voices and not at the score level.
    – KFW
    Mar 7, 2022 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.