Re: [linux-audio-dev] math question re. tempo changes

New Message Reply About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [linux-audio-dev] math question re. tempo changes
From: Paul Winkler (slinkp_AT_ulster.net)
Date: ti joulu  07 1999 - 14:35:32 EST


est_AT_hyperreal.org wrote:
> The basic concept is pretty easy. Your changing tempo means that the
> rate at which time accumulates per unit beat (which is what
> d(sec)/d(beat) is in the language of calculus) is changing. Integrals
> are good for taking a changing rate of accumulation and turning it
> into a function giving the total of the accumulated quantity (time
> here) at any point.

OK.

> The basic idea of integrals is easy..but doing them is (relatively) a
> black art. I haven't done this sort of thing in years..but what
> better place to refresh than in public. :D
> I get:
>
> b_t_c(beat)
> = Integral(from 0 to beat) start_tempo + k * b d(b)
> = start_tempo * beat + k * beat^2 / 2
>

Seems like you got it right! At least, your method produces
identical results to those obtained using a t statement in csound.
 
Here's my test code -- this will need to be modified somewhat to
make it more generally useful in my module:

#!/usr/bin/python

def b2c(beat, start_tempo=60, end_tempo=60, end_beat):
    #make sure we use float values even if args are ints
    (beat, end_beat) = (float(beat), float(end_beat))
    # convert tempo from bpm to bps
    start_tempo, end_tempo = 60.0/start_tempo, 60.0/end_tempo
    k = (end_tempo - start_tempo) / end_beat
    clocktime = ((start_tempo * beat) + (k * beat**2 / 2))
    return clocktime

## TEST
a = range(0, 11)
b = []
for i in a:
    b.append( b2c(i, 60, 120, 10))
    print a[i], "-->", b[i]

a = range(0, 6)
b = []
for i in a:
    b.append( b2c(i, 40, 30, 5))
    print a[i], "-->", b[i]

-- 
................    paul winkler    ..................
slinkP arts:   music, sound, illustration, design, etc.
A member of ARMS    ----->    http://www.reacharms.com
or http://www.mp3.com/arms or http://www.amp3.com/arms
personal page   ---->    http://www.ulster.net/~abigoo


New Message Reply About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b28 : pe maalis 10 2000 - 07:23:26 EST