LSR 233 is useful. But when used across a line break, the hairpin falls short of the length of a normal hairpin. This is the case whether to-barline is turned on or off. I'd like it to be the same length as the unadorned hairpin.
Can anybody assist?
[For extra credit, would it be possible to have the text inside the hairpin? I know that might be complicated - I suppose the hairpin would have to be drawn manually.]
Andrew
%======
\version "2.19.82"
% LSR 233
hairpinWithCenteredText =
#(define-music-function (parser location text) (markup?)
#{
\once \override Voice.Hairpin.after-line-breaking =
#(lambda (grob)
(let* ((stencil (ly:hairpin::print grob))
(par-y (ly:grob-parent grob Y))
(dir (ly:grob-property par-y 'direction))
(new-stencil (ly:stencil-aligned-to
(ly:stencil-combine-at-edge
(ly:stencil-aligned-to stencil X CENTER)
Y dir
(ly:stencil-aligned-to
(grob-interpret-markup grob text) X CENTER))
X LEFT))
(staff-space (ly:output-def-lookup
(ly:grob-layout grob) 'staff-space))
(staff-line-thickness
(ly:output-def-lookup (ly:grob-layout grob) 'line-thickness))
(par-x (ly:grob-parent grob X))
(dyn-text (grob::has-interface par-x 'dynamic-text-interface))
(dyn-text-stencil-x-length
(if dyn-text
(interval-length
(ly:stencil-extent (ly:grob-property par-x 'stencil) X))
0))
(x-shift
(if dyn-text
(-
(+ staff-space dyn-text-stencil-x-length)
(* 0.5 staff-line-thickness)) 0)))
(ly:grob-set-property! grob 'Y-offset 0)
(ly:grob-set-property! grob 'stencil
(ly:stencil-translate-axis
new-stencil
x-shift X))))
#})
treble = {
\time 2/4
%\override Hairpin.to-barline = ##f
\hairpinWithCenteredText \markup { \italic moltissimo }
c''1\<
c''\break
c''
c''\!
\break
c''1\<
c''\break
c''
c''\!
}
\score {
\new Staff {
\treble
}
\layout {}
}
%======