Subject: Re: [linux-audio-dev] math question re. tempo changes
From: Eli Brandt (eli_AT_v.gp.cs.cmu.edu)
Date: ma joulu 06 1999 - 18:54:39 EST
Paul Winkler wrote:
> What I want to do is basically this:
> Let's say I have a section that starts at "beat" 0. The section
> lasts until "beat" 10. During this section, the tempo accelerates
> (linearly) from 60 to 120.
>
> Given any beat value in this section, I should be able to calculate
> the "real" (seconds) time value for this beat.
> Let's say it was a function called:
> beat_to_clock(beat_value, start_tempo, section_length, end_tempo)
>
> How can I do that?
ok, we're dealing with
tempo: beats per second
tempocurve: function from beats to tempo
beat_to_clock: function from beats to seconds
the basic relationship is
d(beat)/d(sec) = tempocurve(t)
so
d(sec)/d(beat) = 1 / tempocurve(t)
so
b_t_c(beat) = Integral(from 0 to beat) 1 / tempocurve(b) d(b)
you've got a linear tempo curve
tempocurve(b) = start_tempo + (b / section_length) *
(end_tempo - start_tempo)
so in this case
b_t_c(beat) = Integral(from 0 to beat)
start_tempo +
((end_tempo - start_tempo) / section_length) * b
d(b)
= 1/k ln(start_tempo + k*b)
where
k = (end_tempo - start_tempo) / section_length
hmm, does that look sane?
-- Eli Brandt | eli+@cs.cmu.edu | http://www.cs.cmu.edu/~eli/
This archive was generated by hypermail 2b28 : pe maalis 10 2000 - 07:23:26 EST