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: Tue, 30 Aug 2011 17:55:49 +0200

On Aug 30, 2011, at 4:28 PM, harm6 wrote:

> 
> 
> Mike Solomon-2 wrote:
>> 
>> How about:
>> 
>> \version "2.14.0"
>> 
>> #(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)))
>> 
>> #(define (my-callback grob)
>>  (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)))
>>      (change-bound grob))))
>> {
>> \override Hairpin #'after-line-breaking = #my-callback
>> a\< \repeat unfold 31 { a } \break \key fis \major \repeat unfold 74 { a
>> } a\p
>> }
>> 
>> Cheers,
>> MS
>> 
> 
> Hi Mike,
> 
> thanks a lot for your work. Your approach to the problem is completely
> beyond my knowledge. I'm trying my definitions with a plethora of manuels
> around me. But I can copy, paste and test.
> 
> So I noticed some problems:
> 
> Your own testing works fine, but it doesn't adding a line in the beginning.
> 
> {
>       a1 \break
>       \override Hairpin #'after-line-breaking = #my-callback
>       a4\< \repeat unfold 31 { a } \break \key fis \major \repeat unfold
> 74 { a } a\p
> }

Hmm...I thought that after-line-breaking would be called after the bounds were 
set, but I was wrong.

Try:

#(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)))

#(define (internal-my-callback grob)
  (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)))
      (change-bound grob))))

#(define (my-callback grob)
 (internal-my-callback grob)
 (ly:hairpin::print grob))

{
a1\break
\override Hairpin #'stencil = #my-callback
a\< \repeat unfold 31 { a } \break \key fis \major
\repeat unfold 32 { a } \break \key ees \major \repeat unfold 42 {a} a\p
}

It may result in oddities with other grobs that rely on spanner bounds, but it 
should be tame in most situations.

Cheers,
MS


reply via email to

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