4 texidoc= "Test optional music function arguments.
5 The output is nonsensical, but if you wrack your brain,
6 you'll figure it out. Remember that optional arguments
7 are matched left to right, and after the first non-match,
11 \layout { ragged-right = ##t }
13 % Get following pitch into Scheme
14 pitch = #(define-scheme-function (parser location p) (ly:pitch?) p)
15 % The same with a duration
16 dur = #(define-scheme-function (parser location p) (ly:duration?) p)
18 % Just like \relative, but defaulting to f as reference, making the
19 % first note of the music the same as if written as absolute pitch
21 #(define-music-function (parser location ref music)
22 ((ly:pitch? #{ \pitch f #}) ly:music?)
23 #{ \relative $ref $music #})
25 % Let's take a duration and four pitches, defaulting to 2 c' d' e'
27 #(define-music-function (parser location dur a b c d)
28 ((ly:duration? #{ \dur 2 #}) (ly:pitch? #{ \pitch c' #})
29 (ly:pitch? #{ \pitch d' #}) (ly:pitch? #{ \pitch e' #})
30 ly:music?) #{ $a $dur $b $c ^\markup{!} $d #})
32 \new Voice { \relative c' e' \relative { e' } \ablative c' e' \ablative { e' }
33 \zap 8. c'' d'' {e''4..} \zap f''8 g'' \zap 4 a'' b'' c''' d'''2 }