[Top][All Lists]

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

Re: Variable assignment in music functions

From: Jean-Charles Malahieude
Subject: Re: Variable assignment in music functions
Date: Thu, 03 Nov 2011 19:26:47 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:7.0) Gecko/20110927 Thunderbird/7.0

Le 03/11/2011 19:02, Michael Ellis disait :
Thanks for the suggestion, Jean-Charles.  I think I've now got
a solution that's fairly satisfactory:

In my include file, I now have:

#(define (make-named-instrument default-name)
   (define iname default-name)

   (define (set newname)
     (set! iname newname))

   (define (interface op . rest)
       ((eq? op 'set)
         (set (car rest)))
       ((eq? op 'get)
       (else (error "Undefined operation"))))


#(define mainInstrument (make-named-instrument "cello"))
#(define cueInstrument (make-named-instrument "acoustic grand"))
#(define clapInstrument (make-named-instrument "woodblock"))

#(define (setMainCueClapInstruments main cue clap)
    (mainInstrument 'set main)
    (cueInstrument 'set cue)
    (clapInstrument 'set clap)


This allows me to do

      \set midiInstrument = #(cueInstrument 'get)

in my cueNotes and similar functions and the choice of instruments can
be set within the .ly file by

     #(setMainCueClapInstruments "trumpet" "clarinet" "timpani")

Is it just me, or has the thought occurred to others that LilyPond
might actually be easier to learn and use if the entry language was
pure Scheme?  :-)

I actually used this kind of artifact with King Arthur: I typeset it for a music school here in France, so the table of contents, character and instrument names should be in French. Beside that, the sources I uploaded on the CPDL might be used in countries where French is not as commonly used as in France and "Inhaltsverzeichnis" looks better in German than "Table des matières". So I had to find a way to collect all the strings that should be adapted in one place (per language) and set this preference in one dedicated file that gets included in each master file.


On Thu, Nov 3, 2011 at 1:34 PM, Jean-Charles Malahieude
Le 03/11/2011 12:53, Michael Ellis disait :

So, with that as background, let me re-ask the question in a different
form:  What's the best way to support changing a set of default

Wouldn't it be possible to base it on an extra file, let's say a
"dictionary.ily" where you define variables like
myCueColor = Blue_with_yellow_spots
muCueInstrument = TripleBassThatSoundsLikeSnoringDucks

that you include in your templates where you would then have something like

\set midiInstrument = \myCueInstrument
\override Rest #'color = \myCueColor

This is just a guess...

reply via email to

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