LilyPond 記譜法リファレンス: 5.6.2 Substitution function examples

### 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" d e f
>       \padText #2.6
>       c4^"piu mosso" fis a g
>     }

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?)
>        #{
>          \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
>        #})

>     \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? string?)
>        #{
>          \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
>     }

他の言語: English, deutsch, español

#### LilyPond — 記譜法リファレンス