3.4.3 Absolute note names

So far we have 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'’ always means middle C, a ‘b’ always means the note one step below middle C, and a ‘g,’ always means the note on the bottom line of a staff with a bass clef.

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

[image of music]

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 with large intervals, and is extremely useful for computer-generated LilyPond files. When cutting and pasting melody fragments, absolute mode preserves the original octave.

See Relative octave entry for more complex situations.


LilyPond 学习手册 v2.25.21 (开发分支).