[ << Changing defaults ] | [Top][Contents][Index][ ? ] | [ Notation manual tables >> ] | ||
[ < Substitution function syntax ] | [ Up : Using music functions ] | [ Notation manual tables > ] |
5.6.2 Substitution function examples
This section introduces some substitution function examples. These are not intended to be exhaustive, but rather to demonstrate some of the possibilities of simple substitution functions.
In the first example, a function is defined that simplifies setting the padding of a TextScript:
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" b a b \padText #2.6 c4^"piu mosso" b a b }
In addition to numbers, we can use music expressions such as notes for arguments to music functions:
custosNote = #(define-music-function (parser location note) (ly:music?) #{ \tweak NoteHead.stencil #ly:text-interface::print \tweak NoteHead.text \markup \musicglyph #"custodes.mensural.u0" \tweak Stem.stencil ##f #note #}) \relative c' { c4 d e f \custosNote g }
Substitution functions with multiple arguments can be defined:
tempoPadded = #(define-music-function (parser location padding tempotext) (number? markup?) #{ \once \override Score.MetronomeMark.padding = #padding \tempo \markup { \bold #tempotext } #}) \relative c'' { \tempo \markup { "Low tempo" } c4 d e f g1 \tempoPadded #4.0 "High tempo" g4 f e d c1 }
[ << Changing defaults ] | [Top][Contents][Index][ ? ] | [ Notation manual tables >> ] | ||
[ < Substitution function syntax ] | [ Up : Using music functions ] | [ Notation manual tables > ] |
Other languages: deutsch, español, français, italiano, 日本語.
About automatic language selection.