On Thu, Oct 21, 2021 at 3:04 PM David Kastrup <[email protected]> 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) >From what I see, in your code, at the end of $music the tempo is reset to 2) : am I wrong? > -- > David Kastrup >
