[ << General input and output ] | [Top][Contents][Index] | [ Spacing issues >> ] |
[ < Using music functions ] | [ Up : Using music functions ] | [ Substitution function examples > ] |
3.4.3.1 Substitution function syntax
Making a function that substitutes a variable into LilyPond code is easy. The general form of these functions is
function = #(define-music-function (arg1 arg2 …) (type1? type2? …) #{ …music… #})
where
argN | The nth argument. |
typeN? | A Scheme type predicate for which argN
must return #t . |
…music… | Normal LilyPond input, using $ (in places where only
LilyPond constructs are allowed) or # (to use it as a Scheme
value or music function argument or music inside of music lists) to
reference arguments
(e.g., ‘#arg1’). |
The list of type predicates is required. Some of the most common type predicates used in music functions are:
- boolean?
- cheap-list? (use instead of ‘list?’ for faster processing)
- ly:duration?
- ly:music?
- ly:pitch?
- markup?
- number?
- pair?
- string?
- symbol?
For a list of available type predicates, see Predefined type predicates. User-defined type predicates are also allowed.
See also
Notation Reference: Predefined type predicates.
Extending LilyPond: Music functions.
Installed Files: ‘lily/music-scheme.cc’, ‘scm/c++.scm’, ‘scm/lily.scm’.
[ << General input and output ] | [Top][Contents][Index] | [ Spacing issues >> ] |
[ < Using music functions ] | [ Up : Using music functions ] | [ Substitution function examples > ] |