lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hairpin with centered text


From: Thomas Morley
Subject: Re: Hairpin with centered text
Date: Sun, 10 Mar 2019 11:55:14 +0100

Hi Andrew,

Am Sa., 9. März 2019 um 02:54 Uhr schrieb Andrew Bernard
<address@hidden>:
>
> 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?

I've the impression
http://lsr.di.unimi.it/LSR/Item?id=233
fights defaults, my approach tries to use them.
Please test, if it proofs to be better I'd change the LSR-snippet.

>
> [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.]

Well, the text is usually too tall to fit inside a Hairpin. One could
use a (very) small fontsize or widen the Hairpin.
Without having tried any of this I suspect ugly output.
Do you have images from nice printings?

Here my code:

%% works with
\version "2.18.2"

\paper { ragged-right = ##t }

hairpinWithCenteredText =
#(define-music-function (parser location text) (markup?)
#{
  \once \override Hairpin.stencil =
    #(lambda (grob)
       (let* ((stencil (ly:hairpin::print grob))
              (stencil-x-ext (ly:stencil-extent stencil X))
              (txt-stil (grob-interpret-markup grob text))
              ;; Get 'direction from DynamicLineSpanner
              (par-y (ly:grob-parent grob Y))
              (dir (ly:grob-property par-y 'direction))
              (new-stencil
                (ly:stencil-combine-at-edge
                  stencil
                  Y dir
                  (ly:stencil-translate-axis
                    (ly:stencil-aligned-to txt-stil X CENTER)
                    (interval-center stencil-x-ext)
                    X)
                  ;; TODO make padding settable?
                  ;;      For now zero is hardcoded
                  0)))
         (ly:grob-set-property! grob 'Y-offset 0)
         new-stencil))
#})

treble = {
  \time 2/4
  %\override Hairpin.to-barline = ##f
  \hairpinWithCenteredText \markup { \italic "moltissimo" }
  c''1
    \ppppp
    \<
  c''\break
  c''
  c''\break
  c''
  c''
    \ppppp
    \!
}

\score {
  \new Staff {
    \treble
  }

  \layout {}
}

HTH,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]