My current project is to create a number of short snippets for doumbek. To create each snippet, I use the following \score
block:
\header { piece = "Name here" } % different for each snippet
\score {
\new DrumStaff \with {
instrumentName = "doumbek"
drumStyleTable = #timbales-style
\override StaffSymbol.line-count = #2
\override BarLine.bar-extent = #'(-1 . 1)
} \drummode {
\time 2/4 % music goes here
timl8.-> ssh16 timl8-> ssl-> % the actual music
\bar ":|."
}
}
\markup { "Additional performance notes here" } % only if needed
The complications with typing this are:
- Copying all that for each snippet is unacceptably duplicative.
- There are about 40 of these two-bar snippets in the project.
- It's all the customization of the
DrumStaff
that adds the majority of the bloat.
After searching (and not finding) how exactly Lilypond internally defines \drums
as \new DrumStaff \drummode
(so I could define some kind of \DoumbekStaff
), I found a way to define a Scheme function to generate the \score blocks I want.
My code now looks like:
% define the Scheme \score template
dscore =
#(define-scheme-function
(title ts perf-notes music)
(markup? fraction? markup? ly:music?)
#{
\header { piece = $title }
\score {
\new DrumStaff \with {
instrumentName = "doumbek"
drumStyleTable = #timbales-style
\override StaffSymbol.line-count = #2
\override BarLine.bar-extent = #'(-1 . 1)
} \drummode {
\time $ts
$music
\bar ":|."
}
}
\markup { $perf-notes }
#})
% the actual music
#(dscore
"Ayoub"
(2 . 4)
""
#{
\repeat percent 3 { timl8.-> ssh16 timl8-> ssl-> } |
timl16-> ssh ssl-> ssh timl-> ssh ssl8-> |
#}
)
Running this as written simply doesn't work. Guile signals an error for the expression beginning with #(dscore
because "Wrong number of arguments to 2". Changing the time signature from 2/4 to 5/4 for testing changes the error to "Wrong number of arguments to 5", so the current problem is with the time signature. fraction?
is supposed to be a fraction represented by a pair but neither my (2 . 4)
nor my (5 . 4)
has been accepted.
Quoting the pair '(2 . 4)
makes that error go away but then I am assaulted with numerous complaints that my \drummode
notes are not, in fact, notes. It seems to attempt to evaluate the music expression before expanding the dscore
function and entering the \drummmode
that is in the function.
Commenting out the drum music and replacing it with normal note name notation, like a2 b4 c
, to see if it works at all gives me a fatal error of "unexpected \score, expecting end of input".
Finally, there are almost certainly numerous other mistakes in the above code. Although the time signature being uncooperative is my current blocking issue, pointers about other mistakes I made would be much appreciated, as I cannot make any further progress until this template works.