Grace notes

Grace notes are musical ornaments, printed in a smaller font, that take up no additional logical time in a measure.

\relative {
  c''4 \grace b16 a4(
  \grace { b16 c16 } a2)
}

[image of music]

There are three other types of grace notes possible; the acciaccatura – an unmeasured grace note indicated by a slurred note with a slashed stem – and the appoggiatura, which takes a fixed fraction of the main note it is attached to and prints without the slash. It is also possible to write a grace note with a slashed stem, like the acciaccatura but without the slur, so as to place it between notes that are slurred themselves, using the \slashedGrace function.

\relative {
  \acciaccatura d''8 c4
  \appoggiatura e8 d4
  \acciaccatura { g16 f } e2
  \slashedGrace a,8 g4
  \slashedGrace b16 a4(
  \slashedGrace b8 a2)
}

[image of music]

The placement of grace notes is synchronized between different staves. In the following example, there are two sixteenth grace notes for every eighth grace note

<<
  \new Staff \relative { e''2 \grace { c16 d e f } e2 }
  \new Staff \relative { c''2 \grace { g8 b } c2 }
>>

[image of music]

If you want to end a note with a grace, use the \afterGrace command. It takes two arguments: the main note, and the grace notes following the main note.

\relative { c''1 \afterGrace d1 { c16[ d] } c1 }

[image of music]

This will place the grace notes after the start of the main note. The point of time where the grace notes are placed is a given fraction of the main note’s duration. The default setting of

afterGraceFraction = 3/4

may be redefined at top level. Individual \afterGrace commands may have the fraction specified right after the command itself instead.

The following example shows the results from setting with the default space, setting it at 15/16, and finally at 1/2 of the main note.

<<
  \new Staff \relative {
    c''1 \afterGrace d1 { c16[ d] } c1
  }
  \new Staff \relative {
    c''1 \afterGrace 15/16 d1 { c16[ d] } c1
  }
  \new Staff \relative {
    c''1 \afterGrace 1/2 d1 { c16[ d] } c1
  }
>>

[image of music]

The effect of \afterGrace can also be achieved using spacers. The following example places the grace note after a space lasting 7/8 of the main note.

\new Voice \relative {
  <<
    { d''1^\trill_( }
    { s2 s4. \grace { c16 d } }
  >>
  c1)
}

[image of music]

A \grace music expression will introduce special typesetting settings, for example, to produce smaller type, and set directions. Hence, when introducing layout tweaks to override the special settings, they should be placed inside the grace expression. The overrides should also be reverted inside the grace expression. Here, the grace note’s default stem direction is overridden and then reverted.

\new Voice \relative {
  \acciaccatura {
    \stemDown
    f''16->
    \stemNeutral
  }
  g4 e c2
}

[image of music]

Selected Snippets

Using grace note slashes with normal heads

The slash through the stem found in acciaccaturas can be applied in other situations.

\relative c'' {
  \override Flag.stroke-style = "grace"
  c8( d2) e8( f4)
}

[image of music]

Tweaking grace layout within music

The layout of grace expressions can be changed throughout the music using the functions add-grace-property and remove-grace-property.

The following example undefines the Stem direction for this grace, so that stems do not always point up, and changes the default note heads to crosses.

\relative c'' {
  \new Staff {
    $(remove-grace-property 'Voice 'Stem 'direction)
    $(add-grace-property 'Voice 'NoteHead 'style 'cross)
    \new Voice {
       \acciaccatura { f16 } g4
       \grace { d16 e } f4
       \appoggiatura { f,32 g a } e2
    }
  }
}

[image of music]

Redefining grace note global defaults

The global defaults for grace notes are stored in the following identifiers.

startGraceMusic
stopGraceMusic
startAcciaccaturaMusic
stopAcciaccaturaMusic
startAppoggiaturaMusic
stopAppoggiaturaMusic

They are defined in file ly/grace-init.ly. By redefining them other effects may be obtained.

startAcciaccaturaMusic = {
  <>(
  \override Flag.stroke-style = "grace"
  \slurDashed
}

stopAcciaccaturaMusic = {
  \revert Flag.stroke-style
  \slurSolid
  <>)
}

\relative c'' {
  \acciaccatura d8 c1
}

[image of music]

Positioning grace notes with floating space

Setting the property 'strict-grace-spacing makes the musical columns for grace notes ’floating’, i.e., decoupled from the non-grace notes: first the normal notes are spaced, then the (musical columns of the) graces are put left of the musical columns for the main notes.

\relative c'' {
  <<
    \override Score.SpacingSpanner.strict-grace-spacing = ##t
    \new Staff \new Voice {
      \afterGrace c4 { c16[ c8 c16] }
      c8[ \grace { b16 d } c8]
      c4 r
    }
    \new Staff {
      c16 c c c c c c c c4 r
    }
  >>
}

[image of music]

See also

Music Glossary: grace notes, acciaccatura, appoggiatura.

Notation Reference: Scaling durations, Manual beams.

Installed Files: ly/grace-init.ly.

Snippets: Rhythms.

Internals Reference: GraceMusic, Grace_beam_engraver, Grace_auto_beam_engraver, Grace_engraver, Grace_spacing_engraver.

Known issues and warnings

A multi-note beamed acciaccatura is printed without a slash, and looks exactly the same as a multi-note beamed appoggiatura.

Grace note synchronization can also lead to surprises. Staff notation, such as key signatures, bar lines, etc., are also synchronized. Take care when you mix staves with grace notes and staves without, for example,

<<
  \new Staff \relative { e''4 \section \grace c16 d2. }
  \new Staff \relative { c''4 \section d2. }
>>

[image of music]

This can be remedied by inserting grace skips of the corresponding durations in the other staves. For the above example

<<
  \new Staff \relative { e''4 \section \grace c16 d2. }
  \new Staff \relative { c''4 \section \grace s16 d2. }
>>

[image of music]

Please make sure that you use the \grace command for the spacer part, even if the visual part uses \acciaccatura or \appoggiatura because otherwise an ugly slur fragment will be printed, connecting the invisible grace note with the following note.

Grace sections should only be used within sequential music expressions. Nesting or juxtaposing grace sections is not supported, and might produce crashes or other errors.

Each grace note in MIDI output has a length of 1/4 of its actual duration. If the combined length of the grace notes is greater than the length of the preceding note a “Going back in MIDI time” error will be generated. Either make the grace notes shorter in duration, for example:

c'8 \acciaccatura { c'8[ d' e' f' g'] }

becomes:

c'8 \acciaccatura { c'16[ d' e' f' g'] }

Or explicitly change the musical duration:

c'8 \acciaccatura { \scaleDurations 1/2 { c'8[ d' e' f' g'] } }

See Scaling durations.


LilyPond Notation Reference v2.25.22 (development-branch).