Using a different rest stencil globally (e.g., printing rests as circles)

Sometimes, an author may want to display rests not with their usual symbols, but e.g. use a circle instead of a quarter rest and a circle with a rectangle below for eighth rests.

This snippet provides a Scheme function for the Rest's #'stencil property, which creates circles instead of the usual rest symbols for quarter and eighth rests, but uses the standard symbols for all other rests. This is done by checking the duration-log property of the rest object and provide a custom stencil for log values of 2 and 3 (because 1/4 = 2-2 and 1/8 = 2-3). For all other values, the built-in rest formatter function is called.

To enable this style only for some parts of a score, don't set the stencil globally, but call the \override somewhere inside the score and \revert it after the section with the custom style:

\relative c' {
  e4. r8 e4 r4
  \override Rest #'stencil = #ly:rest-interface::dot-rests
  e4. r8 e4 r4
  \revert Rest #'stencil
  e4. r8 e4 r4
}

To enable this style globally, simply override the #'stencil property of the Rest object in a layout block:

\layout {
  \context {
    \Voice
    \override Rest #'stencil = #ly:rest-interface::dot-rests
  }
}