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


1.1.3.5 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" {
           %%% change the next line as desired:
           #(set-accidental-style 'default)
           \musicA
         }
         \context Staff = "down" {
           %%% change the next line as desired:
           #(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 on 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 on 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
Same as #(set-accidental-style 'piano) but with the extra accidentals typeset as cautionaries.

[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 was before in the music:

[image of music]

Selected Snippets

In early XXth century works, starting with Schönberg, 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 with LilyPond.

     
     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)
     }
     
     \layout {
       \context { \Staff \remove Key_engraver }
     }
     \score {
       {
         \webernAccidentals
         c' dis' cis' cis'
         c' dis' cis' cis'
         c' c' dis' des'
       }
     }

[image of music]

See also

Snippets: Pitches .

Internals Reference: Accidental_engraver, Accidental, AccidentalSuggestion, AccidentalPlacement, GrandStaff and PianoStaff, Staff.

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.


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

Diese Seite ist für LilyPond-2.11.40 (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.