[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MIDI rendition of things like rall./acc./rit./fermata
From: |
David Kastrup |
Subject: |
Re: MIDI rendition of things like rall./acc./rit./fermata |
Date: |
Tue, 15 Jun 2021 03:46:54 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Flaming Hakama by Elaine <elaine@flaminghakama.com> writes:
> The longhand way of doing it is to just create a new tempo on each beat or
> so ( within the MIDI tag). I think that your suggestion for a shorthand
> would be more useful as a function used within the MIDI tagged content,
> rather than after the fact inside the articulate script, where you will be
> guessing.
>
> I'd like to see the function take these arguments:
> * duration of the section (or provide a music expression that can be
> evaluated to determine the duration)
> * starting tempo (default to current tempo?)
> * ending tempo
> * either the rhythmic distance between tempi changes, as you suggest, or I
> think it would be better to be an integer representing the number of steps
> desired
> * some kind of representation of the curve to be used, such as a keyword
> for an algo known by the function (linear, log, etc.) and if it were more
> fancy, also take arguments for parameters of the known functions, or it it
> were really fancy, you could supply your own function to do the calculation.
>
> This function would output a series of spaces and tempi.
>
> Usage would be like:
> {
> \tempo 4=100
> \tag #'PDF { <>_{accel.} s1*3 }
> \tag #"MIDI {
> \createAccel s1*3 4=100 4=120 6 "linear"
> }
> \tempo 4=120
> }
>
You saw the followup? The one with
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{endscale} of the
original speed (default 1). If @var{endscale} 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)))))
in it?
--
David Kastrup