Size of the arpeggio's arrow

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Size of the arpeggio's arrow

Paolo Prete-3
(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

Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Thomas Morley-2
Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <[hidden email]>:
>
> (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

Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Paolo Prete

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 <[hidden email]> ha scritto:


Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <[hidden email]>:

>
> (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


Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Paolo Prete-3
In reply to this post by Thomas Morley-2
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.

On Thu, Dec 5, 2019 at 5:17 PM Thomas Morley <[hidden email]> wrote:
Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <[hidden email]>:
>
> (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
Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Thomas Morley-2
In reply to this post by Paolo Prete
Am Do., 5. Dez. 2019 um 17:57 Uhr schrieb Paolo Prete <[hidden email]>:

>
>
> 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 <[hidden email]> ha scritto:
>
>
> Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <[hidden email]>:
>
> >
> > (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

Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Thomas Morley-2
Am Do., 5. Dez. 2019 um 18:17 Uhr schrieb Thomas Morley
<[hidden email]>:

>
> Am Do., 5. Dez. 2019 um 17:57 Uhr schrieb Paolo Prete <[hidden email]>:
> >
> >
> > 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 <[hidden email]> ha scritto:
> >
> >
> > Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <[hidden email]>:
> >
> > >
> > > (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

Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Thomas Morley-2
Am Do., 5. Dez. 2019 um 19:02 Uhr schrieb Thomas Morley
<[hidden email]>:

>
> Am Do., 5. Dez. 2019 um 18:17 Uhr schrieb Thomas Morley
> <[hidden email]>:
> >
> > Am Do., 5. Dez. 2019 um 17:57 Uhr schrieb Paolo Prete <[hidden email]>:
> > >
> > >
> > > 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 <[hidden email]> ha scritto:
> > >
> > >
> > > Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <[hidden email]>:
> > >
> > > >
> > > > (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 | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Thomas Morley-2
Am Do., 5. Dez. 2019 um 20:01 Uhr schrieb Thomas Morley
<[hidden email]>:

>
> Am Do., 5. Dez. 2019 um 19:02 Uhr schrieb Thomas Morley
> <[hidden email]>:
> >
> > Am Do., 5. Dez. 2019 um 18:17 Uhr schrieb Thomas Morley
> > <[hidden email]>:
> > >
> > > Am Do., 5. Dez. 2019 um 17:57 Uhr schrieb Paolo Prete <[hidden email]>:
> > > >
> > > >
> > > > 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 <[hidden email]> ha scritto:
> > > >
> > > >
> > > > Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <[hidden email]>:
> > > >
> > > > >
> > > > > (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

In my last mail I actually sort of recreated the arrowed arpeggio-stencil.
This is fine, because no we can start manipulating it.
Let's try to scale up the arrows a bit, using ly:stencil-scale, see IR.


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
             (ly:stencil-scale
               (stencil-with-color arrow-head-stil red)
               1.5 1.5))
           (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))
             (stil-x-ext (ly:stencil-extent stil X)))
        (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
}


Though, now the arrow-head is a little off regarding x-axis.

We need to compensate, best to move him back where he belongs by half
the difference of arpeggio and arrow-stils widths.
Thus we switch from ly:stencil-translate-axis to ly:stencil-translate
expecting a pair for x/y.

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"
                   "")))
           (font (ly:grob-default-font grob))
           (arrow-head-stil (ly:font-get-glyph font arrow-glyph))
           (red-arrow
             (ly:stencil-scale (stencil-with-color arrow-head-stil
red) 1.5 1.5))
           (red-arrow-y-ext (ly:stencil-extent red-arrow Y))
           (red-arrow-x-ext (ly:stencil-extent red-arrow X)))

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

      (let* ((stil (ly:arpeggio::print grob))
             (stil-y-ext (ly:stencil-extent stil Y))
             (stil-x-ext (ly:stencil-extent stil X)))
        (ly:stencil-add
          (ly:stencil-translate
            red-arrow
            (if (negative? arp-dir)
                (cons
                 (/
                  (- (interval-length stil-x-ext)
                     (interval-length red-arrow-x-ext)
                     )
                  2)
                  (- (car stil-y-ext) (interval-length red-arrow-y-ext)))
                (cons
                 (/
                  (- (interval-length stil-x-ext)
                     (interval-length red-arrow-x-ext)
                     )
                  2)
                  (cdr stil-y-ext))))
          stil))))

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


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

TODO
- remove the color
- probably transform the override into a music-function, then the now hardcoded
  scaling value is more conveniant settable.

Shouldn't be hard from here, please ask if something isn't clear.

Ofcourse you need to test all with real world examples. Some bugs may
raise their head...

NB if the scaling value is too high, then the output will be always poor.
If you really need a huge arrow-head, we would need to construct it
from scratch, not looking into the font.


Tutorial closed for now lol

Best,
  Harm

Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Thomas Morley-2
Am Do., 5. Dez. 2019 um 20:46 Uhr schrieb Thomas Morley
<[hidden email]>:

>
> Am Do., 5. Dez. 2019 um 20:01 Uhr schrieb Thomas Morley
> <[hidden email]>:
> >
> > Am Do., 5. Dez. 2019 um 19:02 Uhr schrieb Thomas Morley
> > <[hidden email]>:
> > >
> > > Am Do., 5. Dez. 2019 um 18:17 Uhr schrieb Thomas Morley
> > > <[hidden email]>:
> > > >
> > > > Am Do., 5. Dez. 2019 um 17:57 Uhr schrieb Paolo Prete <[hidden email]>:
> > > > >
> > > > >
> > > > > 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 <[hidden email]> ha scritto:
> > > > >
> > > > >
> > > > > Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <[hidden email]>:
> > > > >
> > > > > >
> > > > > > (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
>
> In my last mail I actually sort of recreated the arrowed arpeggio-stencil.
> This is fine, because no we can start manipulating it.
> Let's try to scale up the arrows a bit, using ly:stencil-scale, see IR.
>
>
> 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
>              (ly:stencil-scale
>                (stencil-with-color arrow-head-stil red)
>                1.5 1.5))
>            (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))
>              (stil-x-ext (ly:stencil-extent stil X)))
>         (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
> }
>
>
> Though, now the arrow-head is a little off regarding x-axis.
>
> We need to compensate, best to move him back where he belongs by half
> the difference of arpeggio and arrow-stils widths.
> Thus we switch from ly:stencil-translate-axis to ly:stencil-translate
> expecting a pair for x/y.
>
> 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"
>                    "")))
>            (font (ly:grob-default-font grob))
>            (arrow-head-stil (ly:font-get-glyph font arrow-glyph))
>            (red-arrow
>              (ly:stencil-scale (stencil-with-color arrow-head-stil
> red) 1.5 1.5))
>            (red-arrow-y-ext (ly:stencil-extent red-arrow Y))
>            (red-arrow-x-ext (ly:stencil-extent red-arrow X)))
>
>       (ly:grob-set-property! grob 'arpeggio-direction '())
>
>       (let* ((stil (ly:arpeggio::print grob))
>              (stil-y-ext (ly:stencil-extent stil Y))
>              (stil-x-ext (ly:stencil-extent stil X)))
>         (ly:stencil-add
>           (ly:stencil-translate
>             red-arrow
>             (if (negative? arp-dir)
>                 (cons
>                  (/
>                   (- (interval-length stil-x-ext)
>                      (interval-length red-arrow-x-ext)
>                      )
>                   2)
>                   (- (car stil-y-ext) (interval-length red-arrow-y-ext)))
>                 (cons
>                  (/
>                   (- (interval-length stil-x-ext)
>                      (interval-length red-arrow-x-ext)
>                      )
>                   2)
>                   (cdr stil-y-ext))))
>           stil))))
>
> {
>   \arpeggioArrowUp
>   \myArpeggio
>   <b d' f' b'>\arpeggio
>
>
>   \arpeggioArrowDown
>   \myArpeggio
>   <b d' f' b'>\arpeggio
> }
>
> TODO
> - remove the color
> - probably transform the override into a music-function, then the now hardcoded
>   scaling value is more conveniant settable.

I forgot, sometimes the arpeggio is to tall now.
Probably add an override for 'positions or something like
\offset positions #'(1 . 0) Arpeggio
or
tackle 'positions directly in myArpeggio

>
> Shouldn't be hard from here, please ask if something isn't clear.
>
> Ofcourse you need to test all with real world examples. Some bugs may
> raise their head...
>
> NB if the scaling value is too high, then the output will be always poor.
> If you really need a huge arrow-head, we would need to construct it
> from scratch, not looking into the font.
>
>
> Tutorial closed for now lol
>
> Best,
>   Harm

Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Thomas Morley-2
Am Do., 5. Dez. 2019 um 20:56 Uhr schrieb Thomas Morley
<[hidden email]>:

>
> Am Do., 5. Dez. 2019 um 20:46 Uhr schrieb Thomas Morley
> <[hidden email]>:
> >
> > Am Do., 5. Dez. 2019 um 20:01 Uhr schrieb Thomas Morley
> > <[hidden email]>:
> > >
> > > Am Do., 5. Dez. 2019 um 19:02 Uhr schrieb Thomas Morley
> > > <[hidden email]>:
> > > >
> > > > Am Do., 5. Dez. 2019 um 18:17 Uhr schrieb Thomas Morley
> > > > <[hidden email]>:
> > > > >
> > > > > Am Do., 5. Dez. 2019 um 17:57 Uhr schrieb Paolo Prete <[hidden email]>:
> > > > > >
> > > > > >
> > > > > > 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 <[hidden email]> ha scritto:
> > > > > >
> > > > > >
> > > > > > Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <[hidden email]>:
> > > > > >
> > > > > > >
> > > > > > > (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
> >
> > In my last mail I actually sort of recreated the arrowed arpeggio-stencil.
> > This is fine, because no we can start manipulating it.
> > Let's try to scale up the arrows a bit, using ly:stencil-scale, see IR.
> >
> >
> > 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
> >              (ly:stencil-scale
> >                (stencil-with-color arrow-head-stil red)
> >                1.5 1.5))
> >            (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))
> >              (stil-x-ext (ly:stencil-extent stil X)))
> >         (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
> > }
> >
> >
> > Though, now the arrow-head is a little off regarding x-axis.
> >
> > We need to compensate, best to move him back where he belongs by half
> > the difference of arpeggio and arrow-stils widths.
> > Thus we switch from ly:stencil-translate-axis to ly:stencil-translate
> > expecting a pair for x/y.
> >
> > 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"
> >                    "")))
> >            (font (ly:grob-default-font grob))
> >            (arrow-head-stil (ly:font-get-glyph font arrow-glyph))
> >            (red-arrow
> >              (ly:stencil-scale (stencil-with-color arrow-head-stil
> > red) 1.5 1.5))
> >            (red-arrow-y-ext (ly:stencil-extent red-arrow Y))
> >            (red-arrow-x-ext (ly:stencil-extent red-arrow X)))
> >
> >       (ly:grob-set-property! grob 'arpeggio-direction '())
> >
> >       (let* ((stil (ly:arpeggio::print grob))
> >              (stil-y-ext (ly:stencil-extent stil Y))
> >              (stil-x-ext (ly:stencil-extent stil X)))
> >         (ly:stencil-add
> >           (ly:stencil-translate
> >             red-arrow
> >             (if (negative? arp-dir)
> >                 (cons
> >                  (/
> >                   (- (interval-length stil-x-ext)
> >                      (interval-length red-arrow-x-ext)
> >                      )
> >                   2)
> >                   (- (car stil-y-ext) (interval-length red-arrow-y-ext)))
> >                 (cons
> >                  (/
> >                   (- (interval-length stil-x-ext)
> >                      (interval-length red-arrow-x-ext)
> >                      )
> >                   2)
> >                   (cdr stil-y-ext))))
> >           stil))))
> >
> > {
> >   \arpeggioArrowUp
> >   \myArpeggio
> >   <b d' f' b'>\arpeggio
> >
> >
> >   \arpeggioArrowDown
> >   \myArpeggio
> >   <b d' f' b'>\arpeggio
> > }
> >
> > TODO
> > - remove the color
> > - probably transform the override into a music-function, then the now hardcoded
> >   scaling value is more conveniant settable.
>
> I forgot, sometimes the arpeggio is to tall now.
> Probably add an override for 'positions or something like
> \offset positions #'(1 . 0) Arpeggio
> or
> tackle 'positions directly in myArpeggio
>
> >
> > Shouldn't be hard from here, please ask if something isn't clear.
> >
> > Ofcourse you need to test all with real world examples. Some bugs may
> > raise their head...
> >
> > NB if the scaling value is too high, then the output will be always poor.
> > If you really need a huge arrow-head, we would need to construct it
> > from scratch, not looking into the font.
> >
> >
> > Tutorial closed for now lol
> >
> > Best,
> >   Harm

Tackling the TODOs:

biggerArrow =
#(define-music-function (scale)(number?)
#{
  \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
             (ly:stencil-scale arrow-head-stil scale scale))
           (red-arrow-y-ext (ly:stencil-extent red-arrow Y))
           (red-arrow-x-ext (ly:stencil-extent red-arrow X))
           (pos (ly:grob-property grob 'positions)))

      (ly:grob-set-property! grob 'positions
        (if (positive? arp-dir)
            (cons (car pos) (- (cdr pos) (interval-length red-arrow-x-ext)))
            (cons (+ (car pos) (interval-length red-arrow-x-ext)) (cdr pos))))

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

      (let* ((stil (ly:arpeggio::print grob))
             (stil-y-ext (ly:stencil-extent stil Y))
             (stil-x-ext (ly:stencil-extent stil X)))
        (ly:stencil-add
          (ly:stencil-translate
            red-arrow
            (if (negative? arp-dir)
                (cons
                 (/
                  (- (interval-length stil-x-ext)
                     (interval-length red-arrow-x-ext))
                  2)
                  (- (car stil-y-ext) (interval-length red-arrow-y-ext)))
                (cons
                 (/
                  (- (interval-length stil-x-ext)
                     (interval-length red-arrow-x-ext))
                  2)
                  (cdr stil-y-ext))))
          stil))))
#})

{
  \arpeggioArrowUp
  \biggerArrow 1.2
  <b d' f' b'>\arpeggio

  \arpeggioArrowDown

  \biggerArrow 1.2
  <b d' f' b'>\arpeggio
}

Best,
  Harm

Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Paolo Prete-3
Thomas,

thank you for your help. Unfortunately the snippet produces two errors that are visible with a size bigger than 1.2.

Have a look at:   http://lilybin.com/y1t45z/1

1)   A collision between the arrow and the notehead that cannot be removed properly by overriding  Arpeggio.padding
2) A graphical mismatch between the arrow and the stem

About 1), I can't find another property that can fix the issue.

About 2), Instead of the default symbol, I would use a simple triangle, so to avoid any mismatch. Which is the way to add it? 

I think this feature is very important, because the default arrow is really too small...

Best,
P

On Thu, Dec 5, 2019 at 9:52 PM Thomas Morley <[hidden email]> wrote:
Am Do., 5. Dez. 2019 um 20:56 Uhr schrieb Thomas Morley
<[hidden email]>:
>
> Am Do., 5. Dez. 2019 um 20:46 Uhr schrieb Thomas Morley
> <[hidden email]>:
> >
> > Am Do., 5. Dez. 2019 um 20:01 Uhr schrieb Thomas Morley
> > <[hidden email]>:
> > >
> > > Am Do., 5. Dez. 2019 um 19:02 Uhr schrieb Thomas Morley
> > > <[hidden email]>:
> > > >
> > > > Am Do., 5. Dez. 2019 um 18:17 Uhr schrieb Thomas Morley
> > > > <[hidden email]>:
> > > > >
> > > > > Am Do., 5. Dez. 2019 um 17:57 Uhr schrieb Paolo Prete <[hidden email]>:
> > > > > >
> > > > > >
> > > > > > 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 <[hidden email]> ha scritto:
> > > > > >
> > > > > >
> > > > > > Am Do., 5. Dez. 2019 um 15:07 Uhr schrieb Paolo Pr <[hidden email]>:
> > > > > >
> > > > > > >
> > > > > > > (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
> >
> > In my last mail I actually sort of recreated the arrowed arpeggio-stencil.
> > This is fine, because no we can start manipulating it.
> > Let's try to scale up the arrows a bit, using ly:stencil-scale, see IR.
> >
> >
> > 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
> >              (ly:stencil-scale
> >                (stencil-with-color arrow-head-stil red)
> >                1.5 1.5))
> >            (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))
> >              (stil-x-ext (ly:stencil-extent stil X)))
> >         (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
> > }
> >
> >
> > Though, now the arrow-head is a little off regarding x-axis.
> >
> > We need to compensate, best to move him back where he belongs by half
> > the difference of arpeggio and arrow-stils widths.
> > Thus we switch from ly:stencil-translate-axis to ly:stencil-translate
> > expecting a pair for x/y.
> >
> > 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"
> >                    "")))
> >            (font (ly:grob-default-font grob))
> >            (arrow-head-stil (ly:font-get-glyph font arrow-glyph))
> >            (red-arrow
> >              (ly:stencil-scale (stencil-with-color arrow-head-stil
> > red) 1.5 1.5))
> >            (red-arrow-y-ext (ly:stencil-extent red-arrow Y))
> >            (red-arrow-x-ext (ly:stencil-extent red-arrow X)))
> >
> >       (ly:grob-set-property! grob 'arpeggio-direction '())
> >
> >       (let* ((stil (ly:arpeggio::print grob))
> >              (stil-y-ext (ly:stencil-extent stil Y))
> >              (stil-x-ext (ly:stencil-extent stil X)))
> >         (ly:stencil-add
> >           (ly:stencil-translate
> >             red-arrow
> >             (if (negative? arp-dir)
> >                 (cons
> >                  (/
> >                   (- (interval-length stil-x-ext)
> >                      (interval-length red-arrow-x-ext)
> >                      )
> >                   2)
> >                   (- (car stil-y-ext) (interval-length red-arrow-y-ext)))
> >                 (cons
> >                  (/
> >                   (- (interval-length stil-x-ext)
> >                      (interval-length red-arrow-x-ext)
> >                      )
> >                   2)
> >                   (cdr stil-y-ext))))
> >           stil))))
> >
> > {
> >   \arpeggioArrowUp
> >   \myArpeggio
> >   <b d' f' b'>\arpeggio
> >
> >
> >   \arpeggioArrowDown
> >   \myArpeggio
> >   <b d' f' b'>\arpeggio
> > }
> >
> > TODO
> > - remove the color
> > - probably transform the override into a music-function, then the now hardcoded
> >   scaling value is more conveniant settable.
>
> I forgot, sometimes the arpeggio is to tall now.
> Probably add an override for 'positions or something like
> \offset positions #'(1 . 0) Arpeggio
> or
> tackle 'positions directly in myArpeggio
>
> >
> > Shouldn't be hard from here, please ask if something isn't clear.
> >
> > Ofcourse you need to test all with real world examples. Some bugs may
> > raise their head...
> >
> > NB if the scaling value is too high, then the output will be always poor.
> > If you really need a huge arrow-head, we would need to construct it
> > from scratch, not looking into the font.
> >
> >
> > Tutorial closed for now lol
> >
> > Best,
> >   Harm

Tackling the TODOs:

biggerArrow =
#(define-music-function (scale)(number?)
#{
  \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
             (ly:stencil-scale arrow-head-stil scale scale))
           (red-arrow-y-ext (ly:stencil-extent red-arrow Y))
           (red-arrow-x-ext (ly:stencil-extent red-arrow X))
           (pos (ly:grob-property grob 'positions)))

      (ly:grob-set-property! grob 'positions
        (if (positive? arp-dir)
            (cons (car pos) (- (cdr pos) (interval-length red-arrow-x-ext)))
            (cons (+ (car pos) (interval-length red-arrow-x-ext)) (cdr pos))))

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

      (let* ((stil (ly:arpeggio::print grob))
             (stil-y-ext (ly:stencil-extent stil Y))
             (stil-x-ext (ly:stencil-extent stil X)))
        (ly:stencil-add
          (ly:stencil-translate
            red-arrow
            (if (negative? arp-dir)
                (cons
                 (/
                  (- (interval-length stil-x-ext)
                     (interval-length red-arrow-x-ext))
                  2)
                  (- (car stil-y-ext) (interval-length red-arrow-y-ext)))
                (cons
                 (/
                  (- (interval-length stil-x-ext)
                     (interval-length red-arrow-x-ext))
                  2)
                  (cdr stil-y-ext))))
          stil))))
#})

{
  \arpeggioArrowUp
  \biggerArrow 1.2
  <b d' f' b'>\arpeggio

  \arpeggioArrowDown

  \biggerArrow 1.2
  <b d' f' b'>\arpeggio
}

Best,
  Harm
Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Thomas Morley-2
Am Fr., 6. Dez. 2019 um 01:39 Uhr schrieb Paolo Pr <[hidden email]>:

>
> Thomas,
>
> thank you for your help. Unfortunately the snippet produces two errors that are visible with a size bigger than 1.2.
>
> Have a look at:   http://lilybin.com/y1t45z/1
>
> 1)   A collision between the arrow and the notehead that cannot be removed properly by overriding  Arpeggio.padding
> 2) A graphical mismatch between the arrow and the stem
>
> About 1), I can't find another property that can fix the issue.

Well, this is indeed a bug. We forgot to adjust X-extent for the
enlarged stencil.
Fixed in the code at the bottom of this mail.
Probably we need to adjust the stencil itself as well. Not sure,
though. In the code it's commented.

> About 2), Instead of the default symbol, I would use a simple triangle, so to avoid any mismatch. Which is the way to add it?

So far it's more due to the changed calculation:

I wrote:

>>                  (/
>>                   (- (interval-length stil-x-ext)
>>                      (interval-length red-arrow-x-ext))
>>                   2)

The lilybin-file reads:

                 (/
                  (- (interval-length stil-x-ext)
                     (interval-length red-arrow-x-ext))
                  10)

Which causes the problem. Go back to `2´ and all is fine.

If you want another stencil for the arrow-head then the method is
already demonstrated.
Get the stencil from the font (there are other arrows available) or
construct it. Using markup would be the most simple. Add it to the
default line. Move the arrow accordingly.
Take care of properties positions and X-extent.

Here the changed code, additionally I did some clean up, avoiding
multiple calculations of the same things adding comments etc.

biggerArrow =
#(define-music-function (scale)(number?)
"Returns an override for @code{Arpeggio.stencil}, with arrow-heads scaled by
@var{scale}"
#{
  \override Arpeggio.stencil =
  #(lambda (grob)
    (let* ((arp-dir (ly:grob-property grob 'arpeggio-direction)))
      ;; If 'arpeggio-direction is unset use default-stencil
      (if (null? arp-dir)
          (ly:arpeggio::print grob)
          (let* ((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))
                 (arrow (ly:stencil-scale arrow-head-stil scale scale))
                 (arrow-y-ext (ly:stencil-extent arrow Y))
                 (arrow-x-ext (ly:stencil-extent arrow X))
                 (arrow-width (interval-length arrow-x-ext))
                 (pos (ly:grob-property grob 'positions)))

            ;; 'positions modified to reflect the height of the arrow-head
            (ly:grob-set-property! grob 'positions
              (if (positive? arp-dir)
                  (cons (car pos) (- (cdr pos) arrow-width))
                  (cons (+ (car pos) arrow-width) (cdr pos))))

            ;; unset 'arpeggio-direction to get the default trill-line stencil
            (ly:grob-set-property! grob 'arpeggio-direction '())

            (let* ((stil (ly:arpeggio::print grob))
                   (stil-y-ext (ly:stencil-extent stil Y))
                   (stil-x-ext (ly:stencil-extent stil X))
                   (stil-width (interval-length stil-x-ext))
                   ;; A scaled arrow-head will be slightly off, find the value
                   ;; to compensate for x-axis, before adding it to the
                   ;; arpeggio-line
                   (scale-compensate-x (/ (- stil-width arrow-width) 2))
                   (new-stil
                     (ly:stencil-add
                       (ly:stencil-translate
                         arrow
                         (cons
                           scale-compensate-x
                           (if (negative? arp-dir)
                               ;; For a down pointing arrow, it's top will be at
                               ;; arpeggio-line-bottom, move by it's height to
                               ;; let the arrow-basis match with the line-bottom
                               (- (car stil-y-ext)
                                  (interval-length arrow-y-ext))
                               (cdr stil-y-ext))))
                       stil)))

               ;; We need to adjust 'X-extent to reflect the enlarged arrow,
               ;; in order to avoid spacing issues
               (ly:grob-set-property! grob 'X-extent
                 (interval-widen
                   (ly:arpeggio::width grob)
                   (* scale-compensate-x -2)))

               ;; Do we need to resize the stencil? For now commented
               ;(ly:make-stencil
               ;  (ly:stencil-expr new-stil)
               ;  (interval-widen stil-x-ext (* scale-compensate-x -2))
               ;  (ly:stencil-extent new-stil Y))
               new-stil
               )))))
#})

%% default
{
  \arpeggioArrowUp
  <b d' f' b'>4\arpeggio

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

  \arpeggioNormal
  <b d' f' b'>\arpeggio
}


%% enlarged
my-scale = 2

{
  \arpeggioArrowUp
  \biggerArrow \my-scale
  <b d' f' b'>\arpeggio

  \arpeggioArrowDown
  \biggerArrow \my-scale
  <b d' f' b'>\arpeggio

  \arpeggioNormal
  \biggerArrow \my-scale
  <b d' f' b'>\arpeggio
}

Cheers,
  Harm

Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Paolo Prete-3
Thank you Thomas, now all is perfect and very useful

On Fri, Dec 6, 2019 at 12:05 PM Thomas Morley <[hidden email]> wrote:
Am Fr., 6. Dez. 2019 um 01:39 Uhr schrieb Paolo Pr <[hidden email]>:
>
> Thomas,
>
> thank you for your help. Unfortunately the snippet produces two errors that are visible with a size bigger than 1.2.
>
> Have a look at:   http://lilybin.com/y1t45z/1
>
> 1)   A collision between the arrow and the notehead that cannot be removed properly by overriding  Arpeggio.padding
> 2) A graphical mismatch between the arrow and the stem
>
> About 1), I can't find another property that can fix the issue.

Well, this is indeed a bug. We forgot to adjust X-extent for the
enlarged stencil.
Fixed in the code at the bottom of this mail.
Probably we need to adjust the stencil itself as well. Not sure,
though. In the code it's commented.

> About 2), Instead of the default symbol, I would use a simple triangle, so to avoid any mismatch. Which is the way to add it?

So far it's more due to the changed calculation:

I wrote:

>>                  (/
>>                   (- (interval-length stil-x-ext)
>>                      (interval-length red-arrow-x-ext))
>>                   2)

The lilybin-file reads:

                 (/
                  (- (interval-length stil-x-ext)
                     (interval-length red-arrow-x-ext))
                  10)

Which causes the problem. Go back to `2´ and all is fine.

If you want another stencil for the arrow-head then the method is
already demonstrated.
Get the stencil from the font (there are other arrows available) or
construct it. Using markup would be the most simple. Add it to the
default line. Move the arrow accordingly.
Take care of properties positions and X-extent.

Here the changed code, additionally I did some clean up, avoiding
multiple calculations of the same things adding comments etc.

biggerArrow =
#(define-music-function (scale)(number?)
"Returns an override for @code{Arpeggio.stencil}, with arrow-heads scaled by
@var{scale}"
#{
  \override Arpeggio.stencil =
  #(lambda (grob)
    (let* ((arp-dir (ly:grob-property grob 'arpeggio-direction)))
      ;; If 'arpeggio-direction is unset use default-stencil
      (if (null? arp-dir)
          (ly:arpeggio::print grob)
          (let* ((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))
                 (arrow (ly:stencil-scale arrow-head-stil scale scale))
                 (arrow-y-ext (ly:stencil-extent arrow Y))
                 (arrow-x-ext (ly:stencil-extent arrow X))
                 (arrow-width (interval-length arrow-x-ext))
                 (pos (ly:grob-property grob 'positions)))

            ;; 'positions modified to reflect the height of the arrow-head
            (ly:grob-set-property! grob 'positions
              (if (positive? arp-dir)
                  (cons (car pos) (- (cdr pos) arrow-width))
                  (cons (+ (car pos) arrow-width) (cdr pos))))

            ;; unset 'arpeggio-direction to get the default trill-line stencil
            (ly:grob-set-property! grob 'arpeggio-direction '())

            (let* ((stil (ly:arpeggio::print grob))
                   (stil-y-ext (ly:stencil-extent stil Y))
                   (stil-x-ext (ly:stencil-extent stil X))
                   (stil-width (interval-length stil-x-ext))
                   ;; A scaled arrow-head will be slightly off, find the value
                   ;; to compensate for x-axis, before adding it to the
                   ;; arpeggio-line
                   (scale-compensate-x (/ (- stil-width arrow-width) 2))
                   (new-stil
                     (ly:stencil-add
                       (ly:stencil-translate
                         arrow
                         (cons
                           scale-compensate-x
                           (if (negative? arp-dir)
                               ;; For a down pointing arrow, it's top will be at
                               ;; arpeggio-line-bottom, move by it's height to
                               ;; let the arrow-basis match with the line-bottom
                               (- (car stil-y-ext)
                                  (interval-length arrow-y-ext))
                               (cdr stil-y-ext))))
                       stil)))

               ;; We need to adjust 'X-extent to reflect the enlarged arrow,
               ;; in order to avoid spacing issues
               (ly:grob-set-property! grob 'X-extent
                 (interval-widen
                   (ly:arpeggio::width grob)
                   (* scale-compensate-x -2)))

               ;; Do we need to resize the stencil? For now commented
               ;(ly:make-stencil
               ;  (ly:stencil-expr new-stil)
               ;  (interval-widen stil-x-ext (* scale-compensate-x -2))
               ;  (ly:stencil-extent new-stil Y))
               new-stil
               )))))
#})

%% default
{
  \arpeggioArrowUp
  <b d' f' b'>4\arpeggio

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

  \arpeggioNormal
  <b d' f' b'>\arpeggio
}


%% enlarged
my-scale = 2

{
  \arpeggioArrowUp
  \biggerArrow \my-scale
  <b d' f' b'>\arpeggio

  \arpeggioArrowDown
  \biggerArrow \my-scale
  <b d' f' b'>\arpeggio

  \arpeggioNormal
  \biggerArrow \my-scale
  <b d' f' b'>\arpeggio
}

Cheers,
  Harm
Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Thomas Morley-2
Am Fr., 6. Dez. 2019 um 15:11 Uhr schrieb Paolo Pr <[hidden email]>:
>
> Thank you Thomas, now all is perfect and very useful

>> Here the changed code, additionally I did some clean up, avoiding
>> multiple calculations of the same things adding comments etc.
>>
>> biggerArrow =
>> #(define-music-function (scale)(number?)
[...]

Now in LSR
lsr.di.unimi.it/LSR/Item?u=1&id=1099

Cheers,
  Harm

Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Werner LEMBERG

> Now in LSR
> lsr.di.unimi.it/LSR/Item?u=1&id=1099

Thanks a lot!  Is there something that should be changed in LilyPond
to make it simpler to achieve this result?  If yes, please open an
issue.


    Werner

Reply | Threaded
Open this post in threaded view
|

Re: Size of the arpeggio's arrow

Thomas Morley-2
Am Sa., 7. Dez. 2019 um 10:38 Uhr schrieb Werner LEMBERG <[hidden email]>:

>
>
> > Now in LSR
> > lsr.di.unimi.it/LSR/Item?u=1&id=1099
>
> Thanks a lot!  Is there something that should be changed in LilyPond
> to make it simpler to achieve this result?  If yes, please open an
> issue.
>
>
>     Werner

Well, I've tagged it as the workaround it is...

Per default the stencil-procedure constructs the arpeggio using
(multiple) "scripts.arpeggio" and probably "scripts.arpeggio.arrow.1"
or "scripts.arpeggio.arrow.M1"
Ofcourse all with the same fontsize otherwise we'd risk optical
mismatches (and thus the new LSR-snippet fails if the arrow is scaled
up too much).

I don't see how we could do it simpler unless we'd provide different
sized arrows for arpeggio. Then we could think of how a suitable
user-interface to exchange those arrows might be coded.

Worth an issue?


Cheers,
  Harm