lilypond-user
[Top][All Lists]
Advanced

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

Re: Controlling hairpin length - revisited!


From: David Sumbler
Subject: Re: Controlling hairpin length - revisited!
Date: Thu, 20 Oct 2016 15:32:40 +0100

On Fri, 2016-10-14 at 12:07 +0200, Thomas Morley wrote:
> Hi David:
> 
> 2016-10-11 15:51 GMT+02:00 David Sumbler <address@hidden>:
> > 
> > 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 <address@hidden>:
> > 
> > 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 "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n")
> ;; scheme
> ;(display "\n------------------------------------------\n")
> ;(display "scheme -----------------------------------")
> ;(display "\n------------------------------------------\n")
> ;(display "scheme-t----------:\n")(display-scheme-music t)
> ;(display "scheme-e----------:\n")(display-scheme-music e)
> ;(display "scheme-m----------:\n")(display-scheme-music m)
> ;; lily
> (display "\n------------------------------------------")
> (display "\nlily -------------------------------------")
> (display "\n------------------------------------------\n")
> (display "\nlily-t----------: ")(display-lily-music  t)
> (display "\nlily-e----------: ")(display-lily-music  e)
> (display "\nlily-m----------: ")(display-lily-music  m)
> (display "\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n")
> 
>      #{
>          \context Bottom <<
>              #m
>              { \skip $t <> -\tweak extra-spacing-width #empty-
> interval $e }
>          >>
>      #})
> 
> 
> { \after 4 \mf \after 4 \> cs2\< ~ cs4 }
> 
> Which will return in terminal:
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> the function ran 1. time
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
> ------------------------------------------
> lily -------------------------------------
> ------------------------------------------
> 
> lily-t----------: %{ expecting a music expression: #<Duration 4 > %}
> 
> lily-e----------: \>
> 
> lily-m----------: cs2\< ~
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> the function ran 2. time
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> 
> ------------------------------------------
> lily -------------------------------------
> ------------------------------------------
> 
> lily-t----------: %{ expecting a music expression: #<Duration 4 > %}
> 
> lily-e----------: \mf
> 
> lily-m----------: \context Bottom << cs2\< ~ { \skip 4 < >-\tweak
> extra-spacing-width #(cons +inf.0 -inf.0)
> 
>  \> } >>
> 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> Interpreting music...
> atest-40.ly:1603:16: warning: unterminated decrescendo
> { \after 4 \mf
>                \after 4 \> cs2\< ~ cs4 }
> 
> 
> The output in scheme-syntax is commented because being too verbose,
> you may try it as well, though. The counter is an addition to make it
> even more clear when what is done.
> 
> 
> Hope that helps a bit,
>   Harm
> 
> P.S.
> Please always post compilable examples, with version and language (if
> not default). Would be nice to eliminate unrelated errors/warnings as
> well.

Thank you for that - it is helpful.

I have also reduced it to make a little function for seeing what Scheme
is up to in more usual, basic circumstances, which will help my general
understanding of how things work.

David



reply via email to

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