lilypond-user
[Top][All Lists]
Advanced

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

Re: Getting \tempo params


From: David Kastrup
Subject: Re: Getting \tempo params
Date: Thu, 21 Oct 2021 16:05:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Paolo Prete <paolopr976@gmail.com> writes:

> On Thu, Oct 21, 2021 at 3:04 PM David Kastrup <dak@gnu.org> wrote:
>
>>
>>
>> Here's a cut&paste of something I currently use in scores of mine for
>> doing things like accelerando, ritardando, and so on.
>>
>> tempoChange =
>> #(define-music-function (interval endscale thenscale music)
>>    (ly:duration? scale? (scale? 1) ly:music?)
>>   "Make a gradual tempo change over @var{music}, essentially changing
>> speed after
>> every duration of @var{interval}, approaching a factor of speed of
>> @var{endscale}
>> compared to the start.  Afterwards, tempo is switched to @var{thenscale}
>> of the
>> original speed (default 1).  If @var{thenscale} is 0, the speed reached at
>> the
>> end is just maintained and can be overriden with an explicit @samp{\\tempo}
>> command if required."
>>    (define (scaletempo oldscale newscale)
>>      (make-apply-context
>>       (lambda (ctx)
>>         (set! (ly:context-property ctx 'tempoWholesPerMinute)
>>          (ly:moment-mul (ly:context-property ctx 'tempoWholesPerMinute)
>>                  (ly:make-moment (/ newscale oldscale)))))))
>>
>>    (let* ((muslen (ly:moment-main (ly:music-length music)))
>>           (intlen (ly:moment-main (ly:duration-length interval)))
>>           (steps (/ muslen intlen))
>>           (endfactor (scale->factor endscale))
>>           (thenfactor (scale->factor thenscale)))
>>      (make-simultaneous-music
>>       (list music
>>             (context-spec-music
>>              (make-sequential-music
>>               (let loop ((rsteplst (iota (1+ steps) endfactor (/ (- 1
>> endfactor) steps)))
>>                          (res (if (positive? thenfactor)
>>                                   (list (scaletempo endfactor thenfactor))
>>                                   (list))))
>>                 (if (null? (cdr rsteplst))
>>                     res
>>                     (loop (cdr rsteplst)
>>                           (cons* (scaletempo (cadr rsteplst) (car
>> rsteplst))
>>                                  (make-skip-music (ly:make-duration 0 0
>> intlen))
>>                                  res)))))
>>              'Score)))))
>>
>> See if that helps you achieve your objective.
>>
>>
> This is interesting, thanks, but I don't understand if it fits with the
> growing beam example.
>  When that beams occur, I need three parameters:
>
> 1) the \tempo just before the beam
> 2) the \tempo at first note of the beam
> 3) the \tempo at the last note of the beam.
>
> Soon after the beam, I need that the tempo must be reset to 1)

That's the default.

> From what I see, in your code, at the end of $music the tempo is reset to
> 2) : am I wrong?

I guess so.

2) is not separately settable but determined by the requested overall
speed change (probably 1/2 or 2/1 in your case) divided by the number of
steps requested (probably 4 or 8 or so).

-- 
David Kastrup



reply via email to

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