Re: Tweaking Hairpin shape

2018-02-11 Thread David Nalesnik
Hi Stefano,

On Sun, Feb 11, 2018 at 3:44 PM, Stefano Troncaro
 wrote:
> I managed to fix it. The problem was not with the calculation of the angle,
> it was with the translation of the angle to the offset that the function
> applies to the vertical placement of the end-points of the hairpins. It is
> correct now.
>
> I also got rid of the rotation of the stencil for the case where the
> straight end-points are not needed, the coordinates of the end-points for
> the different cases are all calculated now.
>
> As far as I can tell this is done. Finally!
>
> I got the alists working now. I can't reproduce the problems I had earlier,
> and the error message was weird and I don't remember it. But I guess that's
> not important anymore.
>
> I'm not sure I understood the following:
>>
>> But the spanner is cloned for each broken segment, so you aren't
>> actually comparing
>> with the initial bit.  Each new segment is simply drawn with a stencil
>> reflecting its
>> position within the whole.
>
>
> By reading the code that creates the hairpin stencils I got the idea that
> after line breaks are calculated, hairpins get broken into smaller hairpins
> that are related to each other. And when drawing the stencils, if these
> relationships are found, then they are drawn differently (they can start and
> end in 1/3rd or 2/3rds of the height depending on the situation). If what
> I'm saying is redundant with what you are saying, as I think it is, then I
> probably did a poor job of explaining myself in my last message.

When lines are broken the original Hairpin is copied to create a
Hairpin for each line.  The stencil function is applied separately to
each of these new Hairpin grobs.  It draws them with various openings
(or closings) based on the position of the spanner bounds it finds for
each: mid-line, start of line, end of line.  The spanner bound will
be, for example, a NonMusicalPaperColumn at a line break; the function
ly:item-break-dir applied to that bounding grob returns -1, 0, or
1--directions which have always left me confused.  The print function
simply looks at the bounds (and whether we have a crescendo or
decrescendo) to determine the shape, not at whether part of the
hairpin is the first piece, a middle piece, or the ending piece.

All this is super interesting, of course, but has no bearing on the
subject and I should have read what you wrote more carefully!

> English is
> not my native language and I struggle to be clear and concise with technical
> topics such as these. I apologize for the difficulties in communication that
> surely arise because of this.
>

No, your English is fine!  As I say, it's my reading comprehension
that leaves something to be desired :)

>
> I can now very comfortably get the hairpins I wanted, and I learned a lot of
> useful things in the process. I know I said it many times already but I'm
> truly grateful for your help! I never would have been able to reach a
> satisfying solution without it.
>

My pleasure!

David

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-11 Thread Stefano Troncaro
I managed to fix it. The problem was not with the calculation of the angle,
it was with the translation of the angle to the offset that the function
applies to the vertical placement of the end-points of the hairpins. It is
correct now.

I also got rid of the rotation of the stencil for the case where the
straight end-points are not needed, the coordinates of the end-points for
the different cases are all calculated now.

As far as I can tell this is done. Finally!

I got the alists working now. I can't reproduce the problems I had earlier,
and the error message was weird and I don't remember it. But I guess that's
not important anymore.

I'm not sure I understood the following:

> But the spanner is cloned for each broken segment, so you aren't
> actually comparing
> with the initial bit.  Each new segment is simply drawn with a stencil
> reflecting its
> position within the whole.
>

By reading the code that creates the hairpin stencils I got the idea that
after line breaks are calculated, hairpins get broken into smaller hairpins
that are related to each other. And when drawing the stencils, if these
relationships are found, then they are drawn differently (they can start
and end in 1/3rd or 2/3rds of the height depending on the situation). If
what I'm saying is redundant with what you are saying, as I think it is,
then I probably did a poor job of explaining myself in my last message.
English is not my native language and I struggle to be clear and concise
with technical topics such as these. I apologize for the difficulties in
communication that surely arise because of this.

But why rotate it in the first place?
>
The case where one of the hairpin lines follows the staff lines would have
been much more easier to manage like you propose, that's without question.
However, I wanted to implement the whole rotation thing as an interface so
that in the future I can create functions that find the correct angle for
use cases that arise. The "follow the staff line" case was a way to test
this approach, and it made me find errors in the math, so it payed off in
the end.

I can now very comfortably get the hairpins I wanted, and I learned a lot
of useful things in the process. I know I said it many times already but
I'm truly grateful for your help! I never would have been able to reach a
satisfying solution without it.


2018-02-10 15:02 GMT-03:00 David Nalesnik :

> Hi Stefano,
>
> On Sat, Feb 10, 2018 at 11:14 AM, Stefano Troncaro
>  wrote:
> > 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 '(.
>
> Not sure what you could have been doing wrong, but there are two ways you
> could
> define the alist
>
> (list (cons 'grob grob) (cons 'width width) (cons 'starth starth)
> (cons 'endh endh))
>
> or through quasi-quoting:
>
>  `((grob . ,grob) (width . ,width) (starth . ,starth) (endh . ,endh))
>
>
> > 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.
>
> But the spanner is cloned for each broken segment, so you aren't
> actually comparing
> with the initial bit.  Each new segment is simply drawn with a stencil
> reflecting its
> position within the whole.
>
> 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
> 

Re: Tweaking Hairpin shape

2018-02-10 Thread David Nalesnik
Hi Stefano,

On Sat, Feb 10, 2018 at 11:14 AM, Stefano Troncaro
 wrote:
> 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 '(.

Not sure what you could have been doing wrong, but there are two ways you could
define the alist

(list (cons 'grob grob) (cons 'width width) (cons 'starth starth)
(cons 'endh endh))

or through quasi-quoting:

 `((grob . ,grob) (width . ,width) (starth . ,starth) (endh . ,endh))


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

But the spanner is cloned for each broken segment, so you aren't
actually comparing
with the initial bit.  Each new segment is simply drawn with a stencil
reflecting its
position within the whole.

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?

I noticed this.  I'm not great with trig, so I'm not seeing right away
how to approach this
by rotating the hairpin.  But why rotate it in the first place?  You
simply want the top or
bottom line--you also need to consider if the hairpin is above the
staff--to be horizontal.  So
create a property 'follow-staff or something and, when set, draw a
straight line for one of the two lines
which are joined to create the hairpin, instead of two lines which
split the opening width.

>
> Thank you for all the help!!

You're very welcome!

David

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-10 Thread Stefano Troncaro
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 :

> Hi Stefano,
>
> On Thu, Feb 8, 2018 at 4:43 PM, Stefano Troncaro
>  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
>
\version "2.19.80"

#(define (proc-number-or-false? obj)
   (or (procedure? obj)
   (number? obj)
   (eq? obj #f)))

#(define (define-grob-property symbol type? description)
   (if (not (equal? (object-property symbol 'backend-doc) #f))
   (ly:error (_ "symbol ~S redefined") symbol))

   (set-object-property! symbol 'backend-type? type?)
   (set-object-property! symbol 'backend-doc description)
   symbol)

#(map
  (lambda (x)
(apply define-grob-property x))

  `(
 (circled-tip-radius ,number? "Radius for hairpin circled tip")
 (rotate ,proc-number-or-false? "Custom rotation: a number specifies angle in degrees, a procedure will receive the grob and return an angle, #f deactivates rotation")
 (straight-end ,boolean? "Straighten the end of the hairpin when it's rotated?")
 ))


#(define broken-neighbor
   (lambda (grob)
 (let* ((pieces (ly:spanner-broken-into (ly:grob-original grob)))
(me-list (member grob pieces)))
   (if (> (length me-list) 1)
   (cadr me-list)
   '()

#(define (interval-dir-set i val dir)
   (cond ((= dir LEFT) (set-car! i val))
 ((= dir RIGHT) (set-cdr! i val))
 (else (ly:error "dir must be LEFT or RIGHT"

#(define (other-dir dir) (- dir))

#(define hairpin::print-scheme
   (lambda (grob)
 (let ((grow-dir 

Re: Tweaking Hairpin shape

2018-02-08 Thread David Nalesnik
Hi Stefano,

On Thu, Feb 8, 2018 at 4:43 PM, Stefano Troncaro
 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
\version "2.19.80"

#(define (proc-number-or-false? obj)
   (or (procedure? obj)
   (number? obj)
   (eq? obj #f)))

#(define (define-grob-property symbol type? description)
   (if (not (equal? (object-property symbol 'backend-doc) #f))
   (ly:error (_ "symbol ~S redefined") symbol))

   (set-object-property! symbol 'backend-type? type?)
   (set-object-property! symbol 'backend-doc description)
   symbol)

#(map
  (lambda (x)
(apply define-grob-property x))

  `(
 (circled-tip-radius ,number? "Radius for hairpin circled tip")
 (rotate ,proc-number-or-false? "Custom rotation: a number specifies angle in degrees, a procedure will receive the grob and return an angle, #f deactivates rotation")
 (straight-end ,boolean? "Straighten the end of the hairpin when it's rotated?")
 ))


#(define broken-neighbor
   (lambda (grob)
 (let* ((pieces (ly:spanner-broken-into (ly:grob-original grob)))
(me-list (member grob pieces)))
   (if (> (length me-list) 1)
   (cadr me-list)
   '()

#(define (interval-dir-set i val dir)
   (cond ((= dir LEFT) (set-car! i val))
 ((= dir RIGHT) (set-cdr! i val))
 (else (ly:error "dir must be LEFT or RIGHT"

#(define (other-dir dir) (- dir))

#(define hairpin::print-scheme
   (lambda (grob)
 (let ((grow-dir (ly:grob-property grob 'grow-direction)))
   (if (not (ly:dir? grow-dir))
   (begin
(ly:grob-suicide! grob)
'()))

   (let* ((padding (ly:grob-property grob 'bound-padding 0.5))
  (bounds (cons (ly:spanner-bound grob LEFT)
(ly:spanner-bound grob RIGHT)))
  (broken (cons
   (not (= (ly:item-break-dir (car bounds)) CENTER))
   (not (= (ly:item-break-dir (cdr bounds)) CENTER)

 (if (cdr broken)
 (let ((next (broken-neighbor grob)))
   (if (ly:spanner? next)
   (begin
(ly:grob-property next 'after-line-breaking)
(set-cdr! broken (grob::is-live? next)))
   (set-cdr! broken #f

 (let* ((common
 (ly:grob-common-refpoint (car bounds) (cdr bounds) X))
(x-points (cons 0 0))
(circled-tip (ly:grob-property grob 'circled-tip))
(height (* (ly:grob-property grob 'height 0.2)
  (ly:staff-symbol-staff-space grob)))
(rad (ly:grob-property grob 'circled-tip-radius (* 0.525 height)))
(thick (* (ly:grob-property grob 'thickness 1.0)
 (ly:staff-symbol-line-thickness grob

   (define (inner dir)
 (let* ((b (interval-bound bounds dir))
(e (ly:generic-bound-extent b common)))
   (interval-dir-set
x-points (ly:grob-relative-coordinate b common X) dir)

   (if (interval-bound broken dir)
   (if (= dir LEFT)
   (interval-dir-set
x-points (interval-bound e (other-dir dir)) dir)
   (let* ((broken-bound-padding
   (ly:grob-property grob 'broken-bound-padding 0.0))
  (chp (ly:grob-object grob 'concurrent-hairpins)))
 (let loop ((i 0))
   (if (and (ly:grob-array? chp)
(< i (ly:grob-array-length chp)))
   (let ((span-elt (ly:grob-array-ref chp i)))
 (if (= (ly:item-break-dir (ly:spanner-bound span-elt RIGHT))
   

Re: Tweaking Hairpin shape

2018-02-08 Thread Stefano Troncaro
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.

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.

Besides that, I have yet to figure out how to make a rotated Hairpin with
the circled-tip placed in the right spot (when it's a decrescendo,
crescendos pose no problem that I've found).

I think everything else is working as intended, but I could be wrong. I
attached it in case anyone wants to look at it or test it out.

Of course, suggestions on how to improve it / optimize it are welcome!

2018-02-06 19:38 GMT-03:00 Thomas Morley :

> 2018-02-06 16:10 GMT+01:00 Werner LEMBERG :
> >
> >> Sure, I attached a few from here
> >> 
> >
> > Thanks, but in this score there is not a single heavily rotated
> > hairpin; I would say that the differences are not of any importance.
> >
> >> .
> >
> > Oh, and an orchestral score doesn't contain heavily rotated hairpins
> > by its very nature.  What I see here is very irregular.
> >
> >> Of course there are many more, in these and other scores.
> >
> > Hmm.  Here's a counterexample that contains `steep' hairpins
> > (cf. page 6 bottom, page 23 bottom, page 24 top, etc., etc.) – and the
> > ends are not vertically aligned.
> >
> >   https://imslp.org/wiki/Special:ReverseLookup/246876
> >
> > The exception, however, is a broken hairpin, page 30 – here I agree
> > that the continuation part should start (or end) vertically aligned.
> > Or may only `could' instead of `should', as for example page 38
> > demonstrates.
> >
> > On the other hand, it probably solely depends on the typesetter:
> > page 40 contains steep hairpins that are all aligned...
> >
> > My conclusion: It could be a useful feature to have the ends of
> > rotated hairpins vertically aligned.  However, I wouldn't like to have
> > this as the default.
> >
> > I'm CCing this e-mail to `bug-lilypond' so that this feature request
> > can be added to our issue database.
> >
> >
> > Werner
>
> I'm a little late to the party this evening...
>
> Though, vertically aligned Hairpins were already discussed (a little)
> during code review of Ferneyhough hairpins
> https://codereview.appspot.com/7615043
> but postponed.
> For an image see comment #2
> I'm pretty sure they could still be implemented. `elbowed-hairpin' has
> it's own limitations, though
>
> Cheers,
>   Harm
>
\version "2.19.80"

#(define (proc-number-or-false? obj)
   (or (procedure? obj)
   (number? obj)
   (eq? obj #f)))

#(define (define-grob-property symbol type? description)
   (if (not (equal? (object-property symbol 'backend-doc) #f))
   (ly:error (_ "symbol ~S redefined") symbol))

   (set-object-property! symbol 'backend-type? type?)
   (set-object-property! symbol 'backend-doc description)
   symbol)

#(map
  (lambda (x)
(apply define-grob-property x))

  `(
 (circled-tip-radius ,number? "Radius for hairpin circled tip")
 (rotate ,proc-number-or-false? "Custom rotation: a number specifies angle in degrees, a procedure will receive the grob and return an angle, #f deactivates rotation")
 (straight-end ,boolean? "Straighten the end of the hairpin when it's rotated?")
 ))


#(define broken-neighbor
   (lambda (grob)
 (let* ((pieces (ly:spanner-broken-into (ly:grob-original grob)))
(me-list (member grob pieces)))
   (if (> (length me-list) 1)
   (cadr me-list)
   '()

#(define (interval-dir-set i val dir)
   (cond ((= dir LEFT) (set-car! i val))
 ((= dir RIGHT) (set-cdr! i val))
 (else (ly:error "dir must be LEFT or RIGHT"

#(define (other-dir dir) (- dir))

#(define hairpin::print-scheme
   (lambda (grob)
 (let ((grow-dir (ly:grob-property grob 'grow-direction)))
   (if (not (ly:dir? grow-dir))
   (begin
(ly:grob-suicide! grob)
'()))
   
   (let* ((padding (ly:grob-property grob 'bound-padding 0.5))
  (bounds (cons (ly:spanner-bound grob LEFT)
(ly:spanner-bound grob RIGHT)))
  (broken (cons
   (not (= (ly:item-break-dir (car bounds)) CENTER))
   (not (= (ly:item-break-dir (cdr bounds)) CENTER)
 
 (if (cdr 

Re: Tweaking Hairpin shape

2018-02-06 Thread Thomas Morley
2018-02-06 16:10 GMT+01:00 Werner LEMBERG :
>
>> Sure, I attached a few from here
>> 
>
> Thanks, but in this score there is not a single heavily rotated
> hairpin; I would say that the differences are not of any importance.
>
>> .
>
> Oh, and an orchestral score doesn't contain heavily rotated hairpins
> by its very nature.  What I see here is very irregular.
>
>> Of course there are many more, in these and other scores.
>
> Hmm.  Here's a counterexample that contains `steep' hairpins
> (cf. page 6 bottom, page 23 bottom, page 24 top, etc., etc.) – and the
> ends are not vertically aligned.
>
>   https://imslp.org/wiki/Special:ReverseLookup/246876
>
> The exception, however, is a broken hairpin, page 30 – here I agree
> that the continuation part should start (or end) vertically aligned.
> Or may only `could' instead of `should', as for example page 38
> demonstrates.
>
> On the other hand, it probably solely depends on the typesetter:
> page 40 contains steep hairpins that are all aligned...
>
> My conclusion: It could be a useful feature to have the ends of
> rotated hairpins vertically aligned.  However, I wouldn't like to have
> this as the default.
>
> I'm CCing this e-mail to `bug-lilypond' so that this feature request
> can be added to our issue database.
>
>
> Werner

I'm a little late to the party this evening...

Though, vertically aligned Hairpins were already discussed (a little)
during code review of Ferneyhough hairpins
https://codereview.appspot.com/7615043
but postponed.
For an image see comment #2
I'm pretty sure they could still be implemented. `elbowed-hairpin' has
it's own limitations, though

Cheers,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-06 Thread Stefano Troncaro
@Werner

> My conclusion: It could be a useful feature to have the ends of
> rotated hairpins vertically aligned.  However, I wouldn't like to have
> this as the default.
>

My thoughts exactly. I did not intend to express that I wanted this as the
default, because I don't, only for a convenient option of doing this to
exist. Thank you for reviewing this and adding it to the database.

Also, thank you for bringing up the Ravel score. It is very interesting
that in the last two systems of page 4, on the last bar of each, one can
see the same rotated hairpin, one with the end-points vertically aligned
and the other without. This page makes a good visual comparison between the
two, I personally prefer the aligned one. Also, this highlights that use of
this resource was very inconsistent.

2018-02-06 12:10 GMT-03:00 Werner LEMBERG :

>
> > Sure, I attached a few from here
> > 
>
> Thanks, but in this score there is not a single heavily rotated
> hairpin; I would say that the differences are not of any importance.
>
> > .
>
> Oh, and an orchestral score doesn't contain heavily rotated hairpins
> by its very nature.  What I see here is very irregular.
>
> > Of course there are many more, in these and other scores.
>
> Hmm.  Here's a counterexample that contains `steep' hairpins
> (cf. page 6 bottom, page 23 bottom, page 24 top, etc., etc.) – and the
> ends are not vertically aligned.
>
>   https://imslp.org/wiki/Special:ReverseLookup/246876
>
> The exception, however, is a broken hairpin, page 30 – here I agree
> that the continuation part should start (or end) vertically aligned.
> Or may only `could' instead of `should', as for example page 38
> demonstrates.
>
> On the other hand, it probably solely depends on the typesetter:
> page 40 contains steep hairpins that are all aligned...
>
> My conclusion: It could be a useful feature to have the ends of
> rotated hairpins vertically aligned.  However, I wouldn't like to have
> this as the default.
>
> I'm CCing this e-mail to `bug-lilypond' so that this feature request
> can be added to our issue database.
>
>
> Werner
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-06 Thread Werner LEMBERG

> Sure, I attached a few from here
> 

Thanks, but in this score there is not a single heavily rotated
hairpin; I would say that the differences are not of any importance.

> .

Oh, and an orchestral score doesn't contain heavily rotated hairpins
by its very nature.  What I see here is very irregular.

> Of course there are many more, in these and other scores.

Hmm.  Here's a counterexample that contains `steep' hairpins
(cf. page 6 bottom, page 23 bottom, page 24 top, etc., etc.) – and the
ends are not vertically aligned.

  https://imslp.org/wiki/Special:ReverseLookup/246876

The exception, however, is a broken hairpin, page 30 – here I agree
that the continuation part should start (or end) vertically aligned.
Or may only `could' instead of `should', as for example page 38
demonstrates.

On the other hand, it probably solely depends on the typesetter:
page 40 contains steep hairpins that are all aligned...

My conclusion: It could be a useful feature to have the ends of
rotated hairpins vertically aligned.  However, I wouldn't like to have
this as the default.

I'm CCing this e-mail to `bug-lilypond' so that this feature request
can be added to our issue database.


Werner
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-06 Thread Stefano Troncaro
Sorry, my previous reply was rejected because of the attached images.
Werner, I hope that the links are sufficient.

-- Forwarded message --
From: Stefano Troncaro <stefanotronc...@gmail.com>
Date: 2018-02-06 11:05 GMT-03:00
Subject: Re: Tweaking Hairpin shape
To: Andrew Bernard <andrew.bern...@gmail.com>
Cc: lilypond-user Mailinglist <lilypond-user@gnu.org>


@Werner
Sure, I attached a few from here
<https://imslp.org/wiki/Special:ReverseLookup/23160> and here
<https://imslp.org/wiki/Special:ReverseLookup/23074>. Of course there are
many more, in these and other scores. In case I was not clear before, not
every rotated hairpin is like this. They are a quite natural possibility
when engraving by hand, not so much in digital scores. I think they have
their uses.

@Andrew
Thanks for your suggestion! I have not used PostScript but from what you
mention I gather it will be a very useful tool. I can picture many
scenarios where I would need it, so I will look into it.


2018-02-06 11:22 GMT-03:00 Stefano Troncaro <stefanotronc...@gmail.com>:

> Thank you David! I think I should be able to work something out from here,
> I'll post again when I have some kind of update.
>
> 2018-02-06 11:04 GMT-03:00 David Nalesnik <david.nales...@gmail.com>:
>
>> Hi Stefano,
>>
>>
>> On Mon, Feb 5, 2018 at 11:53 PM, Stefano Troncaro
>> <stefanotronc...@gmail.com> wrote:
>> > 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.
>>
>> At this point I think you would get the best results by rewriting
>> ly:hairpin::print from scratch so that it has the existing
>> functionality with your enhancements worked in.
>>
>> At some point I translated the function from C++ into Scheme for some
>> experimentation.  It's fairly direct.  I found a version of this where
>> I left the original C++ code inlined as comments
>> (add-shorten-pair.ly).
>>
>> I used this as a preliminary to adding 'shorten-pair directly into the
>> C++ code, and I don't remember if I made improvements to the codebase
>> along the way...
>>
>> Hopefully, you can make use of it!
>>
>> I also located a file which shows what you can do from scratch: here
>> adjusting the size of the circle in the circled tip (not with
>> shorten-pair here...)  FWIW.
>>
>> Hope this helps...
>>
>> David
>>
>
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-06 Thread Stefano Troncaro
Thank you David! I think I should be able to work something out from here,
I'll post again when I have some kind of update.

2018-02-06 11:04 GMT-03:00 David Nalesnik :

> Hi Stefano,
>
>
> On Mon, Feb 5, 2018 at 11:53 PM, Stefano Troncaro
>  wrote:
> > 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.
>
> At this point I think you would get the best results by rewriting
> ly:hairpin::print from scratch so that it has the existing
> functionality with your enhancements worked in.
>
> At some point I translated the function from C++ into Scheme for some
> experimentation.  It's fairly direct.  I found a version of this where
> I left the original C++ code inlined as comments
> (add-shorten-pair.ly).
>
> I used this as a preliminary to adding 'shorten-pair directly into the
> C++ code, and I don't remember if I made improvements to the codebase
> along the way...
>
> Hopefully, you can make use of it!
>
> I also located a file which shows what you can do from scratch: here
> adjusting the size of the circle in the circled tip (not with
> shorten-pair here...)  FWIW.
>
> Hope this helps...
>
> David
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-06 Thread David Nalesnik
Hi Stefano,


On Mon, Feb 5, 2018 at 11:53 PM, Stefano Troncaro
 wrote:
> 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.

At this point I think you would get the best results by rewriting
ly:hairpin::print from scratch so that it has the existing
functionality with your enhancements worked in.

At some point I translated the function from C++ into Scheme for some
experimentation.  It's fairly direct.  I found a version of this where
I left the original C++ code inlined as comments
(add-shorten-pair.ly).

I used this as a preliminary to adding 'shorten-pair directly into the
C++ code, and I don't remember if I made improvements to the codebase
along the way...

Hopefully, you can make use of it!

I also located a file which shows what you can do from scratch: here
adjusting the size of the circle in the circled tip (not with
shorten-pair here...)  FWIW.

Hope this helps...

David
\version "2.19.23"

#(define broken-right-neighbor
   (lambda (grob)
 (let* ((pieces (ly:spanner-broken-into (ly:grob-original grob)))
(me-list (member grob pieces)))
   (if (> (length me-list) 1)
   (cadr me-list)
   '()

#(define (interval-dir-set i val dir)
   (cond ((= dir LEFT) (set-car! i val))
 ((= dir RIGHT) (set-cdr! i val))
 (else (ly:error "dir must be LEFT or RIGHT"

#(define (other-dir dir) (- dir))

%{
;; C++ is from lily/hairpin.cc
;;
;; MAKE_SCHEME_CALLBACK (Hairpin, print, 1);
;; SCM
;; Hairpin::print (SCM smob)
;; {
;;   Spanner *me = unsmob (smob);
%}

#(define hairpin::print-scheme
   (lambda (grob)

;;   SCM s = me->get_property ("grow-direction");

 (let ((grow-dir (ly:grob-property grob 'grow-direction)))

;;   if (!is_direction (s))
;; {
;;   me->suicide ();
;;   return SCM_EOL;
;; }

   (if (not (ly:dir? grow-dir))
   (begin
(ly:grob-suicide! grob)
'())

;;   Direction grow_dir = to_dir (s);
;;   Real padding = robust_scm2double (me->get_property ("bound-padding"), 0.5);
;;
;;   Drul_array broken;
;;   Drul_array bounds;
;;   for (LEFT_and_RIGHT (d))
;; {
;;   bounds[d] = me->get_bound (d);
;;   broken[d] = bounds[d]->break_status_dir () != CENTER;
;; }

   (let* ((padding (ly:grob-property grob 'bound-padding 0.5))
  (bounds (cons (ly:spanner-bound grob LEFT)
(ly:spanner-bound grob RIGHT)))
  (broken (cons
   (not (= (ly:item-break-dir (car bounds)) CENTER))
   (not (= (ly:item-break-dir (cdr bounds)) CENTER)

;;   if (broken[RIGHT])
;; {
;;   Spanner *next = me->broken_neighbor (RIGHT);
;;   // Hairpin-parts suicide in after-line-breaking if they need not be drawn
;;   if (next)
;; {
;;   (void) next->get_property ("after-line-breaking");
;;   broken[RIGHT] = next->is_live ();
;; }
;;   else
;; broken[RIGHT] = false;
;; }

 (if (cdr broken)
 (let ((next (broken-right-neighbor grob)))
   (if (ly:spanner? next)
   (begin
(ly:grob-property next 

Re: Tweaking Hairpin shape

2018-02-05 Thread Andrew Bernard
Hi Stefano,

I face this sort of thing all the time in the new complexity scores that I
set. Despite the elegance you seek - and I fully understand the vertical
end point alignment you are wanting - sometimes it is easiest just to roll
over and draw the lines as a path, perhaps using Postscript, or path markup
commands. This may make more sense when you encounter things that are like
hairpins but not quite - the sort of graphics composers armed with pencils
like to draw, unwitting of the agonies it causes we engravers.

Andrew


On 6 February 2018 at 16:53, Stefano Troncaro 
wrote:

>
> 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.
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-05 Thread Werner LEMBERG

> I wanted to make it so that the two lines that form the hairpin
> would end in the same vertical line,

Please show a real-world example for that.  I can't remember having
ever seen this...


Werner

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-05 Thread Stefano Troncaro
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 :

> Hi Harm,
>
> On Sun, Feb 4, 2018 at 6:23 PM, Thomas Morley 
> 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
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-04 Thread David Nalesnik
Hi Harm,

On Sun, Feb 4, 2018 at 6:23 PM, Thomas Morley  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
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-04 Thread Thomas Morley
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.

Some inline remarks to your code.

2018-02-05 0:25 GMT+01:00 David Nalesnik :
> Hi Stefano,
>
> On Sun, Feb 4, 2018 at 4:09 PM, Stefano Troncaro
>  wrote:
>> Harm, I've been thinking about this, and perhaps you have an idea of how the
>> following can be achieved.
>>
>> A consequence of explicitly stating the degree in which the stencil has to
>> be rotated is that if anything changes the spacing of that system it's very
>> likely that the degree of rotation will have to be manually tweaked. I was
>> thinking on how to achieve an "automatic" solution. I imagine that this
>> could be done by establishing two points of reference. In this example any
>> two points running along the Beam would serve, although the ending points of
>> two of the Stems would work just as well.
>>
>> But all this assumes that every object has a distinct name/ID/whatever, like
>> a pointer to it which allows to recover information on it, or at least that
>> one can be given. Do you know if this is possible?
>>
>
> Within a callback for Hairpin.stencil, you can get to the Beam grob by
> following pointers from the spanner bounds of the Hairpin.  You can
> then calculate the Beam's slope and use that information to rotate the
> Hairpin stencil.
>
> \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))

Great:

> (bound
>  (find (lambda (b)
>  (grob::has-interface b 'note-column-interface))
>(list lb rb
>(if (ly:grob? bound)
>(let* ((stem (ly:grob-object bound 'stem))
>   (beam (ly:grob-object stem 'beam)))
>  (if (ly:grob? beam)
>  (let* ((X-pos (ly:grob-property beam 'X-positions))
> (Y-pos (ly:grob-property beam 'positions))
Using atan may return unexact values if the angle is close to zero, iirc.
I suggest to use ly:angle:
(ang
  (ly:angle
(- (cdr X-pos) (car X-pos))
(- (cdr Y-pos) (car Y-pos

> (ang (atan (- (cdr Y-pos) (car Y-pos))
>(- (cdr X-pos) (car X-pos)
>(ly:stencil-rotate

No need use PI then:
 stil ang CENTER CENTER)

> stil (* ang (/ 180 PI)) CENTER CENTER))
>  stil))
>stil
>
> {
>   \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'8[\< e' \break g' b']\!
> }
>
> Hope this gets you started...
>
> David

All the best,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-04 Thread David Nalesnik
Hi Stefano,

On Sun, Feb 4, 2018 at 4:09 PM, Stefano Troncaro
 wrote:
> Harm, I've been thinking about this, and perhaps you have an idea of how the
> following can be achieved.
>
> A consequence of explicitly stating the degree in which the stencil has to
> be rotated is that if anything changes the spacing of that system it's very
> likely that the degree of rotation will have to be manually tweaked. I was
> thinking on how to achieve an "automatic" solution. I imagine that this
> could be done by establishing two points of reference. In this example any
> two points running along the Beam would serve, although the ending points of
> two of the Stems would work just as well.
>
> But all this assumes that every object has a distinct name/ID/whatever, like
> a pointer to it which allows to recover information on it, or at least that
> one can be given. Do you know if this is possible?
>

Within a callback for Hairpin.stencil, you can get to the Beam grob by
following pointers from the spanner bounds of the Hairpin.  You can
then calculate the Beam's slope and use that information to rotate the
Hairpin stencil.

\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
   (if (ly:grob? bound)
   (let* ((stem (ly:grob-object bound 'stem))
  (beam (ly:grob-object stem 'beam)))
 (if (ly:grob? beam)
 (let* ((X-pos (ly:grob-property beam 'X-positions))
(Y-pos (ly:grob-property beam 'positions))
(ang (atan (- (cdr Y-pos) (car Y-pos))
   (- (cdr X-pos) (car X-pos)
   (ly:stencil-rotate
stil (* ang (/ 180 PI)) CENTER CENTER))
 stil))
   stil

{
  \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'8[\< e' \break g' b']\!
}

Hope this gets you started...

David

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-04 Thread Stefano Troncaro
Harm, I've been thinking about this, and perhaps you have an idea of how
the following can be achieved.

A consequence of explicitly stating the degree in which the stencil has to
be rotated is that if anything changes the spacing of that system it's very
likely that the degree of rotation will have to be manually tweaked. I was
thinking on how to achieve an "automatic" solution. I imagine that this
could be done by establishing two points of reference. In this example any
two points running along the Beam would serve, although the ending points
of two of the Stems would work just as well.

But all this assumes that every object has a distinct name/ID/whatever,
like a pointer to it which allows to recover information on it, or at least
that one can be given. Do you know if this is possible?

Another approach could be to override the before-line-breaking or
after-line-breaking property of the reference Stems with a function that
stores the coordinates with a specific name, that can later be recovered by
the function that rotates the Hairpin stencil. This sounds simpler than the
first idea, although I don't know if Lilypond's internal sequencing allows
for this to work properly.

I would love to hear your ideas on this.

Thanks again for being so helpful,
Stéfano.


2018-02-04 17:21 GMT-03:00 Thomas Morley :

> 2018-02-04 21:02 GMT+01:00 Kieren MacMillan  >:
> > Hi Harm,
> >
> >> See below.
> >
> > Once again, a wonderful solution/contribution.
> >
> >> 'rotation comes too late, use a stencil-override with ly:stencil-rotate
> instead.
> >
> > Is there any reason 'rotation can't come sooner for all grobs, so that
> skylines and spacing Do The Right Thing™?
>
>
> Well, I don't know.
> Also, I'm not sure, whether there are use cases out there for the
> current behaviour of 'rotation.
> And the NR states:
> "There are only a few situations where the rotation of layout objects is
> useful"
> http://lilypond.org/doc/v2.19/Documentation/notation/rotating-objects
>
> Cheers,
>   Harm
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-04 Thread Thomas Morley
2018-02-04 21:02 GMT+01:00 Kieren MacMillan :
> Hi Harm,
>
>> See below.
>
> Once again, a wonderful solution/contribution.
>
>> 'rotation comes too late, use a stencil-override with ly:stencil-rotate 
>> instead.
>
> Is there any reason 'rotation can't come sooner for all grobs, so that 
> skylines and spacing Do The Right Thing™?


Well, I don't know.
Also, I'm not sure, whether there are use cases out there for the
current behaviour of 'rotation.
And the NR states:
"There are only a few situations where the rotation of layout objects is useful"
http://lilypond.org/doc/v2.19/Documentation/notation/rotating-objects

Cheers,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-04 Thread Stefano Troncaro
Amazing, perfect solution! Thank you very much!

2018-02-04 17:02 GMT-03:00 Kieren MacMillan :

> Hi Harm,
>
> > See below.
>
> Once again, a wonderful solution/contribution.
>
> > 'rotation comes too late, use a stencil-override with ly:stencil-rotate
> instead.
>
> Is there any reason 'rotation can't come sooner for all grobs, so that
> skylines and spacing Do The Right Thing™?
>
> Thanks,
> Kieren.
> 
>
> Kieren MacMillan, composer
> ‣ website: www.kierenmacmillan.info
> ‣ email: i...@kierenmacmillan.info
>
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-04 Thread Kieren MacMillan
Hi Harm,

> See below.

Once again, a wonderful solution/contribution.

> 'rotation comes too late, use a stencil-override with ly:stencil-rotate 
> instead.

Is there any reason 'rotation can't come sooner for all grobs, so that skylines 
and spacing Do The Right Thing™?

Thanks,
Kieren.


Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: i...@kierenmacmillan.info


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-04 Thread Thomas Morley
2018-02-04 20:30 GMT+01:00 Stefano Troncaro :
> Thank you! This is a workable starting point. However, it raised a few
> questions.
>
> 1) I noticed that rotating the grob doesn't work well with automatic
> collision detection, since the grob skylines are still where they would be
> for the unrotated grob. See this example code and the attached images:
>>
>> \version "2.19.80"
>> \language "english"
>>
>> tweaks = {
>>   \once \override Hairpin.rotation = #'(9 0 0)
>>   %\once \override Hairpin.extra-offset = #'(0 . -1)
>> }
>>
>> \score {
>>   \new Staff \relative c' { \time 2/2 \tweaks d8[^\<(^"some really long
>> text here!" e f g a b c d]\!) |
>> 4\arpeggio  }
>>   \layout {
>> \context {
>>   \Score
>>   \override Hairpin.height = #0.5
>> }
>>   }
>> }
>
> This makes me hesitate for the same reason that using extra-offset does: I'd
> want to tweak the shape of the Hairpins and have Lilypond automatically work
> out the correct spacing between different grobs and staves. So, how can I
> make it so that the skylines are also updated when I rotate the grob? Or, if
> internally the grob is first placed and then rotated, how can I make it so
> that the rotation occurs before Lilypond calculates the positioning and
> spacing of grobs?

Don't use extra-offset to place things, unless you _want_ them overlap
or as very, very last resort.
Use 'shorten-pair to affect length of the Hairpin, working with
Hairpins for newer devel-versions, Thanks David Nalesnik, iirc.
'rotation comes too late, use a stencil-override with ly:stencil-rotate instead.
See below.

\version "2.19.80"

tweaks = {
  \once \override Hairpin.shorten-pair = #'(-2 . -2)
  \once \override Hairpin.stencil =
#(lambda (grob)
(ly:stencil-rotate (ly:hairpin::print grob) 9 0 0))
}

\score {
  \new Staff
\relative c' {
  \time 2/2
  \tweaks
  d8[^\<(^"some really long text here!" e f g a b c d]\!) |
  4\arpeggio
}
  \layout {
\context {
  \Score
  \override Hairpin.height = #0.5
}
  }
}

Cheers,
  Harm

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-04 Thread Stefano Troncaro
Thank you! This is a workable starting point. However, it raised a few
questions.

1) I noticed that rotating the grob doesn't work well with automatic
collision detection, since the grob skylines are still where they would be
for the unrotated grob. See this example code and the attached images:

> \version "2.19.80"\language "english"
> tweaks = {
>   \once \override Hairpin.rotation = #'(9 0 0)
>   %\once \override Hairpin.extra-offset = #'(0 . -1)}
> \score {
>   \new Staff \relative c' { \time 2/2 \tweaks d8[^\<(^"some really long text 
> here!" e f g a b c d]\!) |
> 4\arpeggio  }
>   \layout {
> \context {
>   \Score
>   \override Hairpin.height = #0.5
> }
>   }
> }
>
> This makes me hesitate for the same reason that using extra-offset does:
I'd want to tweak the shape of the Hairpins and have Lilypond automatically
work out the correct spacing between different grobs and staves. So, how
can I make it so that the skylines are also updated when I rotate the grob?
Or, if internally the grob is first placed and then rotated, how can I make
it so that the rotation occurs before Lilypond calculates the positioning
and spacing of grobs?

Lastly, regarding my need for a slight horizontal displacement:
2) I've tried modifying many properties, and so far Hairpin.X-offset and
Hairpin.extra-offset are the only ones that appear to do something close to
what I need. If I could somehow change the length of the Hairpin I could
use X-offset in conjunction with, for example, X-extent to effectively move
both the starting and ending point in the X axis. Using this approach would
have the advantage of conserving proper collision detection while being
easy to wrap inside a function. But I don't know why X-extent doesn't work
here.

Any ideas?

2018-02-04 13:59 GMT-03:00 Ben :

>
> On 2/4/2018 11:43 AM, Stefano Troncaro wrote:
>
> Hello everyone!
>
> I'm struggling with Hairpins this time. I can't find how to tweak the
> placement of it's starting and ending points.
>
> Suppose that in the following example I want to make the Hairpin follow
> the same slope as the Beam. Furthermore, I'd like the Hairpin to start a
> little bit to the right, abut 0.7 staff-spaces.
>
>> \version "2.19.80"\language "english"
>> \score {
>>   \new Staff \relative c' { \time 2/2 d8[^\<( e f g a b c d]\!) |
>> 4\arpeggio  }
>>   \layout {
>> \context {
>>   \Score
>>   \override Hairpin.height = #0.5
>> }
>>   }
>> }
>>
>>
>
> Hi,
>
> How is this for a start?
> (see attached)
>
> \version "2.19.80"
> \language "english"
>
> \score {
>
>   \new Staff \relative c' {
>   *  \override Hairpin.rotation = #'(12 0 0)*
> * \override Hairpin.extra-offset = #'(0 . -1.0)*
> \time 2/2 d8[^\<( e f g a b c d]\!) |
> 4\arpeggio  }
>   \layout {
> \context {
>   \Score
>   \override Hairpin.height = #0.5
> }
>   }
> }
>
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user
>
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-04 Thread Phil Holmes
For your first question:

http://lilypond.org/doc/v2.19/Documentation/notation/rotating-objects

should help.

--
Phil Holmes


  - Original Message - 
  From: Stefano Troncaro 
  To: lilypond-user Mailinglist 
  Sent: Sunday, February 04, 2018 4:43 PM
  Subject: Tweaking Hairpin shape


  Hello everyone!

  I'm struggling with Hairpins this time. I can't find how to tweak the 
placement of it's starting and ending points.


  Suppose that in the following example I want to make the Hairpin follow the 
same slope as the Beam. Furthermore, I'd like the Hairpin to start a little bit 
to the right, abut 0.7 staff-spaces.

\version "2.19.80"
\language "english"

\score {
  \new Staff \relative c' { \time 2/2 d8[^\<( e f g a b c d]\!) | 
4\arpeggio  }
  \layout {
\context {
  \Score
  \override Hairpin.height = #0.5
}
  }
}I thought it'd be as easy as moving the starting point, but I've searched 
through the Internals Reference and can't find what I'm supposed to 
tweak/override to achieve this.


  Any help will be greatly appreciated!

  Stéfano.



--


  ___
  lilypond-user mailing list
  lilypond-user@gnu.org
  https://lists.gnu.org/mailman/listinfo/lilypond-user






___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Tweaking Hairpin shape

2018-02-04 Thread Ben


On 2/4/2018 11:43 AM, Stefano Troncaro wrote:

Hello everyone!

I'm struggling with Hairpins this time. I can't find how to tweak the 
placement of it's starting and ending points.


Suppose that in the following example I want to make the Hairpin 
follow the same slope as the Beam. Furthermore, I'd like the Hairpin 
to start a little bit to the right, abut 0.7 staff-spaces.


\version  "2.19.80" \language  "english" \score  { \new  Staff  \relative  c'{ 
 \time  2/2  d8[^\<(  e f g a b c d]\!)  |
 4\arpeggio } \layout  { \context  { 
\Score \override  Hairpin.height  = #0.5 } } }




Hi,

How is this for a start?
(see attached)

    \version "2.19.80"
    \language "english"

    \score {

  \new Staff \relative c' {
*  \override Hairpin.rotation = #'(12 0 0)**
** \override Hairpin.extra-offset = #'(0 . -1.0)*
    \time 2/2 d8[^\<( e f g a b c d]\!) |
    4\arpeggio  }
  \layout {
    \context {
  \Score
  \override Hairpin.height = #0.5
    }
  }
    }
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user