lilypond-user
[Top][All Lists]
Advanced

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

Re: Size of the arpeggio's arrow


From: Thomas Morley
Subject: Re: Size of the arpeggio's arrow
Date: Thu, 5 Dec 2019 20:01:38 +0100

Am Do., 5. Dez. 2019 um 19:02 Uhr schrieb Thomas Morley
<address@hidden>:
>
> Am Do., 5. Dez. 2019 um 18:17 Uhr schrieb Thomas Morley
> <address@hidden>:
> >
> > Am Do., 5. Dez. 2019 um 17:57 Uhr schrieb Paolo Prete <address@hidden>:
> > >
> > >
> > > Hi Thomas.
> > > Yes, I'm interested. I could not find any snippet for that, nor a 
> > > corresponding property for "Arpeggio" in the "Lilypond Internals 
> > > Reference"
> > > Thanks.
> > >
> > > Il giovedì 5 dicembre 2019, 16:22:12 GMT, Thomas Morley <address@hidden> 
> > > ha scritto:
> > >
> > >
> > > Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <address@hidden>:
> > >
> > > >
> > > > (I re-post this because it seems that mails from Yahoo services, like 
> > > > some of my previous posts, are filtered as spam)
> > > >
> > > > Hello,
> > > >
> > > > how can I modify the size of the arrow of an \arpeggioArrowUp/Down 
> > > > object?
> > > >
> > > > Thanks
> > >
> > > >
> > >
> > > There is no builtin method to do so.
> > > You could create your own stencil, though.
> > >
> > > Interested in learning howto?
> > >
> > >
> > > Cheers,
> > >   Harm
> > >
> > >
> >
> > Ok :)
> > So what do we want?
> > While applying \arpeggioArrowUp we want the usual arpeggio, but the
> > added arrow-head should be sized as we want.
> >
> > Alas, as soon as we set \arpeggioArrowUp the default is there.
> > Mmhh, what exactly does \arpeggioArrowUp?
> > Looking into property-init.ly (found by some search-functions of your
> > editor or some grepping):
> >
> > arpeggioArrowUp = {
> >   \revert Arpeggio.stencil
> >   \revert Arpeggio.X-extent
> >   \override Arpeggio.arpeggio-direction = #UP
> > }
> >
> > Interesting is arpeggio-direction, looks like it triggers the arrowed 
> > arpeggio.
> > Let's proof:
> >
> > {
> >   \arpeggioArrowUp
> >   R1
> >   \override Arpeggio.arpeggio-direction = #'()
> >   <b d' f' b'>\arpeggio
> > }
> >
> > And indeed the arrow-head is gone.
> >
> > Now we can recreate the _default_-stencil explicitely, using the
> > default-stencil, found in IR.
> > I.e. the procedure ly:arpeggio::print
> > NB, although we've set \arpeggioArrowUp
> >
> > {
> >   \arpeggioArrowUp
> >   R1
> >   \override Arpeggio.arpeggio-direction = #'()
> >   \override Arpeggio.stencil =
> >   #(lambda (grob)
> >      (ly:arpeggio::print grob))
> >   <b d' f' b'>\arpeggio
> > }
> >
> > Let us put the arpeggio-direction into the stencil-override for conveniance:
> >
> > {
> >   \arpeggioArrowUp
> >   R1
> >   \override Arpeggio.stencil =
> >   #(lambda (grob)
> >      (ly:grob-set-property! grob 'arpeggio-direction '())
> >      (ly:arpeggio::print grob))
> >   <b d' f' b'>\arpeggio
> > }
> >
> > Now we only need to add a suitable arrowhead to the stencil and are done.
> >
> >
> > So I need a little break, I'm cooking right now ;)
> >
> >
> > Cheers,
> >   Harm
>
> Now let's care about the arrow-head.
> Probably you noticed the arrow-heads in A.8 "The Emmentaler font" of NR:
> "scripts.arpeggio.arrow.1" and "scripts.arpeggio.arrow.M1"
>
> Likely it's best to select the arrow-head depending on the direction, with
>
>   (format #f
>     "scripts.arpeggio.arrow.~a1"
>     (if (negative? arp-dir)
>         "M"
>         ""))
>
> where arp-dir is the arpeggio-direction, i.e. for no we disregard what
> I said earlier.
>
> Now we have the glyph and we need to look it up in the font.
> Ok, so we need to get the font.
>
> Maybe you stumbled across ly:grob-default-font already, with this one
> we get the font.
> Now we can lookup, using ly:font-get-glyph.
>
> ly:grob-default-font and ly:font-get-glyph can be found in IR.
> To learn how to use them you will need to look throuw our source-code, though.
> I don't know much examples for it.
>
> Disregarding the arpeggio, only putting out the arrow-head it makes for:
>
>
> myArpeggio =
>   \override Arpeggio.stencil =
>   #(lambda (grob)
>     (let* ((arp-dir (ly:grob-property grob 'arpeggio-direction))
>            (arrow-glyph
>              (format #f
>                "scripts.arpeggio.arrow.~a1"
>                (if (negative? arp-dir)
>                    "M"
>                    ""))))
>
>      (ly:font-get-glyph (ly:grob-default-font grob) arrow-glyph)))
>
> {
>   \arpeggioArrowUp
>   \myArpeggio
>   <b d' f' b'>\arpeggio
>
>
>   \arpeggioArrowDown
>   \myArpeggio
>   <b d' f' b'>\arpeggio
> }
>
> Now we've created single arrow-heads depending on the direction.
>
>
> TODO:
> Adjust size of the arrow-heads
> Move them to the place where they should be
> Combine it with the usual trill-like arpeggio-line
>
>
> Laters,
>   Harm

Next steps: move the arrow-heads correctly/combine with arpeggio-line

For better debugging I colored the arrows red.
To move them correctly we need the y-ext of the arpeggio-stencil.
If arppeggio-direction is up we can use the cdr of the arpeggio-stencil.
But if arppeggio-direction is down (car stil-y-ext) is not sufficient,
we need to take the y-ext of the arrow into account as well.
Move is done with ly:stencil-translate-axis.
Finally simply add them with ly:stencil-add.

myArpeggio =
  \override Arpeggio.stencil =
  #(lambda (grob)
    (let* ((arp-dir (ly:grob-property grob 'arpeggio-direction))
           (arrow-glyph
             (format #f
               "scripts.arpeggio.arrow.~a1"
               (if (negative? arp-dir)
                   "M"
                   "")))
           (font (ly:grob-default-font grob))
           (arrow-head-stil (ly:font-get-glyph font arrow-glyph))
           (red-arrow (stencil-with-color arrow-head-stil red))
           (red-arrow-y-ext (ly:stencil-extent red-arrow Y)))

      (ly:grob-set-property! grob 'arpeggio-direction '())

      (let* ((stil (ly:arpeggio::print grob))
             (stil-y-ext (ly:stencil-extent stil Y)))

        (ly:stencil-add
          (ly:stencil-translate-axis
            red-arrow
            (if (negative? arp-dir)
                (- (car stil-y-ext) (interval-length red-arrow-y-ext))
                (cdr stil-y-ext))
            Y)
          stil))))

{
  \arpeggioArrowUp
  \myArpeggio
  <b d' f' b'>\arpeggio


  \arpeggioArrowDown
  \myArpeggio
  <b d' f' b'>\arpeggio
}

TODO Resize the arrow-head


Cheers,
  Harm



reply via email to

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