lilypond-user
[Top][All Lists]
Advanced

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

Storing a bookpart in a variable


From: Vaughan McAlley
Subject: Storing a bookpart in a variable
Date: Thu, 25 Feb 2016 10:48:04 +1100

Greetings,

I’d like to be able to specify at the top of my main score which
movements are printed. I can store a \bookpart in a variable, but I
can’t seem to return it from a scheme expression. Is there a bookpart
equivalent to define-music-function that I haven’t found?

Vaughan


%%%%%%%%%%%%%%%%%%
\version "2.18.2"

compileTheseMovements = "2" % change to "12" to compile both movements

EmptyBookpart = \bookpart {}

FirstMovement = \bookpart {
   \tocItem "First Movement"
   \header {
      title = "Multi-movement piece"
      composer = "LvB"
      subtitle = "First Movement"
   }

   \score {
      { \time 2/4 r8 g' [ g' g'] es'2 }
      \layout {}
      \midi {}
   }

}

SecondMovement = \bookpart {
   \tocItem "Second Movement"
   \header {
      title = ##f
      subtitle = "Second Movement"
   }
   \score {
      { \time 3/8 \partial 8 es16. as32 c'8 c'16. bes32 as16. c'32 f4 }
      \layout {}
      \midi {}
   }
}

\book {
   #(if
     (string-contains compileTheseMovements "1")
     FirstMovement
     EmptyBookpart)

   #(if
     (string-contains compileTheseMovements "2")
     SecondMovement
     EmptyBookpart)

%{
   % This works fine
   \FirstMovement
   \SecondMovement
%}

} % \book
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



reply via email to

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