lilypond-user
[Top][All Lists]
Advanced

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

Conditional expressions


From: Dr A V Le Blanc
Subject: Conditional expressions
Date: Thu, 20 Feb 2003 17:35:03 +0000
User-agent: Mutt/1.3.99i

Often I find I have two different versions of a .ly file,
one for printed output and one for midi files.  For example,
I may want repeats to be expanded when I produce a midi file,
but not in printed output.  For this purpose, to avoid having
to edit a lot of statements, I usually have near the top of
the file a line like this

     rptarg = "volta"

or like this

     rptarg = "unfold"

and I write my repeat statements like this:

     \repeat \rptarg 2 {

so that I can change all of them be editing a single line.

It is not so simple with input of other kinds, however.  For
example, if I have a passage which I want to print with '8va',
but to play the actual pitch, I currently do something like this:

%midi \times 2/3 { [ < a8 d, > es g ] } [ < a8. d, > g16 ] %midi
%midi < c4 e, > r | \times 2/3 { [ < d,8 %midi
 \times 2/3 { [ < a,8 \spanrequest \start "text" d, > es g ] } %midi not
 [ < a8. d, > g16 ] < c4 \spanrequest \stop "text" %midi not
 e, > r | \times 2/3 { [ < d8 %midi not

where I comment out the '%midi' lines for printed output, and the
'%midi not' lines for midi output.

I'd like to have some construct that allows me to do this in a
simpler way.   For example,

    #(define (rptdsp x y) (if (equal? 'rptarg "volta") (display x)
             (display y)))

and then in the text write something applying rptdsp to two
expressions, so that one of them would automatically be used
when rptarg is defined to volta, and one when it is not.  But I
don't quite understand the lilypond/scheme inteface well enough
to see how to do this.  In older lilypond.doc files there used
to be something about an 'apply' function, but I can't find
that in the 1.6.6 manual.  And I'm uncertain as to how to
pass two arguments to a scheme function from an ly file.

     -- Owen
     address@hidden




reply via email to

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