[ << Musical notation ] | [Top][Contents][Index] | [ Specialist notation >> ] |
[ < Instrument transpositions ] | [ Up : Displaying pitches ] | [ Alternate accidental glyphs > ] |
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 << \accidentalStyle voice { … } >>
The accidental style normally applies to the current
Staff
(with the exception of the styles choral
,
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:
\accidentalStyle StaffGroup.voice
The following accidental styles are supported. To demonstrate each style, we use the following example:
musicA = { << \relative { cis''8 fis, bes4 <a cis>8 f bis4 | cis2. <c, g'>4 | } \\ \relative { ais'2 cis, | fis8 b a4 cis2 | } >> } musicB = { \clef bass \new Voice { \voiceTwo \relative { <fis a cis>8[ <fis a cis> \change Staff = up cis' cis \change Staff = down <fis, a> <fis a>] \showStaffSwitch \change Staff = up dis'4 | \change Staff = down <fis, a cis>4 gis <f a d>2 | } } } \new PianoStaff { << \new Staff = "up" { \accidentalStyle default \musicA } \new Staff = "down" { \accidentalStyle default \musicB } >> }
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 { << \new Staff = "up" { %%% change the next line as desired: \accidentalStyle Score.default \musicA } \new 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 lastc
: 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 todefault
.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. Thevoice
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) thenmodern
ormodern-cautionary
should be used instead. modern
-
This rule corresponds to the common practice in the twentieth century. It omits some extra natural signs, which were traditionally prefixed to a sharp following a double sharp, or a flat following a double flat. The
modern
rule prints the same accidentals asdefault
, with two additions 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 theb
and thec
in the second measure of the upper staff: modern-cautionary
-
This rule is similar to
modern
, but the ‘extra’ accidentals are printed as cautionary accidentals (with parentheses). They can also be printed at a different size by overridingAccidentalCautionary
’sfont-size
property. modern-voice
-
This rule is used for multi-voice 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, thea
in the last measure is canceled because the previous cancellation was in a different voice, and thed
in the lower staff is canceled because of the accidental in a different voice in the previous measure: modern-voice-cautionary
-
This rule is the same as
modern-voice
, but with the extra accidentals (the ones not typeset byvoice
) typeset as cautionaries. Even though all accidentals typeset bydefault
are typeset with this rule, some of them are typeset as cautionaries. 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 sameGrandStaff
orPianoStaff
, hence all the cancellations of the final notes.This accidental style applies to the current
GrandStaff
orPianoStaff
unless qualified with a second argument. piano-cautionary
-
This is the same as
piano
but with the extra accidentals typeset as cautionaries. choral
-
This rule is a combination of the
modern-voice
and thepiano
style. It shows all accidentals required for singers that only follow their own voice, as well as additional accidentals for readers that follow all voices of an entireChoirStaff
simultaneously.This accidental style applies to the current
ChoirStaff
unless qualified with a second argument. choral-cautionary
-
This is the same as
choral
but with the extra accidentals typeset as cautionaries. 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. neo-modern-cautionary
-
This rule is similar to
neo-modern
, but the ‘extra’ accidentals are printed as cautionary accidentals (with parentheses). They can also be printed at a different size by overridingAccidentalCautionary
’sfont-size
property. neo-modern-voice
-
This rule is used for multi-voice accidentals to be read both by musicians playing one voice and musicians playing all voices. Accidentals are typeset for each voice as with
neo-modern
, but they are canceled across voices in the sameStaff
. neo-modern-voice-cautionary
-
This rule is similar to
neo-modern-voice
, but the extra accidentals are printed as cautionary accidentals. 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.
dodecaphonic-no-repeat
-
Like with the dodecaphonic accidental style every note gets an accidental sign by default, but accidentals are suppressed for pitches immediately repeated within the same staff.
dodecaphonic-first
-
Similar to the dodecaphonic accidental style every pitch gets an accidental sign, but only the first time it is encountered in a measure. Accidentals are only remembered for the actual octave but throughout voices.
teaching
-
This rule is intended for students, and makes it easy to create scale sheets with automatically created cautionary accidentals. Accidentals are printed like with
modern
, but cautionary accidentals are added for all sharp or flat tones specified by the key signature, except if the note is immediately repeated. no-reset
-
This is the same as
default
but with accidentals lasting ‘forever’ and not only within the same measure: 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.
See also
Snippets: Pitches.
Internals Reference: Accidental, Accidental_engraver, GrandStaff, PianoStaff, Staff, AccidentalSuggestion, AccidentalPlacement, accidental-suggestion-interface.
Known issues and warnings
Simultaneous notes are not considered in the automatic
determination of accidentals; only previous notes and the key
signature are taken into account. Forcing accidentals with ‘!’
or ‘?’ may be required when the same note name occurs
simultaneously with different alterations, as in <f! fis!>
.
\relative c' << { fis8 g } \\ { f! f } >>
A more sophisticated solution is given in LSR snippet 1172.
In alternative endings, cautionary cancellation should be based on
the previous played measure, but it is based on the
previous printed measure. In the following example, the
natural c
in the second alternative does not need a natural
sign:
The following workaround can be used: define a function that locally changes
the accidental style to forget
:
forget = #(define-music-function (music) (ly:music?) #{ \accidentalStyle forget #music \accidentalStyle modern #}) { \accidentalStyle modern \time 2/4 \repeat volta 2 { c'2 } \alternative { \volta 1 { cis' } \volta 2 { \forget c' } } }
[ << Musical notation ] | [Top][Contents][Index] | [ Specialist notation >> ] |
[ < Instrument transpositions ] | [ Up : Displaying pitches ] | [ Alternate accidental glyphs > ] |