]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/optional-args.ly
Merge branch 'translation'
[lilypond.git] / input / regression / optional-args.ly
1 \version "2.19.0"
2
3 \header{
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,
8 the rest is skipped."
9 }
10
11 \layout { ragged-right = ##t }
12
13 % Just like \relative, but defaulting to f as reference, making the
14 % first note of the music the same as if written as absolute pitch
15 ablative =
16 #(define-music-function (parser location ref music)
17   ((ly:pitch? #{ f #}) ly:music?)
18   #{ \relative $ref $music #})
19
20 % Let's take a duration and four pitches, defaulting to 2 c' d' e'
21 zap = 
22 #(define-music-function (parser location dur a b c d)
23   ((ly:duration? #{ 2 #}) (ly:pitch? #{ c' #})
24    (ly:pitch? #{ d' #}) (ly:pitch? #{ e' #})
25    ly:music?) #{ $a $dur $b $c ^\markup{!} $d  #})
26
27 \new Voice { \relative c' e' \relative c' { e' } \ablative c' e' \ablative { e' }
28   \zap 8. c'' d'' {e''4..} \zap f''8 g'' \zap 4 a'' b'' c''' d'''2 }