Next: , Previous: Instrument transpositions, Up: Displaying pitches


Automatic accidentals

There are many different conventions on how to typeset accidentals. LilyPond provides a function to specify which accidental style to use. This function is called as follows:

\new Staff <<
  #(set-accidental-style 'voice)
  { ... }
>>

The accidental style applies to the current Staff by default (with the exception of the styles piano and piano-cautionary, which are explained below). Optionally, the function can take a second argument that determines in which scope the style should be changed. For example, to use the same style in all staves of the current StaffGroup, use:

#(set-accidental-style 'voice 'StaffGroup)

The following accidental styles are supported. To demonstrate each style, we use the following example:

     
     musicA = {
       <<
         \relative c' {
           cis'8 fis, d'4 <a cis>8 f bis4 |
           cis2. <c, g'>4 |
         }
         \\
         \relative c' {
           ais'2 cis, |
           fis8 b a4 cis2 |
         }
       >>
     }
     
     musicB = {
       \clef bass
       \new Voice {
         \voiceTwo \relative c' {
           <fis, a cis>4
           \change Staff = up
           cis'
           \change Staff = down
           <fis, a>
           \change Staff = up
           dis' |
           \change Staff = down
           <fis, a cis>4 gis <f a d>2 |
         }
       }
     }
     
     \new PianoStaff {
       <<
         \context Staff = "up" {
           #(set-accidental-style 'default)
           \musicA
         }
         \context Staff = "down" {
           #(set-accidental-style 'default)
           \musicB
         }
       >>
     }

[image of music]

Note that the last lines of this example can be replaced by the following, as long as the same accidental style should be used in both staves.

\new PianoStaff {
  <<
    \context Staff = "up" {
      %%% change the next line as desired:
      #(set-accidental-style 'default 'Score)
      \musicA
    }
    \context Staff = "down" {
      \musicB
    }
  >>
}
default

This is the default typesetting behavior. It corresponds to eighteenth-century common practice: accidentals are remembered to the end of the measure in which they occur and only in their own octave. Thus, in the example below, no natural signs are printed before the b in the second measure or the last c:

[image of music]


voice

The normal behavior is to remember the accidentals at Staff-level. In this style, however, accidentals are typeset individually for each voice. Apart from that, the rule is similar to default.

As a result, accidentals from one voice do not get canceled in other voices, which is often an unwanted result: in the following example, it is hard to determine whether the second a should be played natural or sharp. The voice option should therefore be used only if the voices are to be read solely by individual musicians. If the staff is to be used by one musician (e.g., a conductor or in a piano score) then modern or modern-cautionary should be used instead.

[image of music]


modern

This rule corresponds to the common practice in the twentieth century. It prints the same accidentals as default, with two exceptions that serve to avoid ambiguity: after temporary accidentals, cancellation marks are printed also in the following measure (for notes in the same octave) and, in the same measure, for notes in other octaves. Hence the naturals before the b and the c in the second measure of the upper staff:

[image of music]


modern-cautionary

This rule is similar to modern, but the ‘extra’ accidentals (the ones not typeset by default) are typeset as cautionary accidentals. They are by default printed with parentheses, but they can also be printed in reduced size by defining the cautionary-style property of AccidentalSuggestion.

[image of music]


modern-voice

This rule is used for multivoice accidentals to be read both by musicians playing one voice and musicians playing all voices. Accidentals are typeset for each voice, but they are canceled across voices in the same Staff. Hence, the a in the last measure is canceled because the previous cancellation was in a different voice, and the d in the lower staff is canceled because of the accidental in a different voice in the previous measure:

[image of music]


modern-voice-cautionary
This rule is the same as modern-voice, but with the extra accidentals (the ones not typeset by voice) typeset as cautionaries. Even though all accidentals typeset by default are typeset with this rule, some of them are typeset as cautionaries.

[image of music]


piano

This rule reflects twentieth-century practice for piano notation. Its behavior is very similar to modern style, but here accidentals also get canceled across the staves in the same GrandStaff or PianoStaff, hence all the cancellations of the final notes.

This accidental style applies to the current GrandStaff or PianoStaff by default.

[image of music]


piano-cautionary
This is the same as piano but with the extra accidentals typeset as cautionaries.

[image of music]


neo-modern
This rule reproduces a common practice in contemporary music: accidentals are printed like with modern, but they are printed again if the same note appears later in the same measure – except if the note is immediately repeated.

[image of music]


neo-modern-cautionary
This rule is similar to neo-modern, but the extra accidentals are printed as cautionary accidentals.

[image of music]


dodecaphonic
This rule reflects a practice introduced by composers at the beginning of the 20th century, in an attempt to abolish the hierarchy between natural and non-natural notes. With this style, every note gets an accidental sign, including natural signs.

[image of music]


no-reset
This is the same as default but with accidentals lasting ‘forever’ and not only within the same measure:

[image of music]


forget
This is the opposite of no-reset: Accidentals are not remembered at all – and hence all accidentals are typeset relative to the key signature, regardless of what came before in the music. Unlike dodecaphonic, this rule never prints any naturals.

[image of music]

Selected Snippets

Dodecaphonic-style accidentals for each note including naturals

In early 20th century works, starting with Schoenberg, Berg and Webern (the "Second" Viennese school), every pitch in the twelve-tone scale has to be regarded as equal, without any hierarchy such as the classical (tonal) degrees. Therefore, these composers print one accidental for each note, even at natural pitches, to emphasize their new approach to music theory and language.

This snippet shows how to achieve such notation rules.

     
     webernAccidentals = {
       % the 5s are just "a value different from any accidental"
       \set Staff.keySignature = #'((0 . 5) (1 . 5) (2 . 5) (3 . 5)
                                    (4 . 5) (5 . 5) (6 . 5))
       \set Staff.extraNatural = ##f
       #(set-accidental-style 'forget)
     }
     
     \score {
       {
         \webernAccidentals
         c'4 dis' cis' cis'
         c'4 dis' cis' cis'
         c'4 c' dis' des'
       }
       \layout {
         \context {
         \Staff
         \remove "Key_engraver"
         }
       }
     }

[image of music]

See also

Snippets: Pitches.

Internals Reference: Accidental, Accidental_engraver, GrandStaff and PianoStaff, Staff, AccidentalSuggestion, AccidentalPlacement, accidental-suggestion-interface.

Known issues and warnings

Simultaneous notes are considered to be entered in sequential mode. This means that in a chord the accidentals are typeset as if the notes in the chord happen one at a time, in the order in which they appear in the input file. This is a problem when accidentals in a chord depend on each other, which does not happen for the default accidental style. The problem can be solved by manually inserting ! and ? for the problematic notes.

Diese Seite ist für LilyPond-2.11.58 (Entwicklungszweig).

Fehler bitte an http://post.gmane.org/post.php?group=gmane.comp.gnu.lilypond.bugs melden.

Ihre Vorschläge für die Dokumentation sind willkommen.

Andere Sprachen: français, español.