I am trying to make my first steps in actually modifying some Scheme. I am using a procedure taken from the snippets repository to add a cross to a stem (e.g. to indicate sprechgesang):
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
speak = {
\once \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?
empty-stencil
(ly:stencil-combine-at-edge
(ly:stem::print grob)
Y
(- (ly:grob-property grob 'direction))
(grob-interpret-markup grob
(markup #:center-align #:fontsize -2
#:musicglyph "noteheads.s2cross"))
-2.3))))
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
This works fine, writing "\speak c4" for instance.
However, I'd like to be able to parameterise the position of the cross which is hard-coded as -2.3, so that I can write "\speak #-3.8 c" for instance. I've tried a couple of ways to write it, but I can't find one that works. I suppose that I will need something like "lambda (grob posn)" to define the parameter for use at the end, but I can't see how to get the value of posn from the LilyPond source into the Scheme procedure.
Help?
Thanks,
Paul