lilypond-user
[Top][All Lists]
Advanced

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

Re: Adding durations (for \after)


From: Lukas-Fabian Moser
Subject: Re: Adding durations (for \after)
Date: Wed, 9 Nov 2022 19:21:08 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2

Hi all,

Am 09.11.22 um 16:11 schrieb David Kastrup:
<https://lilypond.org/doc/v2.23/Documentation/notation/writing-rhythms#scaling-durations>
says:

Factors may also be added by using Scheme expressions evaluating to a
number or musical length like `*#(ly:music-length music)`.
Is there an example of such addition handy?

The stripped-down example below works, but `\after 8*9' would be
better written `\after #( <something involving 2. and 4.> )`.

The best I could glean from the documentation looks something like:

   \after #(ly:moment-add (ly:make-duration 2 1) (ly:make-duration 4 1))

... except that yields a type error because I’m creating durations not
moments.
Maybe something like

    \after #(make-duration-of-length (ly:music-length #{ 2. 4. #}))

Or, with a bit of added sugar:

\version "2.23.4"

duration =
#(define-scheme-function (mus) (ly:music?)
   (make-duration-of-length (ly:music-length mus)))

{
  \after \duration { 2 8 } ->
  \repeat unfold 16 { 8 }
}

Arguably it would make sense for \after to just accept example music as
the delay specification.

I thought along the same lines, but seeing as

{
  \after \duration 2 ->
  \repeat unfold 16 { 8 }
}

does not work, I'm not sure that would be easy - and of course we have the ambiguity with respect to { 2-> }.

So it doesn't seem like we can just let after expect ly:music? for the duration. I'm a bit surprised that

\version "2.23.4"

#(define (duration-or-music? x)
   (or (ly:duration? x) (ly:music? x)))

duration =
#(define-scheme-function (x) (duration-or-music?)
   (if (ly:duration? x)
       x
       (make-duration-of-length (ly:music-length x))))

{
  \after \duration 2. ->
  \repeat unfold 16 { 8 }
}

actually seems to work, but to me it looks kind of fishy...

Lukas




reply via email to

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