]> git.donarmstrong.com Git - lilypond.git/blob - input/new/marking-notes-of-spoken-parts-with-a-cross-on-the-stem.ly
bdf0224acfe35bac061b12744c842b9f6046efe1
[lilypond.git] / input / new / marking-notes-of-spoken-parts-with-a-cross-on-the-stem.ly
1 \version "2.12.0"
2
3 \header {
4   lsrtags = "editorial-annotations, vocal-music"
5
6   texidoc = "
7 This example shows how to put crosses on stems. Mark the beginning
8 of a spoken section with the @code{\\speakOn} keyword, and end it
9 with the @code{\\speakOff} keyword.
10 "
11   doctitle = "Marking notes of spoken parts with a cross on the stem"
12 }
13
14 speakOn = {
15   \override Stem #'stencil = #(lambda (grob)
16     (let* ((x-parent (ly:grob-parent grob X))
17            (is-rest? (ly:grob? (ly:grob-object x-parent 'rest))))
18       (if is-rest?
19         empty-stencil
20         (ly:stencil-combine-at-edge
21           (ly:stem::print grob)
22           Y
23           (- (ly:grob-property grob 'direction))
24           (grob-interpret-markup grob
25             (markup #:hspace -1.025 #:fontsize -4
26               #:musicglyph "noteheads.s2cross"))
27           -2.3 0))))
28 }
29
30 speakOff = {
31   \revert Stem #'stencil
32 }
33
34 \score {
35   \new Staff {
36     \relative c'' {
37       a4 b a c
38       \speakOn
39       g4 f r g
40       b4 r d e
41       \speakOff
42       c4 a g f
43     }
44   }
45 }