lilypond-user
[Top][All Lists]
Advanced

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

Re: Controlling hairpin length


From: Thomas Morley
Subject: Re: Controlling hairpin length
Date: Sun, 17 Jan 2016 18:22:46 +0100

2016-01-17 17:36 GMT+01:00 David Sumbler <address@hidden>:
> Thank you for the suggestion (below) for controlling the actual length
> of hairpins.  I am afraid it has taken until now for me to have an
> opportunity to try it out in my string quartet.  Unfortunately, I find
> that it is only a partial success.
>
> Previously I had '\override Hairpin.minimum-length = #7' in my Voice
> defaults.  This works OK most of the time, although obviously sometimes
> it produces an over-long hairpin which needs an override.
>
> I then tried setting \myHairpinMinimumLength #1.5 (as in your example),
> but had to remove the Hairpin.minimum-length setting to get it to work.
> Unfortunately I found that a number of hairpins produced a compiler
> warning: "decrescendo too small".
>
> I don't understand this, because the example you gave seems to compile
> without a problem, other than that the line length is far greater than
> my page width.
>
> The bar that seems to cause most of the problems is:
>
>         g8\< a b cs( ~ cs\mf\> b) d,\mp cs |
>         g8\< g a g fs4\mf\> r\! |
>         d8\< e fs e as,(\mf\> b) r4\! |
>         e2\< d4\mf\> fs8(--\mp fs)-- |
>
> This is a "parallelMusic" bar for a standard string quartet.  The
> warnings are produced by the decrescendo, and this hairpin has zero
> actual length, despite the \myHairpinMinimumLength setting.  This
> happens in each of the parts (apart from the viola), but not in the
> score.  Presumably the extra quaver in the viola part saves the score
> and the viola part from getting this too-short hairpin, but then the
> viola part gives a similar warning in a later bar.
>
> I am using Lilypond 2.19.30.
>
> David


Hi David,

the code below gives the attached output (cut off)
I see no problems and no warnings.

Tiny example?

\version "2.19.35"

\language "english"

%% a helper:
#(define (look-up-for-parent name-symbol axis grob)
"Return the parent of @var{grob}, specified by it's @var{name-symbol} in
axis @var{axis} or @var{grob}, if equal to the grob named @var{name-symbol}
already.
If not found, look up for the next parent."
 (let* ((parent (ly:grob-parent grob axis)))
 (cond
   ((not (ly:grob? parent))
    (ly:error
       (_"Perhaps typing error for \"~a\" or \"~a\" is not in the parent-tree.")
       name-symbol name-symbol))
   ((equal? name-symbol (grob::name grob)) grob)
   ((not (equal? name-symbol (grob::name parent)))
    (look-up-for-parent name-symbol axis parent))
   (else parent))))

#(define ((hairpin-minimum-length my-minimum) grob)
  (let* ((bound-left (ly:spanner-bound grob LEFT))
         (bound-right (ly:spanner-bound grob RIGHT))
         (sys (look-up-for-parent 'System Y grob))
         (left-x-ext (ly:grob-extent bound-left sys X))
         (right-x-ext (ly:grob-extent bound-right sys X)))
    (ly:grob-set-property! grob 'minimum-length
      ;; keep 'minimum-length user-settable
      (max (ly:grob-property-data grob 'minimum-length)
           ;; nb, this calculation is only an approximation
           ;; should work in most cases, though
           (+ my-minimum (abs (cdr left-x-ext)) (abs (cdr right-x-ext)))))))

myHairpinMinimumLength =
#(define-music-function (parser location minimum)(number?)
#{
  \override Hairpin.before-line-breaking =
    #(hairpin-minimum-length minimum)
#})

%{
{
    \override Hairpin.color = #red
    \myHairpinMinimumLength #1.5
    \repeat unfold 6 { c4\ffff\> d\pppp\! c d \noBreak }
    \break
    %% overriding 'minimum-length is still possible
    \override Hairpin.minimum-length = 20
    \repeat unfold 6 { c4\ffff\> d\pppp\! c d \noBreak }
}
%}

\parallelMusic #'(A B C D) {
        g8\< a b cs( ~ cs\mf\> b) d,\mp cs |
        g8\< g a g fs4\mf\> r\! |
        d8\< e fs e as,(\mf\> b) r4\! |
        e2\< d4\mf\> fs8(--\mp fs)-- |
}

\layout {
  \context {
    \Voice
    \myHairpinMinimumLength #3
  }
}


\new StaffGroup <<
  \new Staff \A
  \new Staff \B
  \new Staff \C
  \new Staff \D
>>

\new Staff \A
\new Staff \B
\new Staff \C
\new Staff \D

Cheers,
  Harm

Attachment: atest-30.png
Description: PNG image


reply via email to

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