David and Harm, I'm really impressed by the level of expertise you both
have showed in this thread. The function works wonderfully, and I'm really
grateful for your help!

I feel kind of bad for asking, but I'm stuck after trying to do what I
thought would be a minor tweak. I wanted to make it so that the two lines
that form the hairpin would end in the same vertical line, since when the
hairpin is rotated the end-points of the two lines are displaced. I tried
achieve this by drawing a white box that overlaps with the line that
overextends, therefore "deleting" the excess.

While I could not always place the box correctly, due to how
ly:stencil-stack works (I don't explain this further because of the
following), the real problem I found is that even when the box is properly
placed, the shortened line looks off. This is because Lilypond naturally
makes line endings smooth, so the "cut the excess with a box" approach
creates a hairpin with one line ending smoothly and the other ending
harshly. This is less evident for thinner lines but is easy to see with
thicker ones. Another flaw of this approach is that the white box reserves
unused space.

So, with that in mind, I wonder: is there a way to smoothen the line after
"cutting" it (which I doubt) or, lacking that, is there a way to access
only one line of the hairpin to shorten it by the necessary amount? The
later I imagine like a Hairpin.shorten-pair that affects only one of the
two lines. Alternatively, is it more sensible to just draw the two lines
and stack them into a stencil? I have not yet tried this but the more I
think about it the more it looks like the most viable option. I tried to
search the definition of ly:hairpin::print to see how Lilypond does this,
but I couldn't find it.

I realize that this may be too much trouble for something too
insignificant. However, the rotated hairpins that end in the same vertical
line are found in old engravings, like those by N. Simrock, and I thought
that it would be nice to have them as an option.

I would love to hear your thoughts on how to approach this issue.

Thank you again for all your help!
Stéfano


2018-02-04 22:37 GMT-03:00 David Nalesnik <[email protected]>:

> Hi Harm,
>
> On Sun, Feb 4, 2018 at 6:23 PM, Thomas Morley <[email protected]>
> wrote:
> > Hi David,
> >
> > I was going to post something similiar.
> > You're code is much more elegant with respect to linebreaks, great stuff.
> > Though, it will not work as desired if the beam/hairpin is distributed
> > over _three_ lines.
> > I've no clue how to make it work, admittedly it's a real rare case.
>
> Yeah, that thought occurred to me after I sent it, though I figured no
> one would notice :)
>
> Thanks so much for the improvements!  I'm sure I will find another
> opportunity to use ly:angle.
>
> Here is a possibility for multiple line spanners incorporating your
> changes:
>
> \version "2.19.65"
>
> #(define test
>    (lambda (grob)
>      (let* ((lb (ly:spanner-bound grob LEFT))
>             (rb (ly:spanner-bound grob RIGHT))
>             (stil (ly:hairpin::print grob))
>             (bound
>              (find (lambda (b)
>                      (grob::has-interface b 'note-column-interface))
>                (list lb rb)))
>             (beam
>              (if bound
>                  (ly:grob-object (ly:grob-object bound 'stem) 'beam)
>                  (let* ((col (ly:item-get-column lb))
>                         (elts (ly:grob-array->list
>                                (ly:grob-object col 'bounded-by-me))))
>                    (find (lambda (e) (grob::has-interface e
> 'beam-interface))
>                      elts)))))
>        (if (ly:grob? beam)
>            (let* ((X-pos (ly:grob-property beam 'X-positions))
>                   (Y-pos (ly:grob-property beam 'positions))
>                   (ang (ly:angle (- (cdr X-pos) (car X-pos))
>                          (- (cdr Y-pos) (car Y-pos)))))
>              (ly:stencil-rotate
>               stil ang CENTER CENTER))
>            stil))))
>
> {
>   \time 1/4 \override Hairpin.stencil = #test
>   c'16\< e' g' b'\!
>   b'16\< g' e' c'\!
>   \once \offset positions #'(0 . 3) Beam
>   c'16^\< e' g' b'\!
>
>   \override Beam.breakable = ##t
>   c'16[\< e' g' b'
>   \break c' e' g' b'
>   \break b' g' e' c'
>   \break b' g' e' c']\!
> }
>
> -David
>
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to