I am starting to play with lilypond functions. I wanted to write a function that allowed me to use repeat unfold, but typing less. This is the code I have right now:
\version "2.14.2"
\language "english"
\header {
title = "Functions example"
}
#(define mydrums '(
(crashcymbalb cross #f 9)
(crashcymbala cross #f 8)
(crashcymbal cross #f 7)
(ridecymbal cross #f 6)
(ridebell default #f 6)
(splashcymbal xcircle #f 5)
(hihat cross #f 4)
(openhihat cross "open" 4)
(closedhihat cross "stopped" 4)
(halfopenhihat xcircle #f 4)
(hightom default #f 3)
(chinesecymbal diamond #f 2)
(snare default #f 1)
(himidtom default #f -1)
(lowtom default #f -3)
(pedalhihat cross #f -4)
(bassdrum default #f -5)
)
)
rpt =
#(define-music-function
(parser location repetitions drumnotes)
(number? ly:music?)
#{
\repeat unfold #repetitions #drumnotes
#}
)
up = \drummode {
\time 4/4
\tempo 4 = 60
\rpt #4 {sn4 sn8 sn sn4}
}
down = \drummode {
bd4 bd bd bd
}
\score {
\new DrumStaff <<
\set DrumStaff.drumStyleTable = #(alist->hash-table mydrums)
\new DrumVoice { \voiceOne \up }
\new DrumVoice { \voiceTwo \down }
>>
\layout {}
\midi {}
}
However, I get 3 error messages (simplified):
37:36: syntax error, unexpected SCM_TOKEN
\repeat unfold #repetitions
#drumnotes
45:1: error in #{ ... #}
}
44:5: music function cannot return #<unspecified>
\rpt #4 sn4
Is there anything I am doing wrong? Does it have to do anything with the drumnotes argument, which should not be of type ly:music?