lilypond-user
[Top][All Lists]
Advanced

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

adjusting horizontal spacing - a function dedicated to Graham


From: Janek Warchoł
Subject: adjusting horizontal spacing - a function dedicated to Graham
Date: Wed, 18 Sep 2013 17:14:33 +0200

This snippet is dedicated to Graham Percival (see post scriptum)


2013/9/14 Janek Warchoł <address@hidden>:
>
> 2013/9/13 Curt <address@hidden>:
>> Unexpectedly hard parts of creating this score (all specific to v2.16):
>>
>> - General spacing and staff sizes.  I believe Lilypond by default
>>         puts everything too close together for music that is read
>>         by instrumentalists, particularly sight-readers.
>>         The spacing commands are easy to use, but difficult to find
>>         and look up if you don't already know them.
>
> I think that we should add to LilyPond a simple, user-friendly
> interface that would allow choosing the "density" of music, so that
> one could write
> \layout { \horizontalSpacingLoose }
> and it would result in common-shortest-duration being increased by
> some factor.  Writing this function should be simple, anyone wants to
> try it?

Ok, so I've looked at this, and then i asked David Nalesnik about it,
and he wrote a function which i had then improved (David Kastrup
helped me as well).  It's here:

stretchHorizontalSpacing =
#(define-music-function (parser location exponent) (number?)
   #{
     \override Score.SpacingSpanner.common-shortest-duration =
     #(lambda (grob)
        (let* ((func (assoc-get 'common-shortest-duration
                       (reverse (ly:grob-basic-properties grob))))
               (default-value (func grob))
               (factor (inexact->exact (expt 2 (- 0 exponent))))
               (multiplier (ly:make-moment (rationalize factor 1/2000))))
          (ly:moment-mul default-value multiplier)))
   #})

Full snippet with description and example is in the attachment (you
can also find it here:
http://github.com/openlilylib/snippets/blob/master/notation-snippets/adjusting-horizontal-spacing.ly
- any future updates will go there).

I think that if the function proves itself useful, it could be added
to official LilyPond distribution.


PS what's up with the dedication?

Two and a half years ago i wrote an email to the -devel with my
thoughts on LilyPond.  It was answered by Graham Percival, and despite
the fact that he was often called "grumpy" (and that some of his
emails made me feel he deserved that adjective), his answer inspired
me.

Which is actually weird because his answer for problems i saw in
LilyPond was essentially "yeah, patches welcome".

But i know why his answer inspired me nevertheless: it was how he said
that.  I saw that Graham sympathized with my ideas, that he too was
concerned about LilyPond being easy to use.  He didn't say "patches
welcome" as if he was warding off a petitioner, but as a fellow
developer who sees the need but doesn't have the resources to fix it.
Somehow it had fallen into my memory:

2011/3/13 Graham Percival <address@hidden> wrote:
(http://lists.gnu.org/archive/html/lilypond-devel/2011-03/msg00339.html)
>
> [...] Sure!  So let's change this.  Write a scheme function, [...]
>
> I'm always astounded at how much we _could_ be doing with "helper"
> scheme functions, but don't.  (some might dismiss them as "syntactic
> sugar", but we could keep them as optional includes to avoid
> "polluting" the main code base)
>
> In this particular case, I'm guessing 5 hours?  I mean, it'd be like
> 10 minutes for Neil, but if you're not familiar with scheme and stuff,
> it always takes a ton longer.

It took me more than two years, and my Scheme skills are still low
(the core of the snippet was written by David Nalesnik, and there's no
way i could do this myself - more credit goes to him than to me), but
i hope that this is a beginning of something good.

I have no idea how much time i will have to write other, similar
functions, but i consider the first step to be finally completed.

Thank you, Graham :-)

Janek

Attachment: adjusting-horizontal-spacing.ly
Description: Binary data


reply via email to

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