lilypond-user
[Top][All Lists]
Advanced

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

Re: Parenthesized Hairpin


From: David Nalesnik
Subject: Re: Parenthesized Hairpin
Date: Thu, 30 Aug 2012 19:00:33 -0500

Hi eluze,

On Thu, Aug 30, 2012 at 5:06 PM, eluze <address@hidden> wrote:
>
> David Nalesnik-2 wrote
>>
>>
>> Below I've rewritten the snippet to show you how this might be done:
>>
> thanks David
>
> now I see another problem (maybe I should open a new post or bug report for
> it):
>
> this example moves the hairpin to the right (on the first line) and in the
> second line the text is just appended to the hairpin and thus appears below
> the following note(s) - is there a way to fit it to the line-width?
>
> to illustrate this, I use longer text on the left and right:
>
> /parenthesizedHairpin = \hairpinBetweenText \markup \small "slowly " \markup
> \small "………!"/
>
> http://lilypond.1069038.n5.nabble.com/file/n131765/hairpin%2Bbreak.png
>

One quick remedy for this is to scale the stencil to accommodate the
added text.  This has the potential for distortion, and a better way
would be to adjust the bounds of the hairpin.  I'm not sure how to do
this.

Anyway, hope this helps!

-David

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
hairpinBetweenText =
#(define-music-function (parser location leftText rightText) (markup? markup?)
   #{
     \once \override Hairpin #'stencil =
     #(lambda (grob)
       (let* ((orig (ly:grob-original grob))
              (siblings (if (ly:grob? orig)
                            (ly:spanner-broken-into orig)
                            '()))
              (hairpin-stencil
                (ly:stencil-aligned-to (ly:hairpin::print grob) Y CENTER))
              (hairpin-stencil-extent
                (interval-length (ly:stencil-extent hairpin-stencil X)))
              (left-addition
                (ly:stencil-aligned-to (grob-interpret-markup grob
leftText) Y CENTER))
              (right-addition
                (ly:stencil-aligned-to (grob-interpret-markup grob
rightText) Y CENTER))
              (left-addition-extent
                (interval-length (ly:stencil-extent left-addition X)))
              (right-addition-extent
                (interval-length (ly:stencil-extent right-addition X))))
         (if (null? siblings) ; if hairpin is whole, add text to both ends
                              ; scale to reflect both markups
             (begin
               (set! hairpin-stencil
                     (ly:stencil-combine-at-edge
                       (ly:stencil-scale hairpin-stencil
                         (/ (- hairpin-stencil-extent
                               left-addition-extent
                               right-addition-extent)
                            hairpin-stencil-extent)
                            1)
                       X RIGHT
                       right-addition
                       0.6))
               (set! hairpin-stencil
                     (ly:stencil-combine-at-edge
                       left-addition
                       X RIGHT
                       hairpin-stencil
                       0)))
             (cond ((eq? grob (car siblings)) ; if first piece, add text to left
                    (set! hairpin-stencil
                          (ly:stencil-combine-at-edge
                          left-addition
                          X RIGHT
                          (ly:stencil-scale hairpin-stencil
                            (/ (- hairpin-stencil-extent
                                  left-addition-extent)
                               hairpin-stencil-extent)
                            1) ; I didn't scale Y
                         0)))
                   ((eq? grob (car (reverse siblings))) ; if last
piece, add text to right
                    (set! hairpin-stencil
                          (ly:stencil-combine-at-edge
                            (ly:stencil-scale hairpin-stencil
                              (/ (- hairpin-stencil-extent
                                    right-addition-extent)
                                 hairpin-stencil-extent)
                              1)
                           X RIGHT
                            right-addition
                            0.6)))))
         hairpin-stencil))
   #})

%cambiando el contenido de los \markup cambiamos el objeto de texto (elemento
%de marcado y aceptara cualquier cosa que se pueda incluir en estos.

%you can change de content of the \markup to show diferent texts
%or any other thing you can put in a \markup

parenthesizedHairpin = \hairpinBetweenText \markup "slowly" \markup
\small "………!"

% the music
\score {
  \relative c' {
    \time 3/4
    \parenthesizedHairpin
    c\< d e
    \break
    f g a
    %\break
    b c d
    %\break
    e f g
    a\!
  }
}



reply via email to

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