> Is there a possibility to do something like this?
>
> if( custom_cfg_flag)
> {
> % default score combination
> % (e.g. with header and chords)
> }
> else
> {
> % some other combination
> % (e.g. only melody)
> }
I have also always wanted LilyPond to provide me with
the code-writing niceties which C offers. Here is a
method which enables me to use blocks of preprocessor
directives in the manner which I am used to:
#define BEGRIFF
#ifdef BEGRIFF
#define INTEGER_CONSTANT 1
#else
#define INTEGER_CONSTANT 43
#endif
My operating system is Linux. For its GNU Compiler Suite
there is the preprocessor ``gpp''. This preprocessor can
be invoked with the ``-T'' option, to instruct it to
understand macros which are written in the style that
TeX (and LilyPond) use.
The first shell script processes a the file
``if-else-1a-input.ly''.
-----if-else-1a-input.ly-----
% Within a region which is commented, you can embed your
% macro definitions.
% \define{conditionalPackage}
% \ifdef{conditionalPackage}
% \define{musicPassage}{\musicPassageAlpha}
% \else
% \define{musicPassage}{\musicPassageBeta}
% \endif
\version "2.12.3"
\header { title = "Using if/else Constructs by Means of GPP" }
musicPassageAlpha = { c'4 d' e' f' }
musicPassageBeta = { b,4 a, g, f, }
\score {
<<
\new Staff \musicPassage
>>
\layout { }
}
% EOF
-----------------------
Here is the shell script that does the work:
-----if-else-1a.sh-----
#! /bin/bash
# Invokes ``[[gpp]]'' in order to process an input file
# which has a macro definition in it formatted in the
# manner which TeX formats things.
INPUT_FILE=if-else-1a-input.ly
OUTPUT_FILE=if-else-1a-output.ly
gpp -T -o $OUTPUT_FILE $INPUT_FILE && \
echo 'Output file "'$OUTPUT_FILE'" successfully written.'
# EOF
-----------------------
The second shell script processes a the file
``if-else-1b-input.ly''. This document has an ``undef''
preprocessor directive in it.
-----if-else-1b-input.ly-----
% Within a region which is commented, you can embed your
% macro definitions.
% This version puts an ``undef'' preprocessor
% directive in the macro definition.
% \define{conditionalPackage}
% \undef{conditionalPackage}
% \ifdef{conditionalPackage}
% \define{musicPassage}{\musicPassageAlpha}
% \else
% \define{musicPassage}{\musicPassageBeta}
% \endif
\version "2.12.3"
\header { title="Using if/else Constructs by Means of GPP" }
musicPassageAlpha = { c'4 d' e' f' }
musicPassageBeta = { b'''4 a''' g''' f''' }
\score {
<<
\new Staff \musicPassage
>>
\layout { }
}
% EOF
-----------------------
Here is the shell script that does the work:
-----if-else-1b.sh-----
#! /bin/bash
# Invokes ``[[gpp]]'' in order to process an input file
# which has a macro definition in it formatted in the
# manner which TeX formats things.
INPUT_FILE=if-else-1b-input.ly
OUTPUT_FILE=if-else-1b-output.ly
gpp -T -o $OUTPUT_FILE $INPUT_FILE && \
echo 'Output file "'$OUTPUT_FILE'" successfully written.'
# EOF
-----------------------
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user