Next: , Up: Music functions


6.1.1 Overview of music functions

Making a function which substitutes a variable into LilyPond code is easy. The general form of these functions is

function =
#(define-music-function (parser location var1 var2... )
                        (var1-type? var2-type?...)
  #{
    ...music...
  #})

where

argi ith variable
argi-type? type of variable
...music... normal LilyPond input, using variables as #$var1.

There following input types may be used as variables in a music function. This list is not exhaustive; see other documentation specifically about Scheme for more variable types.

Input type argi-type? notation
Integer integer?
Float (decimal number) number?
Text string string?
Markup markup?
Music expression ly:music?
A pair of variables pair?

The parser and location argument are mandatory, and are used in some advanced situations. The parser argument is used to access to the value of another LilyPond variable. The location argument is used to set the ‘origin’ of the music expression that is built by the music function, so that in case of a syntax error LilyPond can tell the user an appropriate place to look in the input file.

Esta página corresponde a LilyPond-2.11.58 (rama de desarrollo).

Informe de los fallos a través de la lista en español lilypond-es, o en inglés a través de http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs.

Se agradecen las sugerencias para la documentación.