lilypond-user
[Top][All Lists]
Advanced

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

(De)activate lilypond-source snippets based on whether a variable is def


From: Hans Aikema
Subject: (De)activate lilypond-source snippets based on whether a variable is defined
Date: Mon, 20 May 2013 13:58:15 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130509 Thunderbird/17.0.6

As there are several advanced Lilypond programming experts on this group I'd like to know if any of you know a way to have conditional activation of lilypond-sourcelines based on the existence of a defined variable.

The basic setup of my Lilypond scores is as follows:

Song.ly: A 'wrap it all up' lilypond source containing:
* Song meta-information (\header block)
* Definition of a variable to define the common shared items such as key and tempo
* A \include per voice to include the voice's music- and lyrics-variables
* A \include to include the score-layout (containing definitions to get a combined score, full-volume all parts midi and a per-voice highlighted midi (highlighted by reducing volume of the other voices)

Per voice a <voicename>.ly file containing:
* a variable definition to define the music: <voicename>Music
* a variable definition to define the lyrics: <voicename>Words

ScoreLayout.ly: I need one file for each possible score-setup, with a repeating and predictable structure only varying for the number of voices:
* \include of some global formatting options
* definition of variables for the midi-instruments and volume-levels of 'full volume' and 'reduced volume' voices * variable-definition of the combined music with all voices at 'full volume' (allMusic) * per voice a variable-definition of the combined music with all voices at 'reduced volume' except for the voice to highlight * a \score containing a \layout on which New_dynamic_engraver is removed (because dynamics are used as a hack for midi-volume * a \score per voice using that voice's variable definition that joins the voice at full volume with the other voices at reduced volume containing a \midi {}

Now where I start to annoy myself is that whenever I encounter a new parts-setup I have to create a new layout (properly named like layout-SATB-SATB-lyrics.ly, layout-SoSATB-SoSATB-lyrics.ly, layout-SoSAATB-SoSAATB-lyrics.ly, layout-SoSATB-SoST-lyrics.ly etc. etc). What I'd like to do for ScoreLayout.ly is something like (the 'optionally include blocks' marked with %if and %endif):

allMusic = {
    \new ChoirStaff <<
        %if defined variable soloOneMusic
            \new Staff = soloOne \with {
                  midiMinimumVolume = \volFullMin
                  midiMaximumVolume = \volFullMax
            }<<
                \new Voice = "voiceSoloOne" { << \global \soloOneMusic >> }
            >>
        %endif
        %if defined variable sopranoMusic
            \new Staff = soprano \with {
                  midiMinimumVolume = \volFullMin
                  midiMaximumVolume = \volFullMax
            }<<
                \new Voice = "voiceSoprano" { << \global \sopranoMusic >> }
            >>
        %endif
        %if defined variable sopranoTwoMusic
            \new Staff = sopranoTwo \with {
                  midiMinimumVolume = \volFullMin
                  midiMaximumVolume = \volFullMax
            }<<
\new Voice = "voiceSopranoTwo" { << \global \sopranoTwoMusic >> }
            >>
        %endif
        %if defined variable soloOneWords
\new Lyrics \with {alignBelowContext=solo} \lyricsto voiceSolo \soloWords
        %endif
        %if defined variable sopranoWords
\new Lyrics \with {alignBelowContext=soprano} \lyricsto voiceSoprano \sopranoWords
        %endif
        %if defined variable sopranoTwoWords
\new Lyrics \with {alignBelowContext=sopranoTwo} \lyricsto voiceSopranoTwo \sopranoTwoWords
        %endif
    >> % end of ChoirStaff
}
soloOneHighlight = {
    \new ChoirStaff <<
        %if defined variable soloOneMusic
            \new Staff = soloOne \with {
                  midiMinimumVolume = \volFullMin
                  midiMaximumVolume = \volFullMax
            }<<
                \new Voice = "voiceSoloOne" { << \global \soloOneMusic >> }
            >>
        %endif
        %if defined variable sopranoMusic
            \new Staff = soprano \with {
                  midiMinimumVolume = \volReduceMin
                  midiMaximumVolume = \volReduceMax
            }<<
                \new Voice = "voiceSoprano" { << \global \sopranoMusic >> }
            >>
        %endif
        %if defined variable sopranoTwoMusic
            \new Staff = sopranoTwo \with {
                  midiMinimumVolume = \volReduceMin
                  midiMaximumVolume = \volReduceMax
            }<<
\new Voice = "voiceSopranoTwo" { << \global \sopranoTwoMusic >> }
            >>
        %endif
        %if defined variable soloOneWords
\new Lyrics \with {alignBelowContext=solo} \lyricsto voiceSolo \soloWords
        %endif
        %if defined variable sopranoWords
\new Lyrics \with {alignBelowContext=soprano} \lyricsto voiceSoprano \sopranoWords
        %endif
        %if defined variable sopranoTwoWords
\new Lyrics \with {alignBelowContext=sopranoTwo} \lyricsto voiceSopranoTwo \sopranoTwoWords
        %endif
    >> % end of ChoirStaff
}
%if defined variable soloOneMusic
\score {
    \unfoldRepeats << \global \soloOneHighlight >>
    \midi {}
}
%endif

etc.etc.

Is this somehow easy to accomplish? Or is it better to just keep up adding layouts using manual labor each and every time I encounter a different setup (more than the regular SATB-voices and/or one or more solos)?

regards,
Hans Aikema




reply via email to

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