Am 16.01.2015 um 01:37 schrieb Craig Parker-Feldmann:
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)
}
Yes, definitely.
I don't really know what you want yet, but in general you can do such
stuff with Scheme.
Try this:
%%%%%%%%%%%
%#(define some-cfg-variable #t)
#(define some-cfg-variable #f)
musicOne = { c'' d'' c'' }
musicTwo = { c' d' c' }
\score {
<<
\new Staff \musicOne
#(if some-cfg-variable
#{ \new Staff \musicTwo #})
>>
}
%%%%%%%%%%%
Of course there is much more to it, but it may give you a first
impression of what is possible.
The "#(" starts a Scheme expression.
with "#{ #}" inside a Scheme expression you can produce LilyPond output
again.
HTH
Urs
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
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user