5.6.2 置換関数の例

このセクションでは、置換関数の例をいくつか紹介します。高度なことはしていませんが、シンプルな置換関数を実現する方法を示しています。

最初の例では、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
}

[image of music]

数値のほかに、音符などの音楽表記を音楽関数への引数にすることができます:

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 }

[image of music]

複数の引数をとる置換関数を定義することもできます:

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
}

[image of music]


他の言語: English, deutsch, español, français, italiano
About automatic language selection.

LilyPond — 記譜法リファレンス

inserted by FC2 system