[Top][All Lists]

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

Re: Flat flared hairpins

From: Thomas Morley
Subject: Re: Flat flared hairpins
Date: Tue, 1 Jan 2019 11:34:52 +0100

Am Di., 1. Jan. 2019 um 04:05 Uhr schrieb Andrew Bernard
> Hi Harm,
> I am greatly in your debt. This is really excellent, and you have picked up 
> exactly what  I need. Using it, I have found that when having a hairpin that 
> crosses a line break (my main original question) the flare height is set 
> incorrectly. It's quite hard to see in your example, but it's there if you 
> look hard, and it's very apparent in my score. Is it possible to correct that?
> Andrew

Hi Andrew,

yep, I overlooked it.
Below should return correctly. Though, now 'flat-flared-hairpin'
delivers a list of scaled number-pairs, 'elbowed-hairpin' uses them
and does it's own scaling and finally all is nice, hopefully ...
Doing such scaling twice bugs me, probably one should drop
'elbowed-hairpin' and develop a different tool for your use-case.

Anyway here the current code:

#(define flat-flared-hairpin
  (lambda (grob)
;; change-log: correct scaling of flare-height
"Is supposed to take a maybe broken Hairpin.
Prints a flat line, probably with flares at start/end.
The behaviour is determined looking at some sub-properties of 'details:
  - details.flare-position: whether flares at start/end are printed
      possible values are -1, 0, -1 or LEFT, CENTER, RIGHT
      (default is 0 or CENTER, meaning flares at start and end)
      Remark: can't look at 'grow-direction, because setting it zero causes an
              assertion failure.
  - details.flare-height: height of the flare, numerical value
      default is 1
      TODO: replace with Hairpin.height?
  - details.flare-width: width of the flare, numerical value
      default is 1

  TODO: default 'elbowed-hairpin' takes the provided point-list as
        percentages, leading to not constant width/height of the flares.
        Below some calculations are done to warrant canstant width/height.
        This means such calculations are done twice, here and in
        Probably develop a different tool. "
    (let* ((orig (ly:grob-original grob))
           (broken-siblings (ly:spanner-broken-into orig))
             (if (pair? broken-siblings)
                 (list grob)))
           (details (ly:grob-property grob 'details))
             (assoc-get 'flare-position details 0))
             (assoc-get 'flare-height details 1))
             (assoc-get 'flare-width details 1))
             (lambda (g)
               (let* ((stil (ly:hairpin::print g))
                      (stil-x-ext (ly:stencil-extent stil X))
                      (stil-y-ext (ly:stencil-extent stil Y))
                      (stil-x-length (interval-length stil-x-ext))
                      (stil-y-length (interval-length stil-y-ext)))
                 (if (and (or (zero? flare-position) (eqv? -1 flare-position))
                          (equal? g (car siblings)))
                       (cons 0 (/ (* 2 flare-height) stil-y-length))
                       (cons (/ flare-width stil-x-length) 0))
                     '((0 . 0))))))
             (lambda (g)
               (let* ((stil (ly:hairpin::print g))
                      (stil-x-ext (ly:stencil-extent stil X))
                      (stil-y-ext (ly:stencil-extent stil Y))
                      (stil-x-length (interval-length stil-x-ext))
                      (stil-y-length (interval-length stil-y-ext)))
                 (if (and (or (zero? flare-position) (eqv? 1 flare-position))
                          (equal? g (last siblings)))
                       (cons (- 1 (/ flare-width stil-x-length))  0)
                       (cons 1 (/ (* 2 flare-height) stil-y-length)))
                     '((1 . 0)))))))
      (elbowed-hairpin `(,@(flare-left grob) ,@(flare-right grob)) #t))))

Happy new year,

reply via email to

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