1.2.1 Simple notation

LilyPond will add some notation elements automatically. In the next example, we have only specified four pitches, but LilyPond has added a clef, time signature, and rhythms.

{
  c' e' g' e'
}

[image of music]

This behavior may be altered, but in most cases these automatic values are useful.


Pitches

Music Glossary: pitch, interval, scale, middle C, octave, accidental.

The easiest way to enter notes is by using \relative mode. In this mode, the octave is chosen automatically by assuming the following note is always to be placed closest to the previous note, i.e., it is to be placed in the octave which is within three staff spaces of the previous note. We begin by entering the most elementary piece of music, a scale, in which every note is within just one staff space of the previous note.

% set the starting point to middle C
\relative c' {
  c d e f
  g a b c
}

[image of music]

The initial note is middle C. Each successive note is placed closest to the previous note – in other words, the first c is the closest C to middle C. This is followed by the closest D to the previous note. We can create melodies which have larger intervals, still using only \relative mode:

\relative c' {
  d f a g
  c b f d
}

[image of music]

It is not necessary for the first note of the melody to start on the note which specifies the starting pitch. In the previous example, the first note – the d – is the closest D to middle C.

By adding (or removing) quotes ' or commas , from the ‘\relative c'’ command, we can change the starting octave:

% one octave above middle C
\relative c'' {
  e c a c
}

[image of music]

Relative mode can be confusing initially, but is the easiest way to enter most melodies. Let us see how this relative calculation works in practice. Starting from a B, which is on the middle line in a treble clef, you can reach a C, D and E within 3 staff spaces going up, and an A, G and F within 3 staff spaces going down. So if the note following a B is a C, D or E it will be assumed to be above the B, and an A, G or F will be assumed to be below.

\relative c'' {
  b c  % c is 1 staff space up, so is the c above
  b d  % d is 2 up or 5 down, so is the d above
  b e  % e is 3 up or 4 down, so is the e above
  b a  % a is 6 up or 1 down, so is the a below
  b g  % g is 5 up or 2 down, so is the g below
  b f  % f is 4 up or 3 down, so is the f below
}

[image of music]

Exactly the same happens even when any of these notes are sharpened or flattened. Accidentals are totally ignored in the calculation of relative position. Precisely the same staff space counting is done from a note at any other position on the staff.

To add intervals that are larger than three staff spaces, we can raise the octave by adding a single quote ' (or apostrophe) to the note name. We can lower the octave by adding a comma , to the note name.

\relative c'' {
  a a, c' f,
  g g'' a,, f'
}

[image of music]

To change a note by two (or more!) octaves, we use multiple '' or ,, – but be careful that you use two single quotes '' and not one double quote " !


Durations (rhythms)

Music Glossary: beam, duration, whole note, half note, quarter note, dotted note.

The duration of a note is specified by a number after the note name: 1 for a whole note, 2 for a half note, 4 for a quarter note and so on. Beams are added automatically.

If you do not specify a duration, the previous duration is used for the next note. The duration of the first note defaults to a quarter note.

\relative c'' {
  a1
  a2 a4 a8 a
  a16 a a a a32 a a a a64 a a a a a a a a2
}

[image of music]

To create dotted notes, add a dot . to the duration number. The duration of a dotted note must be stated explicitly (i.e., with a number).

\relative c'' {
  a4 a a4. a8
  a8. a16 a a8. a8 a4.
}

[image of music]


Rests

Music Glossary: rest.

A rest is entered just like a note with the name r :

\relative c'' {
  a4 r r2
  r8 a r4 r4. r8
}

[image of music]


Time signature

Music Glossary: time signature.

The time signature can be set with the \time command:

\relative c'' {
  \time 3/4
  a4 a a
  \time 6/8
  a4. a
  \time 4/4
  a4 a a a
}

[image of music]


Tempo marks

Music Glossary: tempo indication, metronome.

The tempo indication and metronome mark can be set with the \tempo command:

\relative c'' {
  \time 3/4
  \tempo "Andante"
  a4 a a
  \time 6/8
  \tempo 4. = 96
  a4. a
  \time 4/4
  \tempo  "Presto" 4 = 120
  a4 a a a
}

[image of music]


Clef

Music Glossary: clef.

The clef can be set using the \clef command:

\relative c' {
  \clef "treble"
  c1
  \clef "alto"
  c1
  \clef "tenor"
  c1
  \clef "bass"
  c1
}

[image of music]


All together

Here is a small example showing all these elements together:

\relative c, {
  \clef "bass"
  \time 3/4
  \tempo "Andante" 4 = 120
  c2 e8 c'
  g'2.
  f4 e d
  c4 c, r
}

[image of music]

See also

Notation Reference: Writing pitches, Writing rhythms, Writing rests, Time signature, Clef.


Other languages: česky, deutsch, español, français, magyar, italiano, 日本語, nederlands.
About automatic language selection.

LilyPond — Learning Manual v2.19.14 (development-branch).