Re: Controlling hairpin length - revisited!

2017-01-07 Thread David Nalesnik
On Tue, Oct 11, 2016 at 10:28 AM, David Nalesnik
 wrote:
> Hi Kieren,
>
> On Tue, Oct 11, 2016 at 9:51 AM, Kieren MacMillan
>  wrote:
>> Hi David,
>>
>>> Further down in that thread is an implementation of shorten-pair with
>>> hairpins: 
>>> http://lists.gnu.org/archive/html/lilypond-user/2016-06/msg00277.html
>>
>> The $1,000,000 Question: Why isn’t this in the distro?  =)
>
> I think the interaction between this and other properties has to be
> nailed down.  I'm not sure if it behaves "as expected" in conjunction
> with whatever other property affects endpoints (to-barline,
> bound-padding).
>
> I'd welcome testing.
>
> Also, there's the issue of programming language.  Should this
> enhancement be added to the C++ original--easy enough-- or should the
> distro ly:hairpin::print be replaced by a Scheme version?
>
> I'd like to see the stencil function in Scheme, because it would then
> be very convenient for users to adapt it to their needs.
>
> A drawback would be speed, but would that even be noticeable?
>


Patch here: https://sourceforge.net/p/testlilyissues/issues/5029/

Testing welcome!!

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


Re: Controlling hairpin length - revisited!

2016-10-20 Thread David Sumbler
On Fri, 2016-10-14 at 12:07 +0200, Thomas Morley wrote:
> Hi David:
> 
> 2016-10-11 15:51 GMT+02:00 David Sumbler :
> > 
> > The reasons for the long gap were (a) moving house in February and,
> > more importantly (b) feeling very discouraged by the apparent
> > unpredictability of hairpin lengths in Lilypond, despite all Harm's
> > valiant efforts.
> sorry for not being more helpful :(
> 
> 
> 2016-10-14 10:44 GMT+02:00 David Sumbler :
> > 
> > On Thu, 2016-10-13 at 23:54 +0200, Simon Albrecht wrote:
> > > 
> > > On 13.10.2016 14:41, David Sumbler wrote:
> > > > 
> > > > 
> > > > On Wed, 2016-10-12 at 14:10 -0400, Kieren MacMillan wrote:
> > > > > 
> > > > > 
> > > > > Hi David,
> > > > > 
> > > > > > 
> > > > > > 
> > > > > > But I realise that often what I need in order to get
> > > > > > satisfactory
> > > > > > hairpins is more space between the note heads, and simply
> > > > > > moving
> > > > > > the
> > > > > > ends of the hairpin does not reposition the relevant notes.
> > > > > Have you tried adjusting the minimum-length?
> > > > > 
> > > > > %%%  SNIPPET BEGINS
> > > > > \version "2.18.2"
> > > > > \language "english"
> > > > > 
> > > > > after =
> > > > > #(define-music-function (parser location t e m)
> > > > >   (ly:duration? ly:music? ly:music?)
> > > > >   #{
> > > > >   \context Bottom <<
> > > > >   #m
> > > > >   { \skip $t <> -\tweak extra-spacing-width
> > > > > #empty-
> > > > > interval $e }
> > > > >   >>
> > > > >   #})
> > > > > 
> > > > > testing = \relative e'' {
> > > > >    \override Hairpin.minimum-length = #5
> > > > >    e8 cs ds d \after 4 \> \after 4 \mf cs2\< ~ cs4 d8(\p cs)
> > > > > }
> > > > > 
> > > > > \score { \testing }
> > > > > %%%  SNIPPET ENDS
> > > > > 
> > > > > Hope that helps!
> > > > > Kieren.
> > > > Thanks, that's brilliant.  With this and Hairpin.shorten-pair I
> > > > should
> > > > be able to solve most or all of the problems I often find with
> > > > hairpins.
> > > > 
> > > > I have read all the material in the list archive relating to
> > > > this
> > > > function.
> > > Which function? \after?
> > Yes
> > 
> > > 
> > > after =
> > > %% create a music function with three arguments and assign it to
> > > the
> > > variable `after`
> > > #(define-music-function (parser location t e m)
> > > ;; give the types of the three arguments as predicate
> > > procedures
> > > (ly:duration? ly:music? ly:music?)
> > > ;; have the expression in #{#} evaluated by the LilyPond
> > > parser
> > > #{
> > >   %% Bottom is a kind of alias usually referring to Voice.
> > >   %% In this case, it’s there to prevent creating new Voices,
> > >   %% so the simultaneous music <<>> remains in one Voice.
> > >   \context Bottom <<
> > > %% first expression in the simultaneous music: the last
> > > argument
> > > passed to the function
> > > #m
> > > 
> > > %% second expression:
> > > %% \skip $t creates a skip of the duration given as first
> > > argument of the function
> > > %% <> is an empty chord with no duration
> > > %% the tweak prevents the spacing to be distorted by the
> > > inserted item $e
> > > %% empty-interval is defined in scm/lily-library.scm as
> > > #'(+inf.0 . -inf.0),
> > > %% i.e. actually an infinitely small interval. Maybe #'(0
> > > .
> > > 0)
> > > would work just as well,
> > > %% but it might also cause errors or unwanted behaviour.
> > > { \skip $t <> -\tweak extra-spacing-width #empty-interval 
> > > $e
> > > }
> > >   >>
> > > #})
> > > 
> > > HTH, Simon
> > Thank you - that is very helpful, and most of it is clear to me
> > now.
> > 
> > If I could bother you a bit further...
> > 
> > We have
> > #(define-music-function (parser location t e m)
> > 
> > In my file, I have at one point
> > \after 4 \> cs2\< ~ cs4
> > 
> > Clearly the value of t is 4 (a crotchet or quarter-note length);
> > e is \> (a hairpin);
> > m is cs2; or probably cs2\< (since the crescendo hairpin has to be
> > placed before the other dynamics).  I'm not quite sure what is
> > considered a single item of music.  What is the value of m here?
> > 
> > Looking at the function code, it seems that the music items are
> > processed in reverse order (which is what one would expect), i.e.
> > item
> > m is processed, then the additional item e, which is placed
> > later.  So
> > far, so good.
> > 
> > What I actually have at one point in the file is
> > \after 4 \mf \after 4 \> cs2\< ~ cs4
> > 
> > At the first call of the function, t has the value 4, but I'm a bit
> > unclear about how the rest is parsed.  What are the values of e and
> > m
> > in this case?
> > 
> > I imagine that the music items are processed in reverse order here
> > too,
> > i.e. cs2, then the diminuendo hairpin, then the mf mark.  By
> > experimenting I find that it doesn't make any practical 

Re: Controlling hairpin length - revisited!

2016-10-14 Thread Thomas Morley
Hi David:

2016-10-11 15:51 GMT+02:00 David Sumbler :
> The reasons for the long gap were (a) moving house in February and,
> more importantly (b) feeling very discouraged by the apparent
> unpredictability of hairpin lengths in Lilypond, despite all Harm's
> valiant efforts.

sorry for not being more helpful :(


2016-10-14 10:44 GMT+02:00 David Sumbler :
> On Thu, 2016-10-13 at 23:54 +0200, Simon Albrecht wrote:
>> On 13.10.2016 14:41, David Sumbler wrote:
>> >
>> > On Wed, 2016-10-12 at 14:10 -0400, Kieren MacMillan wrote:
>> > >
>> > > Hi David,
>> > >
>> > > >
>> > > > But I realise that often what I need in order to get
>> > > > satisfactory
>> > > > hairpins is more space between the note heads, and simply
>> > > > moving
>> > > > the
>> > > > ends of the hairpin does not reposition the relevant notes.
>> > > Have you tried adjusting the minimum-length?
>> > >
>> > > %%%  SNIPPET BEGINS
>> > > \version "2.18.2"
>> > > \language "english"
>> > >
>> > > after =
>> > > #(define-music-function (parser location t e m)
>> > >   (ly:duration? ly:music? ly:music?)
>> > >   #{
>> > >   \context Bottom <<
>> > >   #m
>> > >   { \skip $t <> -\tweak extra-spacing-width #empty-
>> > > interval $e }
>> > >   >>
>> > >   #})
>> > >
>> > > testing = \relative e'' {
>> > >\override Hairpin.minimum-length = #5
>> > >e8 cs ds d \after 4 \> \after 4 \mf cs2\< ~ cs4 d8(\p cs)
>> > > }
>> > >
>> > > \score { \testing }
>> > > %%%  SNIPPET ENDS
>> > >
>> > > Hope that helps!
>> > > Kieren.
>> > Thanks, that's brilliant.  With this and Hairpin.shorten-pair I
>> > should
>> > be able to solve most or all of the problems I often find with
>> > hairpins.
>> >
>> > I have read all the material in the list archive relating to this
>> > function.
>> Which function? \after?
>
> Yes
>
>> after =
>> %% create a music function with three arguments and assign it to the
>> variable `after`
>> #(define-music-function (parser location t e m)
>> ;; give the types of the three arguments as predicate procedures
>> (ly:duration? ly:music? ly:music?)
>> ;; have the expression in #{#} evaluated by the LilyPond parser
>> #{
>>   %% Bottom is a kind of alias usually referring to Voice.
>>   %% In this case, it’s there to prevent creating new Voices,
>>   %% so the simultaneous music <<>> remains in one Voice.
>>   \context Bottom <<
>> %% first expression in the simultaneous music: the last
>> argument
>> passed to the function
>> #m
>>
>> %% second expression:
>> %% \skip $t creates a skip of the duration given as first
>> argument of the function
>> %% <> is an empty chord with no duration
>> %% the tweak prevents the spacing to be distorted by the
>> inserted item $e
>> %% empty-interval is defined in scm/lily-library.scm as
>> #'(+inf.0 . -inf.0),
>> %% i.e. actually an infinitely small interval. Maybe #'(0 .
>> 0)
>> would work just as well,
>> %% but it might also cause errors or unwanted behaviour.
>> { \skip $t <> -\tweak extra-spacing-width #empty-interval $e
>> }
>>   >>
>> #})
>>
>> HTH, Simon
>
> Thank you - that is very helpful, and most of it is clear to me now.
>
> If I could bother you a bit further...
>
> We have
> #(define-music-function (parser location t e m)
>
> In my file, I have at one point
> \after 4 \> cs2\< ~ cs4
>
> Clearly the value of t is 4 (a crotchet or quarter-note length);
> e is \> (a hairpin);
> m is cs2; or probably cs2\< (since the crescendo hairpin has to be
> placed before the other dynamics).  I'm not quite sure what is
> considered a single item of music.  What is the value of m here?
>
> Looking at the function code, it seems that the music items are
> processed in reverse order (which is what one would expect), i.e. item
> m is processed, then the additional item e, which is placed later.  So
> far, so good.
>
> What I actually have at one point in the file is
> \after 4 \mf \after 4 \> cs2\< ~ cs4
>
> At the first call of the function, t has the value 4, but I'm a bit
> unclear about how the rest is parsed.  What are the values of e and m
> in this case?
>
> I imagine that the music items are processed in reverse order here too,
> i.e. cs2, then the diminuendo hairpin, then the mf mark.  By
> experimenting I find that it doesn't make any practical difference
> whether I put the mf first and the hairpin second or vice versa.  But
> it would be nice to know just what is going on here.
>
> David

I always let things display to understand things better. In this case
you could do:

\version "2.19.48"

\language "english"

#(define counter 0)

after =
#(define-music-function (parser location t e m)
 (ly:duration? ly:music? ly:music?)

(set! counter (1+ counter))
(display "\n%%\n")
(format #t  "the function ran ~a. time" counter)
(display 

Re: Controlling hairpin length - revisited!

2016-10-14 Thread David Sumbler
On Thu, 2016-10-13 at 23:54 +0200, Simon Albrecht wrote:
> On 13.10.2016 14:41, David Sumbler wrote:
> > 
> > On Wed, 2016-10-12 at 14:10 -0400, Kieren MacMillan wrote:
> > > 
> > > Hi David,
> > > 
> > > > 
> > > > But I realise that often what I need in order to get
> > > > satisfactory
> > > > hairpins is more space between the note heads, and simply
> > > > moving
> > > > the
> > > > ends of the hairpin does not reposition the relevant notes.
> > > Have you tried adjusting the minimum-length?
> > > 
> > > %%%  SNIPPET BEGINS
> > > \version "2.18.2"
> > > \language "english"
> > > 
> > > after =
> > > #(define-music-function (parser location t e m)
> > >   (ly:duration? ly:music? ly:music?)
> > >   #{
> > >   \context Bottom <<
> > >   #m
> > >   { \skip $t <> -\tweak extra-spacing-width #empty-
> > > interval $e }
> > >   >>
> > >   #})
> > > 
> > > testing = \relative e'' {
> > >    \override Hairpin.minimum-length = #5
> > >    e8 cs ds d \after 4 \> \after 4 \mf cs2\< ~ cs4 d8(\p cs)
> > > }
> > > 
> > > \score { \testing }
> > > %%%  SNIPPET ENDS
> > > 
> > > Hope that helps!
> > > Kieren.
> > Thanks, that's brilliant.  With this and Hairpin.shorten-pair I
> > should
> > be able to solve most or all of the problems I often find with
> > hairpins.
> > 
> > I have read all the material in the list archive relating to this
> > function.
> Which function? \after?

Yes

> after =
> %% create a music function with three arguments and assign it to the 
> variable `after`
> #(define-music-function (parser location t e m)
> ;; give the types of the three arguments as predicate procedures
> (ly:duration? ly:music? ly:music?)
> ;; have the expression in #{#} evaluated by the LilyPond parser
> #{
>   %% Bottom is a kind of alias usually referring to Voice.
>   %% In this case, it’s there to prevent creating new Voices,
>   %% so the simultaneous music <<>> remains in one Voice.
>   \context Bottom <<
> %% first expression in the simultaneous music: the last
> argument 
> passed to the function
> #m
> 
> %% second expression:
> %% \skip $t creates a skip of the duration given as first 
> argument of the function
> %% <> is an empty chord with no duration
> %% the tweak prevents the spacing to be distorted by the 
> inserted item $e
> %% empty-interval is defined in scm/lily-library.scm as 
> #'(+inf.0 . -inf.0),
> %% i.e. actually an infinitely small interval. Maybe #'(0 .
> 0) 
> would work just as well,
> %% but it might also cause errors or unwanted behaviour.
> { \skip $t <> -\tweak extra-spacing-width #empty-interval $e
> }
>   >>
> #})
> 
> HTH, Simon

Thank you - that is very helpful, and most of it is clear to me now.

If I could bother you a bit further...

We have
#(define-music-function (parser location t e m)

In my file, I have at one point
\after 4 \> cs2\< ~ cs4

Clearly the value of t is 4 (a crotchet or quarter-note length);
e is \> (a hairpin);
m is cs2; or probably cs2\< (since the crescendo hairpin has to be
placed before the other dynamics).  I'm not quite sure what is
considered a single item of music.  What is the value of m here?

Looking at the function code, it seems that the music items are
processed in reverse order (which is what one would expect), i.e. item
m is processed, then the additional item e, which is placed later.  So
far, so good.

What I actually have at one point in the file is
\after 4 \mf \after 4 \> cs2\< ~ cs4

At the first call of the function, t has the value 4, but I'm a bit
unclear about how the rest is parsed.  What are the values of e and m
in this case?

I imagine that the music items are processed in reverse order here too,
i.e. cs2, then the diminuendo hairpin, then the mf mark.  By
experimenting I find that it doesn't make any practical difference
whether I put the mf first and the hairpin second or vice versa.  But
it would be nice to know just what is going on here.

David

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


Re: Controlling hairpin length - revisited!

2016-10-13 Thread Simon Albrecht

On 13.10.2016 14:41, David Sumbler wrote:

On Wed, 2016-10-12 at 14:10 -0400, Kieren MacMillan wrote:

Hi David,


But I realise that often what I need in order to get satisfactory
hairpins is more space between the note heads, and simply moving
the
ends of the hairpin does not reposition the relevant notes.

Have you tried adjusting the minimum-length?

%%%  SNIPPET BEGINS
\version "2.18.2"
\language "english"

after =
#(define-music-function (parser location t e m)
  (ly:duration? ly:music? ly:music?)
  #{
  \context Bottom <<
  #m
  { \skip $t <> -\tweak extra-spacing-width #empty-
interval $e }
  >>
  #})

testing = \relative e'' {
   \override Hairpin.minimum-length = #5
   e8 cs ds d \after 4 \> \after 4 \mf cs2\< ~ cs4 d8(\p cs)
}

\score { \testing }
%%%  SNIPPET ENDS

Hope that helps!
Kieren.

Thanks, that's brilliant.  With this and Hairpin.shorten-pair I should
be able to solve most or all of the problems I often find with
hairpins.

I have read all the material in the list archive relating to this
function.

Which function? \after?

after =
%% create a music function with three arguments and assign it to the 
variable `after`

#(define-music-function (parser location t e m)
   ;; give the types of the three arguments as predicate procedures
   (ly:duration? ly:music? ly:music?)
   ;; have the expression in #{#} evaluated by the LilyPond parser
   #{
 %% Bottom is a kind of alias usually referring to Voice.
 %% In this case, it’s there to prevent creating new Voices,
 %% so the simultaneous music <<>> remains in one Voice.
 \context Bottom <<
   %% first expression in the simultaneous music: the last argument 
passed to the function

   #m

   %% second expression:
   %% \skip $t creates a skip of the duration given as first 
argument of the function

   %% <> is an empty chord with no duration
   %% the tweak prevents the spacing to be distorted by the 
inserted item $e
   %% empty-interval is defined in scm/lily-library.scm as 
#'(+inf.0 . -inf.0),
   %% i.e. actually an infinitely small interval. Maybe #'(0 . 0) 
would work just as well,

   %% but it might also cause errors or unwanted behaviour.
   { \skip $t <> -\tweak extra-spacing-width #empty-interval $e }
 >>
   #})

HTH, Simon

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


Re: Controlling hairpin length - revisited!

2016-10-13 Thread David Sumbler
On Wed, 2016-10-12 at 14:10 -0400, Kieren MacMillan wrote:
> Hi David,
> 
> > 
> > But I realise that often what I need in order to get satisfactory
> > hairpins is more space between the note heads, and simply moving
> > the
> > ends of the hairpin does not reposition the relevant notes.
> Have you tried adjusting the minimum-length?
> 
> %%%  SNIPPET BEGINS
> \version "2.18.2"
> \language "english"
> 
> after =
> #(define-music-function (parser location t e m)
>  (ly:duration? ly:music? ly:music?)
>  #{
>  \context Bottom <<
>  #m
>  { \skip $t <> -\tweak extra-spacing-width #empty-
> interval $e }
>  >>
>  #})
> 
> testing = \relative e'' {
>   \override Hairpin.minimum-length = #5
>   e8 cs ds d \after 4 \> \after 4 \mf cs2\< ~ cs4 d8(\p cs)
> }
> 
> \score { \testing }
> %%%  SNIPPET ENDS
> 
> Hope that helps!
> Kieren.

Thanks, that's brilliant.  With this and Hairpin.shorten-pair I should
be able to solve most or all of the problems I often find with
hairpins.

I have read all the material in the list archive relating to this
function.  Even so I don't really understand how it works.  I have a
reasonable understanding of basic Scheme, but much less of the internal
working of Lilypond and how Lilypond and Scheme interract (and yes, I
have read the Extending manual more than once).  Still, I think I
understand how to use the function, which is the main thing.

If anyone has the patience to explain the workings of the function I'd
be very interested. If not, I shan't blame you!

David

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


Re: Controlling hairpin length - revisited!

2016-10-12 Thread Kieren MacMillan
Hi David,

> But I realise that often what I need in order to get satisfactory
> hairpins is more space between the note heads, and simply moving the
> ends of the hairpin does not reposition the relevant notes.

Have you tried adjusting the minimum-length?

%%%  SNIPPET BEGINS
\version "2.18.2"
\language "english"

after =
#(define-music-function (parser location t e m)
 (ly:duration? ly:music? ly:music?)
 #{
 \context Bottom <<
 #m
 { \skip $t <> -\tweak extra-spacing-width #empty-interval $e }
 >>
 #})

testing = \relative e'' {
  \override Hairpin.minimum-length = #5
  e8 cs ds d \after 4 \> \after 4 \mf cs2\< ~ cs4 d8(\p cs)
}

\score { \testing }
%%%  SNIPPET ENDS

Hope that helps!
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: Controlling hairpin length - revisited!

2016-10-12 Thread David Sumbler
Thanks for this and other replies to my original query.  The routine
works well.

It does what it says on the can - moving the ends of the hairpin - and
that will be very useful.

But I realise that often what I need in order to get satisfactory
hairpins is more space between the note heads, and simply moving the
ends of the hairpin does not reposition the relevant notes.

One example is where I want a crescendo, mf and decrescendo on a single
minim (in a very slow tempo!)  I have tried using spacer rests, thus:

e8 cs ds d << { cs2 ~ cs4 d8( cs) } { s4\< s2\mf\> s4\p } >> |

but it doesn't give enough space for the crescendo hairpin.  Replacing
's4\<' with 's8\< s8' makes no noticeable difference.

As an experiment I have also tried using  '<>4\<' and 'r4\<' (thinking
perhaps I could then make the rests invisible), but neither of these
works.  '<>4\<' produces "two simultaneous span-dynamic events" errors
which I don't get with the spacer rests version, for reasons I can't
fathom; also the output shows mf followed by a crescendo for some
mysterious reason.  'r4\<' gives errors with trying to put rests and
note-heads on the same stem, and also strange unterminated tie errors.

What is the neatest method of simply moving the right-hand note further
to the right to give more space for the hairpins and the mf?
 Everything following the second note needs to be similarly displaced,
of course.

David


On Tue, 2016-10-11 at 09:42 -0500, David Nalesnik wrote:
> Hi,
> 
> 
> On Tue, Oct 11, 2016 at 9:07 AM, tisimst 
> wrote:
> > 
> > David,
> > 
> > On Tue, Oct 11, 2016 at 8:01 AM, Kieren MacMillan [via Lilypond]
> > <[hidden
> > email]> wrote:
> > > 
> > > 
> > > Hi David,
> > > 
> > > > 
> > > > Just so that I have as many weapons as possible at my disposal,
> > > > are
> > > > there any other parameters which might directly affect the
> > > > horizontal
> > > > position of the left-hand end and/or the right-hand end or a
> > > > hairpin,
> > > > or its length?
> > > \after
> > > Hairpin.bound-padding
> > > Hairpin.X-offset
> > > Hairpin.extra-offset
> > > 
> > > Those are my main weapons.  =)
> > > Kieren.
> > 
> > Here's another solution I cooked up with more granular control of
> > both ends
> > of the hairpin:
> > http://lists.gnu.org/archive/html/lilypond-user/2016-06/msg00176.ht
> > ml
> > 
> > It's not perfect, but might do the job for you.
> > 
> 
> Further down in that thread is an implementation of shorten-pair with
> hairpins: http://lists.gnu.org/archive/html/lilypond-user/2016-06/msg
> 00277.html
> 
> This will allow you independent control of the left and right ends,
> regardless of whether a dynamic or dynamics are preset.
> (Bound-padding works only when a dynamic is present, and affects
> right
> and left equally.).
> 
> It's a rewrite of the Hairpin stencil function.  One benefit of doing
> this is there is no scaling of the shortened or lengthened Hairpin.
> Possibly this avoids distortion.
> 
> HTH,
> 
> DN
> 
> 

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


Re: Controlling hairpin length - revisited!

2016-10-11 Thread David Nalesnik
Hi Kieren,

On Tue, Oct 11, 2016 at 9:51 AM, Kieren MacMillan
 wrote:
> Hi David,
>
>> Further down in that thread is an implementation of shorten-pair with
>> hairpins: 
>> http://lists.gnu.org/archive/html/lilypond-user/2016-06/msg00277.html
>
> The $1,000,000 Question: Why isn’t this in the distro?  =)

I think the interaction between this and other properties has to be
nailed down.  I'm not sure if it behaves "as expected" in conjunction
with whatever other property affects endpoints (to-barline,
bound-padding).

I'd welcome testing.

Also, there's the issue of programming language.  Should this
enhancement be added to the C++ original--easy enough-- or should the
distro ly:hairpin::print be replaced by a Scheme version?

I'd like to see the stencil function in Scheme, because it would then
be very convenient for users to adapt it to their needs.

A drawback would be speed, but would that even be noticeable?

>
> Thanks for this!

You're very welcome.

DN

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


Re: Controlling hairpin length - revisited!

2016-10-11 Thread Kieren MacMillan
Hi David,

> Further down in that thread is an implementation of shorten-pair with
> hairpins: 
> http://lists.gnu.org/archive/html/lilypond-user/2016-06/msg00277.html

The $1,000,000 Question: Why isn’t this in the distro?  =)

Thanks for this!
Kieren.


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


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


Re: Controlling hairpin length - revisited!

2016-10-11 Thread David Nalesnik
Hi,


On Tue, Oct 11, 2016 at 9:07 AM, tisimst  wrote:
> David,
>
> On Tue, Oct 11, 2016 at 8:01 AM, Kieren MacMillan [via Lilypond] <[hidden
> email]> wrote:
>>
>> Hi David,
>>
>> > Just so that I have as many weapons as possible at my disposal, are
>> > there any other parameters which might directly affect the horizontal
>> > position of the left-hand end and/or the right-hand end or a hairpin,
>> > or its length?
>>
>> \after
>> Hairpin.bound-padding
>> Hairpin.X-offset
>> Hairpin.extra-offset
>>
>> Those are my main weapons.  =)
>> Kieren.
>
>
> Here's another solution I cooked up with more granular control of both ends
> of the hairpin:
> http://lists.gnu.org/archive/html/lilypond-user/2016-06/msg00176.html
>
> It's not perfect, but might do the job for you.
>


Further down in that thread is an implementation of shorten-pair with
hairpins: http://lists.gnu.org/archive/html/lilypond-user/2016-06/msg00277.html

This will allow you independent control of the left and right ends,
regardless of whether a dynamic or dynamics are preset.
(Bound-padding works only when a dynamic is present, and affects right
and left equally.).

It's a rewrite of the Hairpin stencil function.  One benefit of doing
this is there is no scaling of the shortened or lengthened Hairpin.
Possibly this avoids distortion.

HTH,

DN

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


Re: Controlling hairpin length - revisited!

2016-10-11 Thread tisimst
David,

On Tue, Oct 11, 2016 at 8:01 AM, Kieren MacMillan [via Lilypond] <
ml-node+s1069038n195270...@n5.nabble.com> wrote:

> Hi David,
>
> > Just so that I have as many weapons as possible at my disposal, are
> > there any other parameters which might directly affect the horizontal
> > position of the left-hand end and/or the right-hand end or a hairpin,
> > or its length?
>
> \after
> Hairpin.bound-padding
> Hairpin.X-offset
> Hairpin.extra-offset
>
> Those are my main weapons.  =)
> Kieren.
>

Here's another solution I cooked up with more granular control of both ends
of the hairpin: http://lists.gnu.org/archive/html/lilypond-user/2016-06/
msg00176.html

It's not perfect, but might do the job for you.

HTH,
Abraham




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Controlling-hairpin-length-revisited-tp195269p195271.html
Sent from the User mailing list archive at Nabble.com.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Controlling hairpin length - revisited!

2016-10-11 Thread Kieren MacMillan
Hi David,

> Just so that I have as many weapons as possible at my disposal, are
> there any other parameters which might directly affect the horizontal
> position of the left-hand end and/or the right-hand end or a hairpin,
> or its length?

\after
Hairpin.bound-padding
Hairpin.X-offset
Hairpin.extra-offset

Those are my main weapons.  =)
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


Controlling hairpin length - revisited!

2016-10-11 Thread David Sumbler
After a 9 month gap, I have finally come back to Lilypond and will
attempt to finish tweaking my string quartet score and parts.  I have
installed v2.19.48, and I have run 'convert-ly' on my files.

The reasons for the long gap were (a) moving house in February and,
more importantly (b) feeling very discouraged by the apparent
unpredictability of hairpin lengths in Lilypond, despite all Harm's
valiant efforts.

So, for now, I accept that I am going to have to tweak errant hairpins
individually, using trial and error for the most part.

The only parameter that I am aware of that will affect the printed
length and position of a hairpin is Hairpin.minimum-length.

Just so that I have as many weapons as possible at my disposal, are
there any other parameters which might directly affect the horizontal
position of the left-hand end and/or the right-hand end or a hairpin,
or its length?

David

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


Re: Controlling hairpin length

2016-01-24 Thread David Sumbler
On Sat, 2016-01-23 at 13:27 +0100, Thomas Morley wrote:
> 2016-01-21 16:54 GMT+01:00 David Sumbler :
> 
> >
> > Unfortunately I am still getting some over-long hairpins.  I think that
> > perhaps this has nothing to do with myHairpinMinimumLength, because I
> > was getting these long hairpins before you ever sent it to me - this is
> > one of the reasons I was going to set about tweaking hairpin lengths in
> > the piece.
> >
> > The 2 bars I quoted before are:
> >
> > % bar 14
> > g8\< a b cs( ~ cs\mf\> b) d,\mp cs |
> > g8\< g a g fs4\mf\> r\invP |
> > d8\< e fs e as,(\mf\> b) r4\invP |
> > e2\< d4\mf\> fs8(-\ten\mp fs)-\ten |
> > % bar 15
> > b8 cs\< d e fs-\ten\> fs\! e d \time 3/2 |
> > b,8\mp as\< b cs as-\ten\> b\! r4 \time 3/2 |
> > r2 cs8-\ten\mf\> b\! r4 \time 3/2 |
> > g8 e\< fs e fs-\ten\> d\! r4 \time 3/2 |
> >
> > This is in \parallelMusic for a string quartet.
> 
> 
> If I compile it with the following code, without(!!) any override I
> get the attached image.
> 
> \parallelMusic #'(E F G H) {
> % bar 14
> g8\< a b cs( ~ cs\mf\> b) d,\mp cs |
> g8\< g a g fs4\mf\> r\invP |
> d8\< e fs e as,(\mf\> b) r4\invP |
> e2\< d4\mf\> fs8(-\ten\mp fs)-\ten |
> % bar 15
> b8 cs\< d e fs-\ten\> fs\! e d \time 3/2 |
> b,8\mp as\< b cs as-\ten\> b\! r4 \time 3/2 |
> r2 cs8-\ten\mf\> b\! r4 \time 3/2 |
> g8 e\< fs e fs-\ten\> d\! r4 \time 3/2 |
> }
> 
> \new StaffGroup <<
>   \new Staff \E
>   \new Staff \F
>   \new Staff \G
>   \new Staff \H
> >>
> 
> \new Staff \E
> \new Staff \F
> \new Staff \G
> \new Staff \H
> 
> Ofcourse there are some too short Hairpins, but I can't see any too long.
> 
> 
> Nevertheless I changed `my-hairpin-minimum-length' to
> 
> #(define (my-hairpin-minimum-length grob)
> "Sets @code{minimum-length} for @code{Hairpin}, if their left bound is not the
> @code{NoteColumn}.
> The visible length is actually the one, specified by an additional override 
> for
> @code{minimum-length} or the default.
> If left bound is @code{NoteColumn}, default or specified @code{minimum-length}
> will take over."
>   (let* ((bound-left (ly:spanner-bound grob LEFT))
>  (bound-right (ly:spanner-bound grob RIGHT))
>  (sys (look-up-for-parent 'System Y grob))
>  (left-x-ext (ly:grob-extent bound-left sys X))
>  (not-note-column?
>(lambda (g)
>  (not (and (ly:grob? g)
>(grob::has-interface g 'note-column-interface))
>  (if (and (not-note-column? bound-left)
>   (interval-sane? left-x-ext)
>   (> (abs (cdr left-x-ext))
>  (ly:grob-property-data grob 'minimum-length)))
>  (ly:grob-set-property! grob 'minimum-length
>(+
>   (ly:grob-property-data grob 'minimum-length)
>   (* (if (not-note-column? bound-right) 2 1) (cdr 
> left-x-ext)))
> 
> Applying it as before I get the second attached png.
> 
> Looks quite ok to me.
> Though please be aware, all I can do is to provide a more or less
> workable work around issue 2207.
> 
> There are a lot of things which determine actual Hairpin length.
> I doubt I can reasonable cover them.
> 
> I think you should do
> \revert Hairpin.before-line-breaking
> in cases where `myHairpinMinimumLength' doesn't return acceptable
> results and tweak manually.
> 
> 
> HTH,
>   Harm

I am utterly mystified by what is going on here.  I have tried the new
routine on both my string quartet and also on the code you provided.

In both cases I find that setting minimum-length to the value 2 gives
acceptable results.  (In the case of the full string quartet, I have
closely inspected only the two bars included in your code.)

If I set minimum-length to a value less than 2, then I get some hairpins
that are too short - hardly surprising.

But if I use any value of minimum-length greater than 2 up to about 6,
then again I get hairpins that are too short.  Indeed, with values
between about 2.5 and 5, I also get "decrescendo too small" warnings.

With values from about 7 upwards, the short hairpins are OK, but others
are too long.

In other words, the only value that I can find less than 6 or 7 and
which provides acceptable results is 2 - no more, and no less.

Incidentally, do you know what triggers the "decrescendo too small" and
similar warnings?  It does not seem to happen simply when the actual
hairpin is less than the minimum-length setting.

David


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


Re: Controlling hairpin length

2016-01-23 Thread Michael Gerdau
Dear Harm and David,

I find this whole thread rather helpful and have just copied the
consolidated example as of Harm's last post into my personal snippet
archive.

Thank you guys,
Michael
-- 
 Michael Gerdau   email: m...@qata.de
 GPG-keys available on request or at public keyserver

signature.asc
Description: This is a digitally signed message part.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Controlling hairpin length

2016-01-22 Thread Thomas Morley
2016-01-21 16:54 GMT+01:00 David Sumbler :

> I have tried substituting \! for my \invP markings, and replacing my
> tweaked -\ten markings with standard -- marks.

Please, tell me exactly how \ten is defined.

Cheers,
  Harm

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


Re: Controlling hairpin length

2016-01-22 Thread David Sumbler
On Fri, 2016-01-22 at 11:15 +0100, Thomas Morley wrote:
> 2016-01-21 16:54 GMT+01:00 David Sumbler :
> 
> > I have tried substituting \! for my \invP markings, and replacing my
> > tweaked -\ten markings with standard -- marks.
> 
> Please, tell me exactly how \ten is defined.
> 
> Cheers,
>   Harm

I have:

ten = \tweak Script.font-size #2 --

and

invP = \tweak stencil ##f \p

But, as I said, I have tried replacing these with orthodox - (tenuto)
and \! markings, and I still get the problem with the long hairpins.

Is there any way in Lilypond of directly specifying the actual length of
a hairpin - not a maximum or minimum length, but the precise length that
is required?  I fear that there is not, but it would be jolly useful if
there were!

David


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


Re: Controlling hairpin length

2016-01-21 Thread David Sumbler
On Tue, 2016-01-19 at 23:00 +0100, Thomas Morley wrote:
> %% a helper:
> #(define (look-up-for-parent name-symbol axis grob)
> "Return the parent of @var{grob}, specified by it's @var{name-symbol}
> in
> axis @var{axis} of @var{grob}.  If @var{grob} is already equal to the
> grob
> named @var{name-symbol} return @var{grob}.  If not found, look up for
> the next
> parent."
>  (let* ((parent (ly:grob-parent grob axis)))
>  (cond
>((not (ly:grob? parent))
> (ly:error
>(_"Perhaps typing error for \"~a\" or \"~a\" is not in the
> parent-tree.")
>name-symbol name-symbol))
>((equal? name-symbol (grob::name grob)) grob)
>((not (equal? name-symbol (grob::name parent)))
> (look-up-for-parent name-symbol axis parent))
>(else parent
> 
> #(define (my-hairpin-minimum-length grob)
> "Sets @code{minimum-length} for @code{Hairpin}, if their left bound is
> not the
> @code{NoteColumn}.
> The visible length is actually the one, specified by an additional
> override for
> @code{minimum-length} or the default.
> If left bound is @code{NoteColumn}, default or specified
> @code{minimum-length}
> will take over."
>   (let* ((bound-left (ly:spanner-bound grob LEFT))
>  (sys (look-up-for-parent 'System Y grob))
>  (left-x-ext (ly:grob-extent bound-left sys X))
>  (not-note-column?
>(lambda (g)
>  (not (and (ly:grob? g)
>(grob::has-interface g
> 'note-column-interface))
>  (if (not-note-column? bound-left)
>  (ly:grob-set-property! grob 'minimum-length
>(+
>   (* (if (interval-sane? left-x-ext) (cdr left-x-ext) 1)
>  (ly:grob-property-data grob 'bound-padding))
>   (ly:grob-property-data grob 'minimum-length)
>   (if (interval-sane? left-x-ext) (cdr left-x-ext) 0))
> 
> %% `myHairpinMinimumLength' tries to warrant the visible length of a
> Hairpin
> %% to be not less than the value of `minimum-length'
> myHairpinMinimumLength =
>   \override Hairpin.before-line-breaking = #my-hairpin-minimum-length
> 
> \layout {
>   \context {
> \Voice
> \myHairpinMinimumLength
> %% default for 'minimum-length is #2
> %% try different values
> \override Hairpin.minimum-length = #2
>   }
> }
> 
I have now tested this latest version out on my string quartet score,
and it seems to have solved the problem of too-short hairpins.  I have
not checked through the whole piece thoroughly yet, but certainly in the
places where I previously had "decrescendo too small" warnings I now get
a hairpin of a sensible length.  (I have set Hairpin.minimum-length to
2.5).

Unfortunately I am still getting some over-long hairpins.  I think that
perhaps this has nothing to do with myHairpinMinimumLength, because I
was getting these long hairpins before you ever sent it to me - this is
one of the reasons I was going to set about tweaking hairpin lengths in
the piece.

The 2 bars I quoted before are:

% bar 14
g8\< a b cs( ~ cs\mf\> b) d,\mp cs |
g8\< g a g fs4\mf\> r\invP |
d8\< e fs e as,(\mf\> b) r4\invP |
e2\< d4\mf\> fs8(-\ten\mp fs)-\ten |
% bar 15
b8 cs\< d e fs-\ten\> fs\! e d \time 3/2 |
b,8\mp as\< b cs as-\ten\> b\! r4 \time 3/2 |
r2 cs8-\ten\mf\> b\! r4 \time 3/2 |
g8 e\< fs e fs-\ten\> d\! r4 \time 3/2 |

This is in \parallelMusic for a string quartet.

The decrescendo hairpins in bar 14 are now a reasonable length with the
new routine.  But the same items in bar 15 are far too long, in both
score and all parts: they are roughly the same length as the crescendo
hairpins earlier in the same bar, and thus the 5th and 6th quavers are
forced apart for no good reason.

I have tried substituting \! for my \invP markings, and replacing my
tweaked -\ten markings with standard -- marks.  I have also tried
removing the dynamics in the viola part - I wondered whether the mf,
which causes the viola hairpin to start a little later than the others,
was somehow upsetting things.

I have also searched all of the relevant input files for any mention of
Hairpin settings that I might have overlooked, but found none.

None of these experiments have changed anything: I still get a long
hairpin in bar 15, although bar 14 is fine.

As I said, it looks as if your routine is now working pretty well, and
the problem I am having with bar 15 (and a few others) is some peculiar
bug within Lilypond, but I can't figure out what is causing it to
manifest itself at this particular point.

Any suggestions you can make regarding this will, of course, be very
gratefully received!

David


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


Re: Controlling hairpin length

2016-01-19 Thread Thomas Morley
2016-01-19 13:53 GMT+01:00 David Sumbler :
> On Tue, 2016-01-19 at 01:27 +0100, Thomas Morley wrote:
>> 2016-01-19 1:04 GMT+01:00 Thomas Morley :
>> > Hi David,
>> >
>> > 2016-01-18 22:56 GMT+01:00 David Sumbler :
>> >
>> >> After spending some hours trying to get to the bottom of this problem,
>> > [...]
>> >
>> > Well, I spend some hours creating the function(s) ;)
>> >
>> >> I narrowed it down to 3 different elements in my files
>> > [...]
>> >> I feel
>> >> that ideally an improvement in an area where Lilypond is somewhat
>> >> unsatisfactory (so far as the user is concerned) should not at the same
>> >> time break some other aspect(s) of the program's output,
>> >
>> > Indeed.
>> > Though I can't fix a problem which I didn't foresee or which wasn't 
>> > reported.
>> > Thus, thanks for your examples.
>> >
>> > Please replace
>> > #(define ((hairpin-minimum-length my-minimum) grob)
>> > ...
>> >
>> > with the code below:
>> >
>> > #(define ((hairpin-minimum-length my-minimum) grob)
>> >   (let* ((bound-left (ly:spanner-bound grob LEFT))
>> >  (bound-right (ly:spanner-bound grob RIGHT))
>> >  (sys (look-up-for-parent 'System Y grob))
>> >  (left-x-ext (ly:grob-extent bound-left sys X))
>> >  (right-x-ext (ly:grob-extent bound-right sys X)))
>> > (ly:grob-set-property! grob 'minimum-length
>> >   ;; keep 'minimum-length user-settable
>> >   (max (ly:grob-property-data grob 'minimum-length)
>> >;; nb, this calculation is only an approximation
>> >;; should work in most cases, though
>> >(+ my-minimum
>> >   (max (cdr left-x-ext) 0)
>> >   (max (cdr right-x-ext) 0))
>>
>> Probably even better:
>>
>> #(define ((hairpin-minimum-length my-minimum) grob)
>>   (let* ((bound-left (ly:spanner-bound grob LEFT))
>>  (bound-right (ly:spanner-bound grob RIGHT))
>>  (sys (look-up-for-parent 'System Y grob))
>>  (left-x-ext (ly:grob-extent bound-left sys X))
>>  (right-x-ext (ly:grob-extent bound-right sys X)))
>> (ly:grob-set-property! grob 'minimum-length
>>   ;; keep 'minimum-length user-settable
>>   (max (ly:grob-property-data grob 'minimum-length)
>>;; nb, this calculation is only an approximation
>>;; should work in most cases, though
>>(+ my-minimum
>>   (if (interval-sane? left-x-ext) (cdr left-x-ext) 0)
>>   (if (interval-sane? right-x-ext) (cdr right-x-ext) 0))
>>
>> >
>> > Please report back, whether it works now.
>> >
>> > Cheers,
>> >   Harm
>
> Thank you for accepting my comments about the usability of
> \myHairpinMinimumLength in the spirit that was intended.
>
> I can report that both of the new versions produce no errors.
>
> However, I am still having a problem with the following bar:
>
> g8\< g a g fs4\mf\> r\invP |
>
> where invP = \tweak stencil ##f \p
>
> This gives a "decrescendo too small" warning, with the all too familiar
> vertical line in place of a hairpin, if myHairpinMinimumLength is set to
> a value of less than 3.
>
> Yet in the very next bar:
>
> b,8\mp as\< b cs as--\> b\! r4 |
>
> the diminuendo is unnecessarily long (approximately 5.5 staff spaces
> with the variable set to #2), forcing the final two quavers apart.
>
> I note that in the comments you say "nb, this calculation is only an
> approximation; should work in most cases, though".  But from the above 2
> bars it appears that the printed length of a hairpin can be at least 2.5
> staff spaces shorter or longer than the requested length.  This means
> that the length of individual hairpins may need to be tweaked - which is
> the same problem that we have with the built in Hairpin.minimum-length .
>
> David
>

Well, `minimum-length' is a beasty thing ...

Please try the code below. I paste the complete one plus examples,
because it's changed more than only improve some calculations.
`myHairpinMinimumLength' is now an override reading `minimum-length'
from a separate override or taking the default.

\version "2.19.35"

\language "english"

%% a helper:
#(define (look-up-for-parent name-symbol axis grob)
"Return the parent of @var{grob}, specified by it's @var{name-symbol} in
axis @var{axis} of @var{grob}.  If @var{grob} is already equal to the grob
named @var{name-symbol} return @var{grob}.  If not found, look up for the next
parent."
 (let* ((parent (ly:grob-parent grob axis)))
 (cond
   ((not (ly:grob? parent))
(ly:error
   (_"Perhaps typing error for \"~a\" or \"~a\" is not in the parent-tree.")
   name-symbol name-symbol))
   ((equal? name-symbol (grob::name grob)) grob)
   ((not (equal? name-symbol (grob::name parent)))
(look-up-for-parent name-symbol axis parent))
   (else parent

#(define (my-hairpin-minimum-length grob)
"Sets @code{minimum-length} for @code{Hairpin}, if their left bound is not the
@code{NoteColumn}.
The 

Re: Controlling hairpin length

2016-01-19 Thread David Sumbler
On Tue, 2016-01-19 at 01:27 +0100, Thomas Morley wrote:
> 2016-01-19 1:04 GMT+01:00 Thomas Morley :
> > Hi David,
> >
> > 2016-01-18 22:56 GMT+01:00 David Sumbler :
> >
> >> After spending some hours trying to get to the bottom of this problem,
> > [...]
> >
> > Well, I spend some hours creating the function(s) ;)
> >
> >> I narrowed it down to 3 different elements in my files
> > [...]
> >> I feel
> >> that ideally an improvement in an area where Lilypond is somewhat
> >> unsatisfactory (so far as the user is concerned) should not at the same
> >> time break some other aspect(s) of the program's output,
> >
> > Indeed.
> > Though I can't fix a problem which I didn't foresee or which wasn't 
> > reported.
> > Thus, thanks for your examples.
> >
> > Please replace
> > #(define ((hairpin-minimum-length my-minimum) grob)
> > ...
> >
> > with the code below:
> >
> > #(define ((hairpin-minimum-length my-minimum) grob)
> >   (let* ((bound-left (ly:spanner-bound grob LEFT))
> >  (bound-right (ly:spanner-bound grob RIGHT))
> >  (sys (look-up-for-parent 'System Y grob))
> >  (left-x-ext (ly:grob-extent bound-left sys X))
> >  (right-x-ext (ly:grob-extent bound-right sys X)))
> > (ly:grob-set-property! grob 'minimum-length
> >   ;; keep 'minimum-length user-settable
> >   (max (ly:grob-property-data grob 'minimum-length)
> >;; nb, this calculation is only an approximation
> >;; should work in most cases, though
> >(+ my-minimum
> >   (max (cdr left-x-ext) 0)
> >   (max (cdr right-x-ext) 0))
> 
> Probably even better:
> 
> #(define ((hairpin-minimum-length my-minimum) grob)
>   (let* ((bound-left (ly:spanner-bound grob LEFT))
>  (bound-right (ly:spanner-bound grob RIGHT))
>  (sys (look-up-for-parent 'System Y grob))
>  (left-x-ext (ly:grob-extent bound-left sys X))
>  (right-x-ext (ly:grob-extent bound-right sys X)))
> (ly:grob-set-property! grob 'minimum-length
>   ;; keep 'minimum-length user-settable
>   (max (ly:grob-property-data grob 'minimum-length)
>;; nb, this calculation is only an approximation
>;; should work in most cases, though
>(+ my-minimum
>   (if (interval-sane? left-x-ext) (cdr left-x-ext) 0)
>   (if (interval-sane? right-x-ext) (cdr right-x-ext) 0))
> 
> >
> > Please report back, whether it works now.
> >
> > Cheers,
> >   Harm

Thank you for accepting my comments about the usability of
\myHairpinMinimumLength in the spirit that was intended.

I can report that both of the new versions produce no errors.

However, I am still having a problem with the following bar:

g8\< g a g fs4\mf\> r\invP |

where invP = \tweak stencil ##f \p

This gives a "decrescendo too small" warning, with the all too familiar
vertical line in place of a hairpin, if myHairpinMinimumLength is set to
a value of less than 3.

Yet in the very next bar:

b,8\mp as\< b cs as--\> b\! r4 |

the diminuendo is unnecessarily long (approximately 5.5 staff spaces
with the variable set to #2), forcing the final two quavers apart.

I note that in the comments you say "nb, this calculation is only an
approximation; should work in most cases, though".  But from the above 2
bars it appears that the printed length of a hairpin can be at least 2.5
staff spaces shorter or longer than the requested length.  This means
that the length of individual hairpins may need to be tweaked - which is
the same problem that we have with the built in Hairpin.minimum-length .

David


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


Re: Controlling hairpin length

2016-01-18 Thread Thomas Morley
Hi David,

2016-01-18 22:56 GMT+01:00 David Sumbler :

> After spending some hours trying to get to the bottom of this problem,
[...]

Well, I spend some hours creating the function(s) ;)

> I narrowed it down to 3 different elements in my files
[...]
> I feel
> that ideally an improvement in an area where Lilypond is somewhat
> unsatisfactory (so far as the user is concerned) should not at the same
> time break some other aspect(s) of the program's output,

Indeed.
Though I can't fix a problem which I didn't foresee or which wasn't reported.
Thus, thanks for your examples.

Please replace
#(define ((hairpin-minimum-length my-minimum) grob)
...

with the code below:

#(define ((hairpin-minimum-length my-minimum) grob)
  (let* ((bound-left (ly:spanner-bound grob LEFT))
 (bound-right (ly:spanner-bound grob RIGHT))
 (sys (look-up-for-parent 'System Y grob))
 (left-x-ext (ly:grob-extent bound-left sys X))
 (right-x-ext (ly:grob-extent bound-right sys X)))
(ly:grob-set-property! grob 'minimum-length
  ;; keep 'minimum-length user-settable
  (max (ly:grob-property-data grob 'minimum-length)
   ;; nb, this calculation is only an approximation
   ;; should work in most cases, though
   (+ my-minimum
  (max (cdr left-x-ext) 0)
  (max (cdr right-x-ext) 0))

Please report back, whether it works now.

Cheers,
  Harm

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


Re: Controlling hairpin length

2016-01-18 Thread Thomas Morley
2016-01-19 1:04 GMT+01:00 Thomas Morley :
> Hi David,
>
> 2016-01-18 22:56 GMT+01:00 David Sumbler :
>
>> After spending some hours trying to get to the bottom of this problem,
> [...]
>
> Well, I spend some hours creating the function(s) ;)
>
>> I narrowed it down to 3 different elements in my files
> [...]
>> I feel
>> that ideally an improvement in an area where Lilypond is somewhat
>> unsatisfactory (so far as the user is concerned) should not at the same
>> time break some other aspect(s) of the program's output,
>
> Indeed.
> Though I can't fix a problem which I didn't foresee or which wasn't reported.
> Thus, thanks for your examples.
>
> Please replace
> #(define ((hairpin-minimum-length my-minimum) grob)
> ...
>
> with the code below:
>
> #(define ((hairpin-minimum-length my-minimum) grob)
>   (let* ((bound-left (ly:spanner-bound grob LEFT))
>  (bound-right (ly:spanner-bound grob RIGHT))
>  (sys (look-up-for-parent 'System Y grob))
>  (left-x-ext (ly:grob-extent bound-left sys X))
>  (right-x-ext (ly:grob-extent bound-right sys X)))
> (ly:grob-set-property! grob 'minimum-length
>   ;; keep 'minimum-length user-settable
>   (max (ly:grob-property-data grob 'minimum-length)
>;; nb, this calculation is only an approximation
>;; should work in most cases, though
>(+ my-minimum
>   (max (cdr left-x-ext) 0)
>   (max (cdr right-x-ext) 0))

Probably even better:

#(define ((hairpin-minimum-length my-minimum) grob)
  (let* ((bound-left (ly:spanner-bound grob LEFT))
 (bound-right (ly:spanner-bound grob RIGHT))
 (sys (look-up-for-parent 'System Y grob))
 (left-x-ext (ly:grob-extent bound-left sys X))
 (right-x-ext (ly:grob-extent bound-right sys X)))
(ly:grob-set-property! grob 'minimum-length
  ;; keep 'minimum-length user-settable
  (max (ly:grob-property-data grob 'minimum-length)
   ;; nb, this calculation is only an approximation
   ;; should work in most cases, though
   (+ my-minimum
  (if (interval-sane? left-x-ext) (cdr left-x-ext) 0)
  (if (interval-sane? right-x-ext) (cdr right-x-ext) 0))

>
> Please report back, whether it works now.
>
> Cheers,
>   Harm

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


Re: Controlling hairpin length

2016-01-18 Thread David Sumbler
On Sun, 2016-01-17 at 20:15 +0100, Thomas Morley wrote:
> 2016-01-17 19:21 GMT+01:00 David Sumbler :
> 
> >
> > The only trouble is, I am getting a lot of compiler errors and warnings.
> > For each of the relevant layout blocks, I get:
> >
> > programming error: infinite rod
> > continuing, cross fingers
> >
> > and then numerous instances of:
> >
> > programming error: ignoring weird minimum distance
> > continuing, cross fingers
> >
> > In the cases of the 2nd violin and the viola, this latter message is
> > printed 50 times each for the 3rd movement alone - quite a lot for a
> > movement with only 64 bars!  And there are certainly well over 1,000 of
> > these errors for the whole quartet (score and parts).
> >
> > Have you come across this behaviour?
> 
> 
> 
> In one word: no.
> Please try to boil it down to minimal example otherwise I can't help.
> 
> Cheers,
>   Harm

After spending some hours trying to get to the bottom of this problem, I
narrowed it down to 3 different elements in my files which were causing
these hundreds of error messages when \myHairpinMinimumLength was set.
There were not hundreds of triggers in my files: but it seems that, once
triggered, the hairpin routine couldn't sort itself out for the
remainder of a movement and so kept on repeating the same message.

The first element that caused the errors was my occasional use of \invP,
defined as:
invP = \tweak stencil ##f \p

I have used this in a few places, rather than \! to terminate a hairpin.
I do this as an easy way to finish a diminuendo just before a notehead
so that the note in question does not appear to be included within the
diminuendo.

The second thing that gave rise to problems was the following bar:
d'2..*6/7 \sf\> s8\! e,8~\< |
I had done this so that there would be more space between the diminuendo
hairpin and the following crescendo hairpin.  I wanted it to be clear
that the new crescendo actually begins with the second note.

The third item that caused "infinite rod" and "weird minimum distance"
errors was the following (all 4 quartet instruments in "parallelMusic"):

<< b1\fermata {s2..\> s8\!} >> |
<< c1\fermata {s2..\> s8\!} >> |
<< e1\fermata {s2..\> s8\!} >> |
<< b1\fermata {s2..\> s8\!} >> |

My reason for using this was, again, to try to control the position of
the end of the diminuendo hairpins.

No doubt none of these 3 examples is very elegant, and they are very
likely not the best way of achieving the result I want.  But they worked
perfectly well until I used the improved hairpin length routine.  I feel
that ideally an improvement in an area where Lilypond is somewhat
unsatisfactory (so far as the user is concerned) should not at the same
time break some other aspect(s) of the program's output, so I am
pointing these out not as a criticism, but for information.

For the time being, perhaps, I shall have to go back to individual
tweaks for hairpin length, using trial and error to find the best
values.

Thanks again for your help.

David



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


Re: Controlling hairpin length

2016-01-17 Thread David Sumbler
It's true - your example, using the bar I included in my previous email,
works fine.

In my previous attempts at getting this to work with the whole quartet I
had your 2 Scheme "define"s and the myHairpinMinimumLength definition in
a file of defaults,  which has an /include in my top file.  In the
included file, after the definitions, I had '\myHairpinMinimumLength
#2', or whatever value I was trying out.  I have now realized that I had
not set it correctly in a Voice context.  Having corrected that, I find
that it does indeed seem to produce the desired result.  (I have not had
time to check the hairpins on all 106 pages yet!)

The only trouble is, I am getting a lot of compiler errors and warnings.
For each of the relevant layout blocks, I get:

programming error: infinite rod
continuing, cross fingers

and then numerous instances of:

programming error: ignoring weird minimum distance
continuing, cross fingers

In the cases of the 2nd violin and the viola, this latter message is
printed 50 times each for the 3rd movement alone - quite a lot for a
movement with only 64 bars!  And there are certainly well over 1,000 of
these errors for the whole quartet (score and parts).

Have you come across this behaviour?

David


On Sun, 2016-01-17 at 18:22 +0100, Thomas Morley wrote:
> 2016-01-17 17:36 GMT+01:00 David Sumbler :
> > Thank you for the suggestion (below) for controlling the actual length
> > of hairpins.  I am afraid it has taken until now for me to have an
> > opportunity to try it out in my string quartet.  Unfortunately, I find
> > that it is only a partial success.
> >
> > Previously I had '\override Hairpin.minimum-length = #7' in my Voice
> > defaults.  This works OK most of the time, although obviously sometimes
> > it produces an over-long hairpin which needs an override.
> >
> > I then tried setting \myHairpinMinimumLength #1.5 (as in your example),
> > but had to remove the Hairpin.minimum-length setting to get it to work.
> > Unfortunately I found that a number of hairpins produced a compiler
> > warning: "decrescendo too small".
> >
> > I don't understand this, because the example you gave seems to compile
> > without a problem, other than that the line length is far greater than
> > my page width.
> >
> > The bar that seems to cause most of the problems is:
> >
> > g8\< a b cs( ~ cs\mf\> b) d,\mp cs |
> > g8\< g a g fs4\mf\> r\! |
> > d8\< e fs e as,(\mf\> b) r4\! |
> > e2\< d4\mf\> fs8(--\mp fs)-- |
> >
> > This is a "parallelMusic" bar for a standard string quartet.  The
> > warnings are produced by the decrescendo, and this hairpin has zero
> > actual length, despite the \myHairpinMinimumLength setting.  This
> > happens in each of the parts (apart from the viola), but not in the
> > score.  Presumably the extra quaver in the viola part saves the score
> > and the viola part from getting this too-short hairpin, but then the
> > viola part gives a similar warning in a later bar.
> >
> > I am using Lilypond 2.19.30.
> >
> > David
> 
> 
> Hi David,
> 
> the code below gives the attached output (cut off)
> I see no problems and no warnings.
> 
> Tiny example?
> 
> \version "2.19.35"
> 
> \language "english"
> 
> %% a helper:
> #(define (look-up-for-parent name-symbol axis grob)
> "Return the parent of @var{grob}, specified by it's @var{name-symbol} in
> axis @var{axis} or @var{grob}, if equal to the grob named @var{name-symbol}
> already.
> If not found, look up for the next parent."
>  (let* ((parent (ly:grob-parent grob axis)))
>  (cond
>((not (ly:grob? parent))
> (ly:error
>(_"Perhaps typing error for \"~a\" or \"~a\" is not in the 
> parent-tree.")
>name-symbol name-symbol))
>((equal? name-symbol (grob::name grob)) grob)
>((not (equal? name-symbol (grob::name parent)))
> (look-up-for-parent name-symbol axis parent))
>(else parent
> 
> #(define ((hairpin-minimum-length my-minimum) grob)
>   (let* ((bound-left (ly:spanner-bound grob LEFT))
>  (bound-right (ly:spanner-bound grob RIGHT))
>  (sys (look-up-for-parent 'System Y grob))
>  (left-x-ext (ly:grob-extent bound-left sys X))
>  (right-x-ext (ly:grob-extent bound-right sys X)))
> (ly:grob-set-property! grob 'minimum-length
>   ;; keep 'minimum-length user-settable
>   (max (ly:grob-property-data grob 'minimum-length)
>;; nb, this calculation is only an approximation
>;; should work in most cases, though
>(+ my-minimum (abs (cdr left-x-ext)) (abs (cdr right-x-ext)))
> 
> myHairpinMinimumLength =
> #(define-music-function (parser location minimum)(number?)
> #{
>   \override Hairpin.before-line-breaking =
> #(hairpin-minimum-length minimum)
> #})
> 
> %{
> {
> \override Hairpin.color = #red
> \myHairpinMinimumLength #1.5
> \repeat unfold 6 { c4\\> d\\! c d \noBreak }
> \break
> %% overriding 'minimum-length is still possible
>   

Re: Controlling hairpin length

2016-01-17 Thread Thomas Morley
2016-01-17 19:21 GMT+01:00 David Sumbler :

>
> The only trouble is, I am getting a lot of compiler errors and warnings.
> For each of the relevant layout blocks, I get:
>
> programming error: infinite rod
> continuing, cross fingers
>
> and then numerous instances of:
>
> programming error: ignoring weird minimum distance
> continuing, cross fingers
>
> In the cases of the 2nd violin and the viola, this latter message is
> printed 50 times each for the 3rd movement alone - quite a lot for a
> movement with only 64 bars!  And there are certainly well over 1,000 of
> these errors for the whole quartet (score and parts).
>
> Have you come across this behaviour?



In one word: no.
Please try to boil it down to minimal example otherwise I can't help.

Cheers,
  Harm

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


Re: Controlling hairpin length

2016-01-17 Thread David Sumbler
Thank you for the suggestion (below) for controlling the actual length
of hairpins.  I am afraid it has taken until now for me to have an
opportunity to try it out in my string quartet.  Unfortunately, I find
that it is only a partial success.

Previously I had '\override Hairpin.minimum-length = #7' in my Voice
defaults.  This works OK most of the time, although obviously sometimes
it produces an over-long hairpin which needs an override.

I then tried setting \myHairpinMinimumLength #1.5 (as in your example),
but had to remove the Hairpin.minimum-length setting to get it to work.
Unfortunately I found that a number of hairpins produced a compiler
warning: "decrescendo too small".

I don't understand this, because the example you gave seems to compile
without a problem, other than that the line length is far greater than
my page width.

The bar that seems to cause most of the problems is:

g8\< a b cs( ~ cs\mf\> b) d,\mp cs |
g8\< g a g fs4\mf\> r\! |
d8\< e fs e as,(\mf\> b) r4\! |
e2\< d4\mf\> fs8(--\mp fs)-- |

This is a "parallelMusic" bar for a standard string quartet.  The
warnings are produced by the decrescendo, and this hairpin has zero
actual length, despite the \myHairpinMinimumLength setting.  This
happens in each of the parts (apart from the viola), but not in the
score.  Presumably the extra quaver in the viola part saves the score
and the viola part from getting this too-short hairpin, but then the
viola part gives a similar warning in a later bar.

I am using Lilypond 2.19.30.

David



On Sat, 2015-12-12 at 22:35 +0100, Thomas Morley wrote:
> 2015-12-12 17:46 GMT+01:00 David Sumbler :
> > Although I quite often find myself needing to use
> >
> > \override Voice.Hairpin.minimum-length = #2
> >
> > or similar, I find that the results are unpredictable (to me!)
> >
> > Sometimes I have a very short hairpin, perhaps starting on a quaver and
> > ending on the next quaver.  In the output such a hairpin sometimes
> > appears as a short vertical line (i.e. with length=0), and a warning is
> > shown in the compiler output.
> >
> > If I change Hairpin.minimum-length I have to do it by trial and error,
> > because the result does not seem necessarily to correspond to the value
> > I have specified.  (I am assuming that the units are staff spaces.)  I'm
> > guessing that this may perhaps be something to do with having an actual
> > dynamic such as mf attached to one or both notes.
> 
> It's issue 2207
> https://sourceforge.net/p/testlilyissues/issues/2207/
> 
> >
> > The Internals Reference says that use of the minimum-length property
> > with a hairpin "requires an appropriate callback for the
> > springs-and-rods property".  Unfortunately I have no clear idea what
> > this means, and I haven't managed to find out yet either by searching or
> > by experimentation.  The best I have come up with so far is
> >
> > \override Hairpin.springs-and-rods = #ly:spanner::set-spacing-rods
> 
> This is already the default for Hairpins (but nor for Glissando par example)
> No need to set it again in your file.
> 
> >
> > This doesn't improve the output at all, but at least it doesn't produce
> > any additional error or warning!
> >
> > How can I guarantee that all hairpins will be printed with a minimum
> > length of, say, 1.5 staff spaces, and the notes spaced appropriately,
> > regardless of preceding or following dynamics?
> 
> You may find the discussion at the linked issue enlightning.
> 
> For now you may try the following as a workaround.
> Though, please be aware it's not tested beyond the example, your turn ;)
> Ofcorse I'll try to improve the code, if you notice issues
> 
> \version "2.18.2"
> 
> %% a helper:
> #(define (look-up-for-parent name-symbol axis grob)
> "Return the parent of @var{grob}, specified by it's @var{name-symbol} in
> axis @var{axis} or @var{grob}, if equal to the grob named @var{name-symbol}
> already.
> If not found, look up for the next parent."
>  (let* ((parent (ly:grob-parent grob axis)))
>  (cond
>((not (ly:grob? parent))
> (ly:error
>(_"Perhaps typing error for \"~a\" or \"~a\" is not in the 
> parent-tree.")
>name-symbol name-symbol))
>((equal? name-symbol (grob::name grob)) grob)
>((not (equal? name-symbol (grob::name parent)))
> (look-up-for-parent name-symbol axis parent))
>(else parent
> 
> #(define ((hairpin-minimum-length my-minimum) grob)
>   (let* ((bound-left (ly:spanner-bound grob LEFT))
>  (bound-right (ly:spanner-bound grob RIGHT))
>  (sys (look-up-for-parent 'System Y grob))
>  (left-x-ext (ly:grob-extent bound-left sys X))
>  (right-x-ext (ly:grob-extent bound-right sys X)))
> (ly:grob-set-property! grob 'minimum-length
>   ;; keep 'minimum-length user-settable
>   (max (ly:grob-property-data grob 'minimum-length)
>;; nb, this calculation is only an approximation
>;; should work in most cases, 

Re: Controlling hairpin length

2016-01-17 Thread Thomas Morley
2016-01-17 17:36 GMT+01:00 David Sumbler :
> Thank you for the suggestion (below) for controlling the actual length
> of hairpins.  I am afraid it has taken until now for me to have an
> opportunity to try it out in my string quartet.  Unfortunately, I find
> that it is only a partial success.
>
> Previously I had '\override Hairpin.minimum-length = #7' in my Voice
> defaults.  This works OK most of the time, although obviously sometimes
> it produces an over-long hairpin which needs an override.
>
> I then tried setting \myHairpinMinimumLength #1.5 (as in your example),
> but had to remove the Hairpin.minimum-length setting to get it to work.
> Unfortunately I found that a number of hairpins produced a compiler
> warning: "decrescendo too small".
>
> I don't understand this, because the example you gave seems to compile
> without a problem, other than that the line length is far greater than
> my page width.
>
> The bar that seems to cause most of the problems is:
>
> g8\< a b cs( ~ cs\mf\> b) d,\mp cs |
> g8\< g a g fs4\mf\> r\! |
> d8\< e fs e as,(\mf\> b) r4\! |
> e2\< d4\mf\> fs8(--\mp fs)-- |
>
> This is a "parallelMusic" bar for a standard string quartet.  The
> warnings are produced by the decrescendo, and this hairpin has zero
> actual length, despite the \myHairpinMinimumLength setting.  This
> happens in each of the parts (apart from the viola), but not in the
> score.  Presumably the extra quaver in the viola part saves the score
> and the viola part from getting this too-short hairpin, but then the
> viola part gives a similar warning in a later bar.
>
> I am using Lilypond 2.19.30.
>
> David


Hi David,

the code below gives the attached output (cut off)
I see no problems and no warnings.

Tiny example?

\version "2.19.35"

\language "english"

%% a helper:
#(define (look-up-for-parent name-symbol axis grob)
"Return the parent of @var{grob}, specified by it's @var{name-symbol} in
axis @var{axis} or @var{grob}, if equal to the grob named @var{name-symbol}
already.
If not found, look up for the next parent."
 (let* ((parent (ly:grob-parent grob axis)))
 (cond
   ((not (ly:grob? parent))
(ly:error
   (_"Perhaps typing error for \"~a\" or \"~a\" is not in the parent-tree.")
   name-symbol name-symbol))
   ((equal? name-symbol (grob::name grob)) grob)
   ((not (equal? name-symbol (grob::name parent)))
(look-up-for-parent name-symbol axis parent))
   (else parent

#(define ((hairpin-minimum-length my-minimum) grob)
  (let* ((bound-left (ly:spanner-bound grob LEFT))
 (bound-right (ly:spanner-bound grob RIGHT))
 (sys (look-up-for-parent 'System Y grob))
 (left-x-ext (ly:grob-extent bound-left sys X))
 (right-x-ext (ly:grob-extent bound-right sys X)))
(ly:grob-set-property! grob 'minimum-length
  ;; keep 'minimum-length user-settable
  (max (ly:grob-property-data grob 'minimum-length)
   ;; nb, this calculation is only an approximation
   ;; should work in most cases, though
   (+ my-minimum (abs (cdr left-x-ext)) (abs (cdr right-x-ext)))

myHairpinMinimumLength =
#(define-music-function (parser location minimum)(number?)
#{
  \override Hairpin.before-line-breaking =
#(hairpin-minimum-length minimum)
#})

%{
{
\override Hairpin.color = #red
\myHairpinMinimumLength #1.5
\repeat unfold 6 { c4\\> d\\! c d \noBreak }
\break
%% overriding 'minimum-length is still possible
\override Hairpin.minimum-length = 20
\repeat unfold 6 { c4\\> d\\! c d \noBreak }
}
%}

\parallelMusic #'(A B C D) {
g8\< a b cs( ~ cs\mf\> b) d,\mp cs |
g8\< g a g fs4\mf\> r\! |
d8\< e fs e as,(\mf\> b) r4\! |
e2\< d4\mf\> fs8(--\mp fs)-- |
}

\layout {
  \context {
\Voice
\myHairpinMinimumLength #3
  }
}


\new StaffGroup <<
  \new Staff \A
  \new Staff \B
  \new Staff \C
  \new Staff \D
>>

\new Staff \A
\new Staff \B
\new Staff \C
\new Staff \D

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


Controlling hairpin length

2015-12-12 Thread David Sumbler
Although I quite often find myself needing to use

\override Voice.Hairpin.minimum-length = #2

or similar, I find that the results are unpredictable (to me!)

Sometimes I have a very short hairpin, perhaps starting on a quaver and
ending on the next quaver.  In the output such a hairpin sometimes
appears as a short vertical line (i.e. with length=0), and a warning is
shown in the compiler output.

If I change Hairpin.minimum-length I have to do it by trial and error,
because the result does not seem necessarily to correspond to the value
I have specified.  (I am assuming that the units are staff spaces.)  I'm
guessing that this may perhaps be something to do with having an actual
dynamic such as mf attached to one or both notes.

The Internals Reference says that use of the minimum-length property
with a hairpin "requires an appropriate callback for the
springs-and-rods property".  Unfortunately I have no clear idea what
this means, and I haven't managed to find out yet either by searching or
by experimentation.  The best I have come up with so far is

\override Hairpin.springs-and-rods = #ly:spanner::set-spacing-rods

This doesn't improve the output at all, but at least it doesn't produce
any additional error or warning!

How can I guarantee that all hairpins will be printed with a minimum
length of, say, 1.5 staff spaces, and the notes spaced appropriately,
regardless of preceding or following dynamics?

David


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


Re: Controlling hairpin length

2015-12-12 Thread Thomas Morley
2015-12-12 17:46 GMT+01:00 David Sumbler :
> Although I quite often find myself needing to use
>
> \override Voice.Hairpin.minimum-length = #2
>
> or similar, I find that the results are unpredictable (to me!)
>
> Sometimes I have a very short hairpin, perhaps starting on a quaver and
> ending on the next quaver.  In the output such a hairpin sometimes
> appears as a short vertical line (i.e. with length=0), and a warning is
> shown in the compiler output.
>
> If I change Hairpin.minimum-length I have to do it by trial and error,
> because the result does not seem necessarily to correspond to the value
> I have specified.  (I am assuming that the units are staff spaces.)  I'm
> guessing that this may perhaps be something to do with having an actual
> dynamic such as mf attached to one or both notes.

It's issue 2207
https://sourceforge.net/p/testlilyissues/issues/2207/

>
> The Internals Reference says that use of the minimum-length property
> with a hairpin "requires an appropriate callback for the
> springs-and-rods property".  Unfortunately I have no clear idea what
> this means, and I haven't managed to find out yet either by searching or
> by experimentation.  The best I have come up with so far is
>
> \override Hairpin.springs-and-rods = #ly:spanner::set-spacing-rods

This is already the default for Hairpins (but nor for Glissando par example)
No need to set it again in your file.

>
> This doesn't improve the output at all, but at least it doesn't produce
> any additional error or warning!
>
> How can I guarantee that all hairpins will be printed with a minimum
> length of, say, 1.5 staff spaces, and the notes spaced appropriately,
> regardless of preceding or following dynamics?

You may find the discussion at the linked issue enlightning.

For now you may try the following as a workaround.
Though, please be aware it's not tested beyond the example, your turn ;)
Ofcorse I'll try to improve the code, if you notice issues

\version "2.18.2"

%% a helper:
#(define (look-up-for-parent name-symbol axis grob)
"Return the parent of @var{grob}, specified by it's @var{name-symbol} in
axis @var{axis} or @var{grob}, if equal to the grob named @var{name-symbol}
already.
If not found, look up for the next parent."
 (let* ((parent (ly:grob-parent grob axis)))
 (cond
   ((not (ly:grob? parent))
(ly:error
   (_"Perhaps typing error for \"~a\" or \"~a\" is not in the parent-tree.")
   name-symbol name-symbol))
   ((equal? name-symbol (grob::name grob)) grob)
   ((not (equal? name-symbol (grob::name parent)))
(look-up-for-parent name-symbol axis parent))
   (else parent

#(define ((hairpin-minimum-length my-minimum) grob)
  (let* ((bound-left (ly:spanner-bound grob LEFT))
 (bound-right (ly:spanner-bound grob RIGHT))
 (sys (look-up-for-parent 'System Y grob))
 (left-x-ext (ly:grob-extent bound-left sys X))
 (right-x-ext (ly:grob-extent bound-right sys X)))
(ly:grob-set-property! grob 'minimum-length
  ;; keep 'minimum-length user-settable
  (max (ly:grob-property-data grob 'minimum-length)
   ;; nb, this calculation is only an approximation
   ;; should work in most cases, though
   (+ my-minimum (abs (cdr left-x-ext)) (abs (cdr right-x-ext)))

myHairpinMinimumLength =
#(define-music-function (parser location minimum)(number?)
#{
  \override Hairpin.before-line-breaking =
#(hairpin-minimum-length minimum)
#})

{
\override Hairpin.color = #red
\myHairpinMinimumLength #1.5
\repeat unfold 8 { c4\\> d\\! c d \noBreak }
\break
%% overriding 'minimum-length is still possible
\override Hairpin.minimum-length = 20
\repeat unfold 8 { c4\\> d\\! c d \noBreak }
}



HTH,
  Harm

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


Re: Controlling hairpin length

2015-12-12 Thread Thomas Morley
2015-12-12 22:35 GMT+01:00 Thomas Morley :
> 2015-12-12 17:46 GMT+01:00 David Sumbler :
>> Although I quite often find myself needing to use
>>
>> \override Voice.Hairpin.minimum-length = #2
>>
>> or similar, I find that the results are unpredictable (to me!)
>>
>> Sometimes I have a very short hairpin, perhaps starting on a quaver and
>> ending on the next quaver.  In the output such a hairpin sometimes
>> appears as a short vertical line (i.e. with length=0), and a warning is
>> shown in the compiler output.
>>
>> If I change Hairpin.minimum-length I have to do it by trial and error,
>> because the result does not seem necessarily to correspond to the value
>> I have specified.  (I am assuming that the units are staff spaces.)  I'm
>> guessing that this may perhaps be something to do with having an actual
>> dynamic such as mf attached to one or both notes.
>
> It's issue 2207
> https://sourceforge.net/p/testlilyissues/issues/2207/
>
>>
>> The Internals Reference says that use of the minimum-length property
>> with a hairpin "requires an appropriate callback for the
>> springs-and-rods property".  Unfortunately I have no clear idea what
>> this means, and I haven't managed to find out yet either by searching or
>> by experimentation.  The best I have come up with so far is
>>
>> \override Hairpin.springs-and-rods = #ly:spanner::set-spacing-rods
>
> This is already the default for Hairpins (but nor for Glissando par example)
> No need to set it again in your file.
>
>>
>> This doesn't improve the output at all, but at least it doesn't produce
>> any additional error or warning!
>>
>> How can I guarantee that all hairpins will be printed with a minimum
>> length of, say, 1.5 staff spaces, and the notes spaced appropriately,
>> regardless of preceding or following dynamics?
>
> You may find the discussion at the linked issue enlightning.
>
> For now you may try the following as a workaround.
> Though, please be aware it's not tested beyond the example, your turn ;)
> Ofcorse I'll try to improve the code, if you notice issues
>
> \version "2.18.2"

Sorry, this needs a more recent version.

>
> %% a helper:
> #(define (look-up-for-parent name-symbol axis grob)
> "Return the parent of @var{grob}, specified by it's @var{name-symbol} in
> axis @var{axis} or @var{grob}, if equal to the grob named @var{name-symbol}
> already.
> If not found, look up for the next parent."
>  (let* ((parent (ly:grob-parent grob axis)))
>  (cond
>((not (ly:grob? parent))
> (ly:error
>(_"Perhaps typing error for \"~a\" or \"~a\" is not in the 
> parent-tree.")
>name-symbol name-symbol))
>((equal? name-symbol (grob::name grob)) grob)
>((not (equal? name-symbol (grob::name parent)))
> (look-up-for-parent name-symbol axis parent))
>(else parent
>
> #(define ((hairpin-minimum-length my-minimum) grob)
>   (let* ((bound-left (ly:spanner-bound grob LEFT))
>  (bound-right (ly:spanner-bound grob RIGHT))
>  (sys (look-up-for-parent 'System Y grob))
>  (left-x-ext (ly:grob-extent bound-left sys X))
>  (right-x-ext (ly:grob-extent bound-right sys X)))
> (ly:grob-set-property! grob 'minimum-length
>   ;; keep 'minimum-length user-settable
>   (max (ly:grob-property-data grob 'minimum-length)
>;; nb, this calculation is only an approximation
>;; should work in most cases, though
>(+ my-minimum (abs (cdr left-x-ext)) (abs (cdr right-x-ext)))
>
> myHairpinMinimumLength =
> #(define-music-function (parser location minimum)(number?)
> #{
>   \override Hairpin.before-line-breaking =
> #(hairpin-minimum-length minimum)
> #})
>
> {
> \override Hairpin.color = #red
> \myHairpinMinimumLength #1.5
> \repeat unfold 8 { c4\\> d\\! c d \noBreak }
> \break
> %% overriding 'minimum-length is still possible
> \override Hairpin.minimum-length = 20
> \repeat unfold 8 { c4\\> d\\! c d \noBreak }
> }
>
>
>
> HTH,
>   Harm

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