]> git.donarmstrong.com Git - lilypond.git/blob - input/regression/optional-args.ly
Fixed errors in Catalan translation
[lilypond.git] / input / regression / optional-args.ly
1 \version "2.17.15"
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 % 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)
17
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
20 ablative =
21 #(define-music-function (parser location ref music)
22   ((ly:pitch? #{ \pitch f #}) ly:music?)
23   #{ \relative $ref $music #})
24
25 % Let's take a duration and four pitches, defaulting to 2 c' d' e'
26 zap = 
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  #})
31
32 \new Voice { \relative c' e' \relative c' { e' } \ablative c' e' \ablative { e' }
33   \zap 8. c'' d'' {e''4..} \zap f''8 g'' \zap 4 a'' b'' c''' d'''2 }