Simple substitution functions - GNU LilyPond
Description: GNU LilyPond

Next: Paired substitution functions, Previous: Overview of music functions, Up: Music functions

#### 12.1.2 Simple substitution functions

Here is a simple example,

>          padText = #(define-music-function (parser location padding) (number?)
>            #{
>              \once \override TextScript #'padding = #$padding
>            #})

>          \relative c''' {
>            c4^"piu mosso" b a b
>            \padText #1.8
>            c4^"piu mosso" d e f
>            \padText #2.6
>            c4^"piu mosso" fis a g
>          }

Music expressions may be substituted as well,

>          custosNote = #(define-music-function (parser location note)
>                                               (ly:music?)
>            #{
>              \once \override Voice.NoteHead #'stencil =
>                #ly:text-interface::print
>              \once \override Voice.NoteHead #'text =
>                \markup \musicglyph #"custodes.mensural.u0"
>              \once \override Voice.Stem #'stencil = ##f
>              $note
>            #})

>          { c' d' e' f' \custosNote g' }

Multiple variables may be used,

>          tempoMark = #(define-music-function (parser location padding marktext)
>                                              (number? string?)
>          #{
>            \once \override Score . RehearsalMark #'padding = $padding
>            \once \override Score . RehearsalMark #'no-spacing-rods = ##t
>            \mark \markup { \bold $marktext }
>          #})

>          \relative c'' {
>          c2 e
>          \tempoMark #3.0 #"Allegro"
>          g c
>          }

Next: Paired substitution functions, Previous: Overview of music functions, Up: Music functions

This page is for LilyPond-2.10.33 (stable-branch).