lilypond-user
[Top][All Lists]
Advanced

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

Re: shorten a broken hairpin at a linebreak?


From: Mike Solomon
Subject: Re: shorten a broken hairpin at a linebreak?
Date: Thu, 1 Sep 2011 19:56:31 +0200

On Sep 1, 2011, at 7:42 PM, harm6 wrote:

> 
> 
> Mike Solomon-2 wrote:
>> 
>> More control over the length is always achievable by overriding the
>> stencil, as is the solution to the problem you pose above regarding the
>> closing diminuendi.
>> 
>> 
> 
> Hi Mike,
> 
> great work on the closing diminuendi!!
> 
> One point left: I want each diminuendo of the broken siblings to be
> increased up to the barline.
> Using David's last-bar-Definition I came up with this Definition.
> Problem: Some lines are fine, some not. Don't know why!
> 
> Any hint to proceed?
> 
> Cheers,
>  Harm
> 
> \version "2.14.2"
> 
> #(define (has-interface? grob interface)
> (member interface
>        (assoc-get 'interfaces
>                   (ly:grob-property grob 'meta))))
> 
> #(define (find-system grob)
> (if (has-interface? grob 'system-interface)
>    grob
>    (find-system (ly:grob-parent grob X))))
> 
> #(define (first-musical-column grobl)
> (if (not (eqv? #t (ly:grob-property (car grobl) 'non-musical)))
>    (car grobl)
>    (first-musical-column (cdr grobl))))
> 
> #(define (change-bound grob)
> (let* ((system (find-system grob))
>       (cols (ly:grob-array->list (ly:grob-object system 'columns)))
>       (musical-column (first-musical-column (reverse cols))))
>  (ly:spanner-set-bound! grob RIGHT musical-column)))
> 
> %%%%% by David Nalesnik:
> 
> #(define (last-bar grob)
>   ;; return the X-coordinate of the last barline on a line
>   (let* ((sys (ly:grob-system grob))
>         (array (ly:grob-object sys 'all-elements))
>         (grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name)))
>         (lst (filter (lambda (x) (eq? 'BarLine (grob-name x)))
>                       (ly:grob-array->list array)))
>         (bar-coords (sort (map (lambda (x) (ly:grob-relative-coordinate x sys 
> X))
> lst) <)))
>         
>     (define (find-last-bar bar-coords)
>       (if (null? (cdr bar-coords))
>          (car bar-coords)
>          (find-last-bar (cdr bar-coords))))
>          
>  (find-last-bar bar-coords)))
> 
> %%%%
> 
> #(define (internal-my-callback grob fn1 fn2)
> (let* (
>        ;; have we been split?
>        (orig (ly:grob-original grob))
> 
>        ;; if yes, get the split pieces (our siblings)
>        (siblings (if (ly:grob? orig)
>                      (ly:spanner-broken-into orig)
>                      '())))
> 
>   (if (and (>= (length siblings) 2)
>            (not (eq? (car (reverse siblings)) grob)))
>     (fn1 grob)
>     (fn2 grob))))
> 
> #(define (change-ends grob)
>  (let* ((st (ly:hairpin::print grob))
>         (gd (ly:grob-property grob 'grow-direction))
>         (w (ly:stencil-extent st X))
>         (thick (* (ly:grob-property grob 'thickness)
> (ly:staff-symbol-line-thickness grob)))
>         (h (ly:stencil-extent st Y))
>         (bar-pos (last-bar grob))
>         (add (interval-length (cons (cdr w) bar-pos)))
>         (ylu (if (eqv? gd RIGHT) (interval-center (cons (interval-center h)
> (cdr h))) (cdr h)))
>         (yru (if (eqv? gd RIGHT) (cdr h) (interval-center (cons
> (interval-center h) (cdr h)))))
>         (yld (if (eqv? gd RIGHT) (interval-center (cons (car h)
> (interval-center h))) (car h)))
>         (yrd (if (eqv? gd RIGHT) (car h) (interval-center (cons (car h)
> (interval-center h))))))
>    (ly:stencil-add
>      ;(make-line-stencil thick (car w) ylu (cdr w) yru)
>      ;(make-line-stencil thick (car w) yld (cdr w) yrd)
>      (make-line-stencil thick (car w) ylu (+ add (cdr w)) yru)
>      (make-line-stencil thick (car w) yld (+ add (cdr w)) yrd)
>      )))
> 
> #(define (my-callback grob)
>  (internal-my-callback grob change-bound values)
>  (if (eqv? LEFT (ly:grob-property grob 'grow-direction))
>     (internal-my-callback grob change-ends ly:hairpin::print)
>     (ly:hairpin::print grob)))
> 
> {
> % 1
>       a1\break
>       \override Hairpin #'stencil = #my-callback
>       \override Hairpin #'bound-padding = #my-callback 
> % 2
>       a\> \repeat unfold 2 { a } \break
> % 5
>       \repeat unfold 8 { a } \break \key fis \major
> % 13
>       \repeat unfold 2 { a } \break \key ees \major
> % 15
>       \repeat unfold 17 {a} a\! \break \key ces\major
> % 33 with new hairpin
>       a1\> a1 \break \key cis\major
> % 35
>       a a\!
>    } 
> 

Hey Harm,

Unfortunately, I won't be checking my mail for a couple weeks and I won't have 
time to verify it tonight.  Sorry!  There are several heavy-overriders on the 
list, and I'm hoping one of them will be able to help you out :)

Cheers,
MS


reply via email to

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