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: harm6
Subject: Re: shorten a broken hairpin at a linebreak?
Date: Mon, 29 Aug 2011 13:25:23 -0700 (PDT)


harm6 wrote:
> 
> Hi,
> 
> how can I shorten the first part of a broken hairpin to avoid the printing
> under a new KeySignature (or KeyCancellation, TimeSignature etc) at a
> linebreak?
> 
> Thanks!
>   Harm 
> 

It could be done this way:

\version "2.14.2"

eraseBrokenHairpin =
#(define-music-function (parser location extent)(list?)
#{
        #(define ((hairpin-eraser extent) grob)
           (ly:stencil-add
             (ly:hairpin::print grob)  
               ;(stencil-with-color (ly:round-filled-box extent (cons -1 1)
0.0) red)))
               (stencil-with-color (ly:round-filled-box extent (cons -1 1)
0.0) white)))

              
        #(define (hairpin-callback grob)
          (let* ((orig (ly:grob-original grob))
                 (siblings (if (ly:grob? orig)
                             (ly:spanner-broken-into orig) 
                             '() )))
                             
              (define (recursion-helper ls1 ls2 ls3)
                        (if (or (null? ls1) (null? ls2))
                        ls3
                        (append ls3
                           (list
                             (if (and (>= (length ls1) 1)(eq? (car ls1) grob))
                                      (if (equal? (cons 0 0) (cons (car ls2)
(cadr ls2)))
                                          (car ls1)
                                          (ly:grob-set-property! grob 'stencil 
                                                (hairpin-eraser (cons (car ls2) 
(cadr
ls2))))))
                             (recursion-helper (cdr ls1) (cddr ls2) ls3 )))))
                             
              (define (recursion lst1 lst2)
                        (recursion-helper lst1 lst2 '()))
        
        (recursion siblings $extent)))
        
         \once \override Voice.Hairpin #'after-line-breaking =
#hairpin-callback
  #})

%----------------------- Test
--------------------------------------------------

\relative c' {
        \override Hairpin #'color = #red
        \key ces\major
        \eraseBrokenHairpin #(list  67 85  93 108  95 108)
                c'1\< 
        \break
        \key cis\major
                d2  e
        \break
        \key es\major
        \time 2/2
                f g
        \break
        \key e\major
        \time 4/4
                a b\!
} 

Anyone with a better idea?

Cheers,
  Harm
http://old.nabble.com/file/p32359910/brokenHairpinErase.pdf
brokenHairpinErase.pdf 
-- 
View this message in context: 
http://old.nabble.com/shorten-a-broken-hairpin-at-a-linebreak--tp32343028p32359910.html
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.




reply via email to

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