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]

All these quotes makes the input less readable and they are a source of errors. With \relative, the previous example is much easier to read and type:

\relative c'' {
  \key a \major
  \time 6/8
  cis8. 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 { c'4 \relative c'' { f g } c }

[image of music]

If you are using absolute music inside of relative, you’ll need to mark the absolute music explicitly with \absolute to stop it from becoming part of the relative music:

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

[image of music]


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

LilyPond — Learning Manual v2.18.2 (stable-branch).