Custom percussion staves

Custom percussion styles may be defined, to which the drumStyleTable property may then be set. Existing notations may be redefined as an association list where each entry has to be comprised of four items: a name, the note head style (or default), an articulation sign if needed (or #f if not), and the note head’s position on the staff. That list must then be converted into a Scheme hash table, using the alist->hash-table function.

#(define mydrums '(
         (bassdrum        default   #f           -1)
         (snare           default   #f           0)
         (hihat           cross     #f           1)
         (halfopenhihat   cross     halfopen     1)
         (pedalhihat      xcircle   stopped      2)
         (lowtom          diamond   #f           3)))

up = \drummode { hh8 hh hhho hhho hhp4 hhp }
down = \drummode { bd4 sn bd toml8 toml }

\new DrumStaff \with { drumStyleTable = #(alist->hash-table mydrums) }
    \new DrumVoice { \voiceOne \up }
    \new DrumVoice { \voiceTwo \down }

[image of music]

New names may also be added to these custom notations through the drumPitchNames variable, that may be redefined as an association list (or augmented by appending a new list to its existing value, as demonstrated below), but also through its individual entries. This also makes it possible to define aliases: alternate input shorthand for some notations.

drumPitchNames =
    '((leftsnap . sidestick)
      (rightsnap . ridecymbal))
    drumPitchNames) = #'sidestick = #'ridecymbal

\drums {
  leftsnap4. rightsnap8 leftsnap4 rightsnap
  ls8 rs ls rs ls4 rs

[image of music]

In a similar manner, the drumPitchTable property associates a specific pitch (meaning a different instrument sound, as provided by available MIDI sound fonts) to each notation. That property needs to be defined as a hash table, which is again converted from an association list (stored by default as the midiDrumPitches variable). Redefining these associations is achieved as explained above, either by defining an entire association list or through individual entries. The following example demonstrates how to create a whole notation set with its own input syntax, custom notations and corresponding MIDI output.

drumPitchNames.dbass      = #'dbass
drumPitchNames.dba        = #'dbass  % 'db is in use already
drumPitchNames.dbassmute  = #'dbassmute
drumPitchNames.dbm        = #'dbassmute         = #'dopen
drumPitchNames.dopenmute  = #'dopenmute
drumPitchNames.dom        = #'dopenmute
drumPitchNames.dslap      = #'dslap
drumPitchNames.ds         = #'dslap
drumPitchNames.dslapmute  = #'dslapmute
drumPitchNames.dsm        = #'dslapmute

#(define djembe-style
  '((dbass      default  #f         -2)
    (dbassmute  default  stopped    -2)
    (dopen      default  #f          0)
    (dopenmute  default  stopped     0)
    (dslap      default  #f          2)
    (dslapmute  default  stopped     2)))

midiDrumPitches.dbass     = g
midiDrumPitches.dbassmute = fis
midiDrumPitches.dopen     = a
midiDrumPitches.dopenmute = gis
midiDrumPitches.dslap     = b
midiDrumPitches.dslapmute = ais

test = \drummode { dba4 do ds dbm dom dsm }

\score {
  \new DrumStaff \with {
    \override StaffSymbol.line-count = 3
    instrumentName = "Djembé "
    drumStyleTable = #(alist->hash-table djembe-style)
    drumPitchTable = #(alist->hash-table midiDrumPitches)
  } {
    \time 3/4
  \layout {}
  \midi {}

[image of music]

See also

Installed Files: ly/

Snippets: Percussion.

Internals Reference: DrumStaff, DrumVoice.

LilyPond Notation Reference v2.25.17 (development-branch).