bug-lilypond
[Top][All Lists]
Advanced

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

Re: Tweaking Hairpin shape


From: Stefano Troncaro
Subject: Re: Tweaking Hairpin shape
Date: Sat, 10 Feb 2018 14:14:05 -0300

Hi David, thank you for your suggestions, this is almost done!

I decided to pass an alist to the function instead of changing the amount
of arguments based on the procedure name, mainly because if I write more
angle functions in the future I want to be able to do so without having to
temper with the stencil definition. That is however a useful idea that I
would have never thought about, and I may find it useful in the future.

I have a few doubts if you don't mind.

1) At first I couldn't make the alist approach work because for some reason
I can't define one in a let or let* block. Do you know why? I googled and I
couldn't find an explanation.

2) Is there a way to define an alist different than a succession of acons?
I thought I would be able to create it with a syntax like '((k1 . v1) (k2 .
v2) ... etc) but in the end I had to settle for (acons k1 v1 (acons k2 v2
... (acons kn vn '()))).

3) I made the following function to make it so that the upper line of the
hairpin runs parallel with the staff lines. It does so by finding the angle
that is formed between the "zero-point" of the hairpin (the point where it
begins to open) and the ending point of the higher hairpin line, that is in
(width, height). The function takes into account that the lines of hairpins
that go through a system break have different starting and ending heights,
this is called "adjusted height" here. With all this in mind, the function
finds the angle of the upper line of the hairpin, and returns the negative
of that angle, which ideally would result in that angle being 0 degrees,
making it so that the upper line is parallel to the staff. But the end
result is slightly off (see image). I don't know if the math is wrong or if
this problem arises from rounding differences. If it is the later I may
need to formulate another approach entirely. Any insight on this?

> #(define hairpin-upper-with-staff
>    (lambda (prop-alist)
>      (let* ((starth (assq-ref prop-alist 'starth))
>             (endh (assq-ref prop-alist 'endh))
>             (width (assq-ref prop-alist 'width))
>             (adj-hgt (- endh starth))
>             (def-ang (ly:angle width adj-hgt)) )
>        (- def-ang))))
>
>
Thank you for all the help!!

2018-02-08 21:50 GMT-03:00 David Nalesnik <address@hidden>:

> Hi Stefano,
>
> On Thu, Feb 8, 2018 at 4:43 PM, Stefano Troncaro
> <address@hidden> wrote:
> > Hello again!
> >
> > I managed to modify David's translation of ly:hairpin::print to have it
> use
> > two properties, Hairpin.rotate and Hairpin.straight-end, to achieve
> almost
> > all the results I wanted.
>
> Glad you got some use out of this!  I like the look of the
> straight-edged hairpins.
>
> >
> > The idea is that Hairpin.rotate can be either a numerical value,
> > representing the angle of rotation, or a procedure that returns the
> angle of
> > rotation. In one of the examples I used the function discussed earlier in
> > this thread to have it automatically detect the angle of a beam.
> However, I
> > can't manage to make this idea work when the procedure given to
> > Hairpin.rotate requires more than one variable. This is very inconvenient
> > because for some cases the procedure would need to calculate again a lot
> of
> > things that are already calculated in the process of making the stencil.
>
> First of all, calling ly:grob-property calls any procedure the
> property is set to.  The function ly:grob-property-data won't.
>
> I don't know of any way in Scheme to overload functions or to count
> arguments.  If you name your function, however, you can use
> procedure-name.  (See the attached.)
>
> HTH,
> David
>

Attachment: rotated hairpins.ly
Description: Text Data

Attachment: math-slightly-off.png
Description: PNG image


reply via email to

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