[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
<address@hidden>:
>
> 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))
(siblings
(if (pair? broken-siblings)
broken-siblings
(list grob)))
(details (ly:grob-property grob 'details))
(flare-position
(assoc-get 'flare-position details 0))
(flare-height
(assoc-get 'flare-height details 1))
(flare-width
(assoc-get 'flare-width details 1))
(flare-left
(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)))
(list
(cons 0 flare-height)
(cons (/ flare-width stil-x-length) 0))
'((0 . 0))))))
(flare-right
(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)))
(list
(cons (- 1 (/ flare-width stil-x-length)) 0)
(cons 1 flare-height))
'((1 . 0)))))))
(elbowed-hairpin `(,@(flare-left grob) ,@(flare-right grob)) #t))))
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\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
\mus
}
{
\set Staff.instrumentName = "TEST 2"
% \override Hairpin.details.flare-position = #CENTER %% or 0 or let it unset
\mus
}
{
\set Staff.instrumentName = "TEST 3"
\override Hairpin.details.flare-position = #RIGHT %% or 1
\mus
}
{
\set Staff.instrumentName = "TEST 4"
\musII
}
{
\set Staff.instrumentName = "TEST 5"
\override Hairpin.to-barline = ##f
\override Hairpin.after-line-breaking = ##t
\musIII
}
HTH,
Harm
- Re: Flat flared hairpins, (continued)
- Re: Flat flared hairpins, Malte Meyn, 2018/12/31
- Re: Flat flared hairpins, Thomas Morley, 2018/12/31
- Re: Flat flared hairpins, David Kastrup, 2018/12/31
- Re: Flat flared hairpins, Wols Lists, 2018/12/31
- Re: Flat flared hairpins, Andrew Bernard, 2018/12/31
- Re: Flat flared hairpins, Wols Lists, 2018/12/31
- Re: [OT] Variations in ordinals and building floor numbers (WAS: RE: Flat flared hairpins), Karlin High, 2018/12/31
- Re: Flat flared hairpins, mskala, 2018/12/31
- Re: OT: Flat flared hairpins, Phil Holmes, 2018/12/31
- Re: OT: Flat flared hairpins, Karlin High, 2018/12/31
Re: Flat flared hairpins,
Thomas Morley <=
Re: Flat flared hairpins, Thomas Morley, 2018/12/31
Re: Flat flared hairpins, Ming Tsang, 2018/12/31