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: David Nalesnik
Subject: Re: shorten a broken hairpin at a linebreak?
Date: Mon, 29 Aug 2011 16:50:41 -0500



On Mon, Aug 29, 2011 at 3:25 PM, harm6 <address@hidden> wrote:


harm6 wrote:
Anyone with a better idea?

Hi, Harm --

I've been playing around with your function and experimenting with ways to automate calculation of the whiteout box extents.  I recast it to accept offsets from the current line-width, so I think there is more flexibility, less need to guess.  Leave a number in the input list at 0 and the function will use, in this case, 108.120472440945 -- you could see tiny traces of the hairpin at the line ends :)

Not sure about calculating the other end of the whiteout box (from position of the barline, I suppose).

Hope this is helpful --

David 

\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)
'() ))
   (line-width (ly:output-def-lookup (ly:grob-layout grob) 'line-width)))
   
(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 (- line-width (car ls2)) (- line-width (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  41 23  15 0  13 0) ;; recast as offsets from line-width
               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\!
}

reply via email to

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