[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: Mon, 31 Dec 2018 13:11:42 +0100

Am Mo., 31. Dez. 2018 um 06:01 Uhr schrieb Andrew Bernard
> I need some special flat, flared ended hairpins to indicate pulsing in a 
> string quartet I am setting for a friend. So far, I managed to adapt a 
> textspanner to do the job. It's fiddly but OK. However, because I use a 
> custom graphic path markup for the spanner, the code does not deal with line 
> breaks. It's best to refer to the attached image to see what I mean. I'll put 
> my code here. Would anybody be willing to help out on this? Line break 
> continuation code in lilypond has always been outside my grasp and skill 
> level.
> Alternatively, if there is a more nice way to achieve this, I'd be really 
> grateful to hear it.
> Andrew

Hi Andrew,

here my attempt:

\version "2.19.82"

#(define flat-flared-hairpin
  (lambda (grob)
"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
      Remark: default 'elbowed-hairpin' takes the provided point-list as
              percentages, leading to not constant widths of the flares.
              Below some calculations are done to warrant canstant width"
    (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-x-length (interval-length stil-x-ext)))
                 (if (and (or (zero? flare-position) (eqv? -1 flare-position))
                          (equal? g (car siblings)))
                       (cons 0 flare-height)
                       (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-x-length (interval-length stil-x-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 flare-height))
                     '((1 . 0)))))))
      (elbowed-hairpin `(,@(flare-left grob) ,@(flare-right grob)) #t))))


\paper { ragged-right = ##f }

mus = { c'1\< \break cis' \break d' dis'\! }

musII = { c'1\< cis' d' dis'\! }

musIII = { c'1\< \break cis' \break d'\! }

\layout {
  \override Hairpin.stencil = #flat-flared-hairpin
  \override Hairpin.details.flare-height = 2 %% default is 1
  \override Hairpin.details.flare-width = 2 %% default is 1

  \set Staff.instrumentName = "TEST 1"
  \override Hairpin.details.flare-position = #LEFT %% or -1

  \set Staff.instrumentName = "TEST 2"
%  \override Hairpin.details.flare-position = #CENTER %% or 0 or let it unset

  \set Staff.instrumentName = "TEST 3"
  \override Hairpin.details.flare-position = #RIGHT %% or 1

  \set Staff.instrumentName = "TEST 4"

  \set Staff.instrumentName = "TEST 5"
  \override = ##f
  \override Hairpin.after-line-breaking = ##t


reply via email to

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