Node:Using the predefined accidental variables, Next:, Up:Accidentals



Using the predefined accidental variables

The constructs for describing the accidental typesetting rules are quite hairy, so non-experts should stick to the variables defined in ly/property-init.ly.

The variables set properties in the "Current" context (see Context properties). This means that the variables should normally be added right after the creation of the context in which the accidental typesetting described by the variable is to take effect. For example, if you want to use piano-accidentals in a piano staff then issue \pianoAccidentals first thing after the creation of the piano staff:

     \score {
         \notes \relative c'' <<
             \new Staff { cis4 d e2 }
             \context GrandStaff <<
                 \pianoAccidentals
                 \new Staff { cis4 d e2 }
                 \new Staff { es2 c }
             >>
             \new Staff { es2 c }
         >>
     }
     

[picture of music]

The variables are:

\defaultAccidentals
This is the default typesetting behaviour. It should correspond to 18th century common practice: Accidentals are remembered to the end of the measure in which they occur and only on their own octave.
\voiceAccidentals
The normal behaviour is to remember the accidentals on Staff-level. This variable, however, typesets accidentals individually for each voice. Apart from that the rule is similar to \defaultAccidentals.

This leads to some weird and often unwanted results because accidentals from one voice do not get cancelled in other voices:

              \context Staff <<
                  \voiceAccidentals
                  <<
                   { es g } \\
                   { c, e }
               >> >>
          

[picture of music]

Hence you should only use \voiceAccidentals 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) then you use \modernVoiceAccidentals or \modernVoiceCautionaries instead.
\modernAccidentals
This rule corresponds to the common practice in the 20th century. The rule is more complex than \defaultAccidentals. You get all the same accidentals, but temporary accidentals also get cancelled in other octaves. Furthermore, in the same octave, they also get cancelled in the following measure:
                \modernAccidentals
                cis' c'' cis'2 | c'' c'
          

[picture of music]


\modernCautionaries
This rule is similar to \modernAccidentals, but the "extra" accidentals (the ones not typeset by \defaultAccidentals) are typeset as cautionary accidentals. They are printed in reduced size or with parentheses:
                \modernCautionaries
                cis' c'' cis'2 | c'' c'
          

[picture of music]


\modernVoiceAccidentals
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 cancelled across voices in the same Staff.
\modernVoiceCautionaries
is the same as \modernVoiceAccidentals, but with the extra accidentals (the ones not typeset by \voiceAccidentals) typeset as cautionaries. Even though all accidentals typeset by \defaultAccidentals are typeset by this variable then some of them are typeset as cautionaries.
\pianoAccidentals
20th century practice for piano notation. Very similar to \modernAccidentals but accidentals also get cancelled across the staves in the same GrandStaff or PianoStaff.
\pianoCautionaries
As \pianoAccidentals but with the extra accidentals typeset as cautionaries.
\noResetKey
Same as \defaultAccidentals but with accidentals lasting "forever" and not only until the next measure:
                \noResetKey
                c1 cis cis c
          

[picture of music]


\forgetAccidentals
This is sort of the opposite of \noResetKey: 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:
                \forgetAccidentals
                \key d\major c4 c cis cis d d dis dis
          

[picture of music]


This page is for LilyPond-2.0.0 (stable-branch).

Report errors to <bug-lilypond@gnu.org>.