Hi Massimiliano,
the code you provided is _very_ old. I modified it a bit in order to
work with both possible stem directions and respect rests. Also, there
was a hard-coded offset for the cross that can more succinctly be
replaced by a \center-align.
I also lenghened the stems a bit. Note that this does not work together
with beams - I suspect it's got to do with unpure-pure-containers, which
I don't understand :-).
Best
Lukas
\version "2.21.6"
sp =
{
\override Stem.stencil =
#(lambda (grob)
(let ((dir (ly:grob-property grob 'direction))
(length (ly:grob-property grob 'length))
(actual-stem (ly:stem::print grob)))
(if (ly:stencil? actual-stem) ; do not add anything if we don't
have a stem (e.g. rests)
(ly:stencil-combine-at-edge actual-stem
1
dir
(ly:text-interface::print grob)
(+ (* length -0.5) 0.75)) ; 0.75
is the distance from cross to start of notehead
empty-stencil)))
\override Voice.Stem.text = \markup \center-align \teeny \musicglyph
#"noteheads.s2cross"
\override Voice.Stem.length = #(lambda (grob) (+ 0.5
(ly:stem::calc-length grob)))
}
\relative {
\sp c'4 d e8[ f g a] b4 r c4 d e
\undo \sp e d c b a
\once \sp g f e
}
Am 31.10.20 um 23:03 schrieb Massimiliano Viel:
And another possibly outrageous question… when I invoke /\sp/, it
works from the first following note on to the last note, rests
included (!).
How do I stop it?
I showed both \undo\sp and \once\sp in my example.
Enjoy LilyPond - it's amazing what you can achieve with it!
Lukas