Learning LilyPond

Bildschirmfoto 2024-08-28 um 18.44.50

I have been a musician for over 30 years. During that time there were periods where I practiced up to 8 hours per day and performed several times per month. There were also periods in which I didn’t practice or perform for months or years. In the past year or so I have gotten back into playing again. I joined a rock cover band, Vice Rock , have been playing with and mentoring the drummers my children’s school big band, spent several months improving my piano skills, and have even written a couple songs recently.

As part of writing songs, I decided that I wanted to make some nice sheet music for them. I knew that were some music typesetting options with LaTeX, and since I have been an avid LaTeX user for nearly twenty years now, I did some investigation into that. After some research, I decided that LilyPond was the best option, which is not actually LaTeX, although there is a LaTeX package to integrate LilyPond into LaTeX documents. LilyPond shares many traits with TeX. It has a relatively simple syntax, such that in many ways, you can read the source code and understand what notes are to be played. It also is very powerful, allowing you to change just about every setting you could possibly think of, and also create new functionality through its embedded programming language, Scheme. I was aware of Scheme before, but had never used it. I knew it was a functional programming language in the LISP family. As I have been learning LilyPond, I also took some time to get familiar with Scheme. I found a very handy website explaining Scheme concepts and how they relate to LilyPond. I think it will still take some time for me to get extremely proficient at writing my own functions, but I learned quite a bit, and found enough answers on forums to get some results I am fairly satisfied with. I thought I would share some of my experiences here, in case they are useful to anyone else (especially my future self).

I recently ran across a cadence I wrote back in 1998 when I was teaching the Trenton high school marching band drumline in Michigan. I decided it would be nice if I could re-write it, instead of hand written to a professional looking manuscript. Drum notation has some very specific symbols not found in most standard music you would see for wind or string instruments, or even for classical percussion. After a lot of searching, I was able to find some solutions which work quite well. The first one I tackled was diddles. This actually took some time, because the first solutions I found were for classical style drum rolls, which uses two or three slashes on a stem to indicate a roll. In modern marching drum music, one usually only writes a single slash, to indicate a double stroke. I learned that one can simply use the tremolo notation like sn16:32 but that yields a horizontal slash on the stem, instead of an angled one. I found a very handy lilypond cookbook on Tumblr, which advised me how to achieve my desired effect. Here you can see the effect of changing the StemTremelo settings

\drummode {
sn16:32 sn16:32 sn16:32 sn16:32
sn16:32 sn16:32 sn16:32 sn16:32
r2
\override StemTremolo.slope = #0.25
\override StemTremolo.beam-width = #1.5
sn16:32 sn16:32 sn16:32 sn16:32
sn16:32 sn16:32 sn16:32 sn16:32
r2
}

Bildschirmfoto 2024-08-28 um 18.34.27
Customizing rolls

In addition to double stroke rolls, there are also buzz rolls or buzz strokes, which are indicated with a “z” across the stem. I found some more advice on the Tumblr LilyPond cookbook for this, as well as some advice on reddit. I modified it a bit more to my own personal taste, and ended up with this custom function

buzzSymbol = \markup \path #0.25
#(let ((x 1/2) (y 1/2))
`((moveto ,x ,(- y)) (lineto ,(- x) ,(- y))
(lineto ,x ,y) (lineto ,(- x) ,y)))

applyBuzzSymbol = #(grob-transformer 'stencil
(lambda (grob orig)
(let* ((yex (ly:stencil-extent orig Y))
(ypos (interval-index yex CENTER))
(sten (grob-interpret-markup grob buzzSymbol)))
(ly:stencil-add orig
(ly:stencil-translate-axis sten ypos Y)))))
buzz = \tweak Stem.stencil \applyBuzzSymbol \etc

Then I can use it like so:

    r8 \buzz sn8_"R" rimclick8_L  sn16 sn16 r16 rimclick8 sn16 rimclick8 sn8

which looks like:

Bildschirmfoto 2024-08-28 um 18.56.59
buzz strokes and rimclicks

One thing I could not figure out was how to change the look of the unattached eighth note, since the “z” kind of collides with the curl indicating an eighth note. I figured there was a way to alter the look of the eighth notes, but I haven’t found it yet. Maybe someday.

Another tricky issue for writing drum music is flams. I flam is when you play one hand right before the other, which is also known as a grace note. They are usually written as a small eighth note with a slash through it. After some more research, I found out how to achieve this as well, and wrote a custom function to make it easy. I actually defined two functions, one for right and one for left flam. One thing I could not get to work correctly was to reset the Stem.length to the previous value. There is a \revert command, but it did not seem to work for me. I think maybe it was reverting to the default value, but I had overridden the Stem.length previously to my taste.

rflam = #(define-music-function (dur) (ly:duration?)
#{ \drummode {
\override Stem.length = #4
\slashedGrace sna8
\override Stem.length = #7
sn$dur ^> _"R" } #})

lflam = #(define-music-function (dur) (ly:duration?)
#{ \drummode {
\override Stem.length = #4
\slashedGrace sna8
\override Stem.length = #7
sn$dur ^> _"L" } #} )

Then I can use them like so

  \rflam16 sn16_"R" \lflam16 sn16_"L" \rflam4 r2
Bildschirmfoto 2024-08-28 um 18.41.41
Typesetting flams

Similar to LaTeX, LilyPond also allows you to include files in other ones. Once I had figured out some of the basic changes I wanted to make, I started organizing separate files into libraries, which I plan to use for other pieces I write. I ended up creating one file with all of my general definitions for drumline. Then I created a separate file for setting specific to typesetting a score with the four main instruments for drumline – snare, tenors, bass, and cymbals. In particular, scores are normally typeset with a landscape page orientation. I then created a file for the actual notes of each instrument, and then a very basic file for the score, as well as individual instruments.

If you are interested in learning more, or re-using, I put all of my work in my new music Github repository. If you are just interested in learning Streetbeat 98, here is the pdf of the score.

I have also been working on recording video of this cadence. I will try to post that soon.

Join 164 other subscribers

archives

  • 2024 (8)
  • 2023 (8)
  • 2022 (15)
  • 2021 (19)
  • 2020 (1)
  • 2019 (1)
  • 2018 (2)
  • 2017 (1)
  • 2016 (2)
  • 2015 (5)
  • 2014 (5)
  • 2013 (2)
  • 2011 (7)
  • 2010 (10)
  • 2009 (50)
  • 2008 (28)
  • 2007 (31)
  • 2006 (8)

Category