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 08:54:48 -0500

Hi Daniel,

> So far so good, but I've noticed that if you do a \break before ending the
> hairpin (e.g. a hairpin through 4 bars), the hairpin parenthesis repeats.
> Is that a normal behaviour?
>

This is the expected and documented behavior in LilyPond, but not
convenient!  The reason this happens is that when you break a spanner,
the original object is cloned, and all pieces inherit any overrides.

The section 
http://www.lilypond.org/doc/v2.16/Documentation/extending/difficult-tweaks
describes this situation and what to do about it.

Below I've rewritten the snippet to show you how this might be done:

% this snippet is useful to put a hairpin between to markups i.e.
parentheses or slash
% or any other text

% este fragmento sirve para poner un regulador de angulo entre dos markups, p.e.
% parentesis, corchetes, barras o cualquier otro texto

% leftText y rightText serĂ¡n los textos a la izquierda y a la derecha
respectivamente
% leftText and rightText will be the markup texts on each side of the hairpin

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))
              (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)))
         (if (or (null? siblings)
                 (eq? grob (car siblings)))
             (set! hairpin-stencil
                   (ly:stencil-combine-at-edge
                     left-addition
                     X RIGHT
                     hairpin-stencil
                     0)))
         (if (or (null? siblings)
                 (eq? grob (car (reverse siblings))))
             (set! hairpin-stencil
                   (ly:stencil-combine-at-edge
                     hairpin-stencil
                     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 "(" \markup ")"

% 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]