2.4.3 Absolute note names

So far we have always used \relative to define pitches. This is usually the fastest way to enter most music. Without \relative, pitches are interpreted in absolute mode.

In this mode, LilyPond treats all pitches as absolute values. A c' will always mean middle C, a b will always mean the note one step below middle C, and a g, will always mean the note on the bottom staff of the bass clef.

{
  \clef "bass"
  c'4 b g, g, |
  g,4 f, f c' |
}

[image of music]

Here is a four-octave scale:

{
  \clef "bass"
  c,4 d, e, f, |
  g,4 a, b, c |
  d4 e f g |
  a4 b c' d' |
  \clef "treble"
  e'4 f' g' a' |
  b'4 c'' d'' e'' |
  f''4 g'' a'' b'' |
  c'''1 |
}

[image of music]

As you can see, writing a melody in the treble clef involves a lot of quote ' marks. Consider this fragment from Mozart:

{
  \key a \major
  \time 6/8
  cis''8. d''16 cis''8 e''4 e''8 |
  b'8. cis''16 b'8 d''4 d''8 |
}

[image of music]

Common octave marks can be indicated just once, using the command \fixed followed by a reference pitch:

\fixed c'' {
  \key a \major
  \time 6/8
  cis8. d16 cis8 e4 e8 |
  b,8. cis16 b,8 d4 d8 |
}

[image of music]

With \relative, the previous example needs no octave marks because this melody moves in steps no larger than three staff positions:

\relative {
  \key a \major
  \time 6/8
  cis''8. d16 cis8 e4 e8 |
  b8. cis16 b8 d4 d8 |
}

[image of music]

If you make a mistake with an octave mark (' or ,) while working in \relative mode, it is very obvious – many notes will be in the wrong octave. When working in absolute mode, a single mistake will not be as visible, and will not be as easy to find.

However, absolute mode is useful for music which has large intervals, and is extremely useful for computer-generated LilyPond files. When cutting and pasting melody fragments, absolute mode preserves the original octave.

Sometimes music is arranged in more complex ways. If you are using \relative inside of \relative, the outer and inner relative sections are independent:

\relative { c'4 \relative { f'' g } c }

[image of music]

To use absolute mode inside of \relative, put the absolute music inside \fixed c { … } and the absolute pitches will not affect the octaves of the relative music:

\relative {
  c'4 \fixed c { f'' g'' } c |
  c4 \fixed c'' { f g } c
}

[image of music]


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

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