I'm writing a music function to insert a specific pattern of alternative
endings with partial measures. Lilypond gives an error suggesting the
\alternative block is in the wrong place, even though writing it in the
same place by hand gives no error.

For instance, this works as you'd expect:

\version "2.19.83"
shortMeasure = \set Timing.measureLength = #(ly:make-moment 3/4)
longMeasure = \set Timing.measureLength = #(ly:make-moment 4/4)
\relative c' {
    c4 c c
    \repeat volta 2 {
        c | c c c c | c c c c
    }
    \alternative {
        { \shortMeasure c2. }
        { \longMeasure c1 }
    }
}


But this, which I'd expect to do the same thing, doesn't:

\version "2.19.83"
shortMeasure = \set Timing.measureLength = #(ly:make-moment 3/4)
longMeasure = \set Timing.measureLength = #(ly:make-moment 4/4)
alts = #(define-music-function (parser location p) (ly:pitch?)
                #{ \alternative {
                        { \shortMeasure $p 2. }
                        { \longMeasure $p 1 } } #} )
\relative c' {
    c4 c c
    \repeat volta 2 {
        c | c c c c | c c c c
    }
    \alts c
}


Instead, it gives the error "syntax error, unexpected \alternative."

Can anyone give me insight into why?

Thanks,
Leah
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to