Marking notes of spoken parts with a cross on the stem (Sprechstimme)

This example shows how to put crosses on stems. Mark the beginning of a spoken section with the \speakOn keyword, and end it with the \speakOff keyword.

speakOn = {
  \override Stem.stencil =
    #(lambda (grob)
       (let* ((x-parent (ly:grob-parent grob X))
              (is-rest? (ly:grob? (ly:grob-object x-parent 'rest))))
         (if is-rest?
              (ly:stem::print grob)
              (- (ly:grob-property grob 'direction))
              (grob-interpret-markup grob
                                     (markup #:center-align #:fontsize -4
                                             #:musicglyph "noteheads.s2cross"))

speakOff = {
  \revert Stem.stencil
  \revert Flag.stencil

\score {
  \new Staff {
    \relative c'' {
      a4 b a c
      g4 f r g
      b4 r d e
      c4 a g f

[image of music]

LilyPond snippets v2.25.17 (development-branch).