LilyPond is an open source technology for notating music in plain text files. In this course, we'll cover the fundamentals of music notation in LilyPond.
Tags: none
In this course, you'll learn how to notate music with LilyPond! You can download LilyPond and run the code from this project directly, or you can use LilyBin to play your masterpiece in the browser.
After taking this course, you'll be able to:
- Add notes
- Specify a rhythm
- Change a time signature
- Add multiple notes, or chords
- Change a key signature
- Use accidentals
- Specify dynamics
When you're done, you'll be able to answer questions like:
- How do I notate music for free?
- How do I make sheet music without a mouse or clicking through a software interface?
- How can I make version controlled sheet music?
- Where can I find free sheet music?
- How do I use LilyPond?
- What can I use LilyPond for?
We can't wait to see what you create!
We're going to learn how to do some single instrument notation with nothing other than a plain text editor.
- This course assumes you are able to read sheet music in treble clef.
- This course assumes you are familiar with the GitHub interface and working with pull requests. If you need a refresher, try Introduction to GitHub.
- We assume you are comfortable using files and folders.
- LilyPond, software that makes sheet music from plain text files
- LilyBin, a website where you can run LilyPond for free
- You'll be able to hear MIDI files output from LilyPond
- GitHub's file editing interface
If you are a musician, music teacher, or music student this is a great course for you. If you're wanting to learn how to notate music without needing to use a mouse or click through an interface, this is the best course for you. If you're wanting to learn how to create beautiful, amazing sheet music for free, this is a fantastic way to do that. And if you're a person who loves version control and sheet music, take this course pronto!
LilyPond is an open source music notation technology. With LilyPond, music can be notated in non-binary files with numbers and symbols, just like code.
In this course, we're going to practice some of the fundamental ways to notate music with LilyPond, like:
- Pitches
- Rhythms
- Time signature
- Key signature
- Accidentals
- Dynamic markings
Before you start this course, you may want to be familiar with a few concepts, like melody and rhythm notation in traditional western music. This course is not about how music is notated - it's about how to notate music with LilyPond.
LilyPond uses the alphabetical note names to determine pitch. In this pull request, we see:
c8\mf c g' b
a a <g d>4
f4 f e e
d d c2
Some of these letters, numbers, and symbols represent things related to the notes, and some represent pitches. The letters that represent pitches are:
c c g b
a a <g d>
f f e e
d d c
We'll talk about some of the other symbols later on.
We have created a version of the song in its current form, and you can listen to it here.
Right now, the compiled piece would look like this:
You can also see and play the file on LilyBin.
This pull request introduces a file called twinkle-twinkle.ly
. This file is the notation of the melody from "Twinkle Twinkle Little Star". But, a few things are wrong. You'll notice that a note is wrong, and a rhythm is wrong - we'll fix the rhythm later. First, correct the note so it matches the traditional melody.
- [Edit the
twinkle-twinkle.ly
file on this branch]({{ editUrl }}) - Identify and correct the note in the pattern
- Save and commit your changes to this branch
I'll respond when I detect a new commit on this branch.
I wasn't able to find that you added the proper note!
I'm specifically looking for the following line:
c8\mf c g' g
I'll respond when I detect a new commit on this branch.
We have created a version of the song in its current form, and you can listen to it here.
Right now, the compiled piece would look like this:
You can also see and play the file on LilyBin.
In LilyPond, rhythm is dictated through symbols. As stated in LilyPond's documentation,
Durations are designated by numbers and dots, and entered as their reciprocal values. For example, a quarter note is entered using a 4 (since it is a 1/4 note), and a half note is entered using a 2 (since it is a 1/2 note). For notes longer than a whole you must use the \longa (a double breve) and \breve commands. Durations as short as 128th notes may be specified. Shorter values are possible, but only as beamed notes.
The duration of each note is defined with a number in the same block with the pitches. For twinkle twinkle little star, the long version would look like:
{
c8\mf c8 g'8 b8
a8 a8 <g d>4
f4 f4 e4 e4
d4 d4 c2
}
If a pitch doesn't have a specific number (duration), it assumes the duration of the pitch before it. You may notice that there isn't a number after every letter (pitch)! In our example, we see:
{
c8\mf c g' b
a a <g d>4
f4 f e e
d d c2
}
If you sing, play, or read this music as it currently is, you will notice that the harmonic rhythm changes in the second bar (the song slows down to half speed). Edit the rhythm to continue the notation pattern from the first measure.
- [Edit the
twinkle-twinkle.ly
file on this branch]({{ editUrl }}) - Identify and correct the rhythm in the pattern
- Save and commit your changes to this branch
I'll respond when I detect a new commit on this branch.
I wasn't able to find that you added the proper rhythm!
I'm specifically looking for the following line:
f8 f e e
d d c4
I'll respond when I detect a new commit on this branch.
Great job! So far, you've edited pitches and rhythms.
We have created a version of the song in its current form, and you can listen to it here.
Right now, the compiled piece would look like this:
You can also see and play the file on LilyBin.
Time signatures can be specified before a group of notes by \time
followed by the time signature. (Ex: \time 2/4
).
The main block of notes in our piece currently look like:
\relative c' {
c8\mf c g' b
a a <g d>4
f4 f e e
d d c2
}
If we were to specify 2/4 time, we would add a line before the notes, but within the block, like this:
\relative c' {
\time 2/4
c8\mf c g' b
a a <g d>4
f4 f e e
d d c2
}
See the difference?
Right now, the time signature of this piece is not specified. Let's try out a change and edit it to specify a time signature of 2/4 time. What do you think will happen to the bar lines? 🧐
- [Edit the
twinkle-twinkle.ly
file on this branch]({{ editUrl }}) - Insert a line before the pitches start to declare a 2/4 time signature
- Save and commit your changes to this branch
I'll respond when I detect a new commit on this branch.
I wasn't able to find that you added the proper time signature!
I'm specifically looking for the following line:
... {
\time 2/4
...
}
Note: the ellipses (...
) are just placeholders for areas that this section doesn't focus on. Do not copy and paste the ellipses into your code.
I'll respond when I detect a new commit on this branch.
Nice job with the time signature! What do you notice about the barlines?
We have created a version of the song in its current form, and you can listen to it here.
Right now, the compiled piece would look like this:
You can also see and play the file on LilyBin.
You may have noticed so far that our example has many instances of only one note, but there is an example of a chord.
Single notes are notated by letters (or letters combined with numbers or other symbols) that are surrounded by spaces, like:
c8\mf c g' b
Below, you can see that the notes G
and D
are grouped together by the bracket symbols, <
and >
:
a a <g d>4
Let's add another chord to the last note of the piece!
- [Edit the
twinkle-twinkle.ly
file on this branch]({{ editUrl }}) - Edit the last note to be a chord with the notes
c
andg
- Save and commit your changes to this branch
I'll respond when I detect a new commit on this branch.
I wasn't able to find that you added the proper chord!
I'm specifically looking for the following line:
d d <c g>4
I'll respond when I detect a new commit on this branch.
Nice work! We have created a version of the song in its current form, and you can listen to it here.
Right now, the compiled piece would look like this:
You can also see and play the file on LilyBin.
Like with the time signature, the key signature is notated with /key
followed by the signature, like \key c \minor
. In a file, this would look like:
\relative c' {
\time 4/4
\key c \minor
c8\mf c g' b
a a <g d>4
f4 f e e
d d c2
}
Let's add some drama and change the key to c minor
.
- [Edit the
twinkle-twinkle.ly
file on this branch]({{ editUrl }}) - Add a line after the time signature to specify c minor as the key for this song
- Save and commit your changes to this branch
I'll respond when I detect a new commit on this branch.
I wasn't able to find that you added the proper key signature!
I'm specifically looking for the following line:
... {
\key c \minor
...
}
Note: the ellipses (...
) are just placeholders for areas that this section doesn't focus on. Do not copy and paste the ellipses into your code.
I'll respond when I detect a new commit on this branch.
We have created a version of the song in its current form, and you can listen to it here.
Right now, the compiled piece would look like this:
You can also see and play the file on LilyBin.
If you chose to visualize the changes as music notation after you changed the key signature, you may have noticed that the notes affected were automatically notated as naturals.
To change how these notes are visualized, we will add the notation for flats by the notes that we want to actually be flat.
Flats are notated with es
after a note, like ces
for c♭.
Sharps are notated with is
after a note, like cis
for c♯.
Naturals (♮) are always assumed.
Let's make the second a
in the piece a flat.
- [Edit the
twinkle-twinkle.ly
file on this branch]({{ editUrl }}) - Edit the second occurrence of the pitch
a
to be a flat - Save and commit your changes to this branch
I'll respond when I detect a new commit on this branch.
I wasn't able to find that you added the accidentals!
I'm specifically looking for the following line:
a aes <g d>4
I'll respond when I detect a new commit on this branch.
We have created a version of the song in its current form, and you can listen to it here.
Right now, the compiled piece would look like this:
You can also see and play the file on LilyBin.
As you may have noticed, musical notation is typically associated with the pitch. Dynamics are included directly after a pitch. You can see this already in our song.
c8\mf c g' b
As seen on LilyPond's documentation, the available dynamic marks are \ppppp
, \pppp
, \ppp
, \pp
, \p
, \mp
, \mf
, \f
, \ff
, \fff
, \ffff
, \fffff
, \fp
, \sf
, \sff
, \sp
, \spp
, \sfz
, and \rfz
.
- [Edit the
twinkle-twinkle.ly
file on this branch]({{ editUrl }}) - Add a dynamic marking of piano,
\p
, on the firstf
note - Save and commit your changes to this branch
I'll respond when I detect a new commit on this branch.
I wasn't able to find that you added the accidentals!
I'm specifically looking for the following line:
f8\p f e e
I'll respond when I detect a new commit on this branch.
We have created a version of the song in its current form, and you can listen to it here.
Right now, the compiled piece would look like this:
You can also see and play the file on LilyBin.
You've done it! Go ahead and please approve, then merge this pull request.
- Approve this pull request
- Merge this pull request
- Delete the branch
twinkle-twinkle
I'll respond when you merge this pull request.
In this pull request, you'll find the start of a new song. What music will you write next?
Good job, @{{ user.username }}! You're done! We opened [a pull request]({{ prLink }}) with your final notes.
In this course, you learned how to notate music with LilyPond. You learned how to:
- Set pitches:
c c g g
- Change rhythm:
c8 g4
- Set time signatures:
\time 2/4
- Create chords:
<g d>
- Set key signatures:
\key c \minor
- Add accidentals:
a aes
- Insert dynamic markings
c\mf
- You can learn more about LilyPond at http://lilypond.org/
- For a more thorough introduction, look at the Learning Manual.
- For over 2000 free scores in LilyPond format, check out Mutopia.
- Play with LilyPad live on LilyBin.