2.2.1 Accidentals and key signatures


Music Glossary: sharp, flat, double sharp, double flat, accidental.

A sharp pitch is made by adding is to the name, and a flat pitch by adding es. As you might expect, a double sharp or double flat is made by adding isis or eses. This syntax is derived from note naming conventions in Nordic and Germanic languages, like German and Dutch. To use other names for accidentals, see Note names in other languages.

cis1 ees fisis, aeses

[image of music]

Key signatures

Music Glossary: key signature, major, minor.

The key signature is set with the command \key followed by a pitch and \major or \minor.

\key d \major
\key c \minor

[image of music]

Warning: key signatures and pitches

Music Glossary: accidental, key signature, pitch, flat, natural, sharp, transposition.

To determine whether to print an accidental, LilyPond examines the pitches and the key signature. The key signature only affects the printed accidentals, not the note’s pitch! This is a feature that often causes confusion to newcomers, so let us explain it in more detail.

LilyPond makes a sharp distinction between musical content and layout. The alteration (flat, natural sign or sharp) of a note is part of the pitch, and is therefore musical content. Whether an accidental (a printed flat, natural or sharp sign) is printed in front of the corresponding note is a question of layout. Layout is something that follows rules, so accidentals are printed automatically according to those rules. The pitches in your music are works of art, so they will not be added automatically, and you must enter what you want to hear.

In this example:

\key d \major
d cis fis

[image of music]

No note has a printed accidental, but you must still add is and type cis and fis in the input file.

The code b does not mean “print a black dot just on the middle line of the staff.” Rather, it means “there is a note with pitch B-natural.” In the key of A-flat major, it does get an accidental:

\key aes \major

[image of music]

Adding all alterations explicitly might require a little more effort when typing, but the advantage is that transposing is easier, and accidentals can be printed according to different conventions. For some examples how accidentals can be printed according to different rules, see Automatic accidentals.

See also

Notation Reference: Note names in other languages, Accidentals, Automatic accidentals, Key signature.

Music Glossary: Pitch names.

Other languages: français, español, deutsch.

Learning Manual