I have the following Lilypond source file consisting of a few blocks of the following form:
global = \relative { ... }
Soprano = \relative { ... }
Alto = \relative { ... } % ditto Tenor, Bass
\score { \new StaffGroup <<
\new Staff << \clef "G" \global \Soprano >>
\new Staff << \clef "G" \global \Alto >>
\new Staff << \clef "G_8" \global \Tenor >>
\new Staff << \clef "F" \global \Bass >>
>> \layout { } }
Obviously the global
, Soprano
, Alto
, Tenor
, Bass
definitions change each time, but the \score
block remains the same.
I want to factor that block in a Scheme macro. However, the simplest definition I tried,
#(define (Choral) (ly:make-score #{ \new StaffGroup <<
\new Staff << \clef "G" \global \Soprano >>
\new Staff << \clef "G" \global \Alto >>
\new Staff << \clef "G_8" \global \Tenor >>
\new Staff << \clef "F" \global \Bass >>
>> #} ))
has the following inconvenients: (1) it must be invoked by #(Choral)
instead of the more natural \Choral
, and worse, (2) it produces no output whatsoever. If I try to put a \layout { }
block in the (Choral)
definition lilypond produces the following error: error: syntax error, unexpected \layout
.
Is there a simple way to write a macro that produces a \score
block with attached \layout
?