lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Inserting alternative endings from a music function


From: Leah Velleman
Subject: Inserting alternative endings from a music function
Date: Wed, 26 Jun 2019 11:41:11 -0400

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]