[PD] exponential tempo control

Chuckk Hubbard badmuthahubbard at gmail.com
Thu Oct 27 04:04:44 CEST 2005


My problem: having tempo change exponentially, but controlling when it would
reach the new tempo. So I know the old BPM (a), the new BPM (b), and the
number of beats to get from one to the other (B). I set metro to 100 ms.
What I don't know is the amount of time those however many beats will take
while tempo is changing, how many increments of change there will be (n),
and what factor to multiply by tempo with each increment (i). The idea is
that, whatever that factor is, it will multiply 10 times a second.
So:
i^n=b/a
 Also, the sum of all of the tempos passed through:
a*i^0 + a*i^1 + a*i^2 + a*i^3 + .... + a*i^(n-1)
 So the average BPM for the whole time is:
(a*i^0 + a*i^1 + a*i^2 + a*i^3 + .... + a*i^(n-1))/n = v (average)
 Seconds per beat is the reciprocal of v times 60, and increments-per-beat
is 10 times that, and n is then B times that, so:
n = 600B/v = 600Bn/SUMk=0->(n-1)(a*i^k)
 if:
n = 600Bn/SUM""""
then:
600B/SUM"""" = 1, or:
600B = (a*i^0 + a*i^1 + a*i^2 ..... + a*i^(n-1))
 dividing by a:
600B/a = i^0 + i^1 + i^2 .... i^(n-1)
  I did some experimenting with constants and found that SUM(k=0->(n-1) i^k
is always equal to:
((i^n)-1)/(i-1)

For example, 1+3+9+27+81+243=364, which is (729-1)/2
 But since i^n=b/a, this sum is also:
((b/a)-1)/(i-1)
 So:
600B/a = ((b/a)-1)/(i-1)
 Yay. Now I know i.
 i = ((b/a - 1)a/600B)+1
 And n is simply the log base i of b/a.
 I round n to an integer, multiply by 100, and that is the delay before
looking up the next tempostructure. Outside of this abstraction, there is
simply a metro that bangs a float multiplying tempo by i at 100 ms until
stopped by the next tempo. Outputting n at all proved to be unnecessary.
  -Chuckk

--
"It is not when truth is dirty, but when it is shallow, that the lover of
knowledge is reluctant to step into its waters."
-Friedrich Nietzsche, "Thus Spoke Zarathustra"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20051026/d7a80647/attachment.htm>
-------------- next part --------------
#N canvas 142 55 744 757 12;
#X floatatom 219 83 5 0 0 0 a - -;
#X floatatom 28 129 5 0 0 0 B - -;
#X floatatom 117 137 5 0 0 0 b - -;
#X obj 81 195 /;
#X obj 141 222 /;
#X obj 104 259 - 1;
#X obj 104 289 /;
#X obj 104 319 + 1;
#X obj 104 355 log;
#X obj 69 286 log;
#X obj 85 390 /;
#X obj 130 80 inlet;
#X obj 41 63 inlet;
#X obj 190 56 inlet;
#X obj 69 229 t f f;
#X obj 120 447 int;
#X obj 85 470 -;
#X obj 85 498 moses 0.5;
#X obj 85 419 t f f;
#X obj 152 553 f;
#X obj 85 557 f;
#X obj 152 580 + 1;
#X obj 297 440 outlet;
#X obj 161 673 outlet;
#X obj 85 527 b;
#X obj 152 526 b;
#X obj 117 108 f;
#X obj 40 104 t b f;
#X obj 85 642 del;
#X obj 85 674 outlet;
#X obj 27 544 r play;
#X obj 27 571 sel 0;
#X msg 27 598 stop;
#X obj 141 248 * 600;
#X obj 85 610 * 100;
#X text 230 183 Inputs (r to l)- old tempo \, new tempo \, beats until
new tempo;
#X text 224 227 Outputs (r to l)- increment to multiply 10x/second
\, number of times to multiply \, bang for next tempo;
#X connect 0 0 4 1;
#X connect 0 0 3 1;
#X connect 1 0 4 0;
#X connect 2 0 3 0;
#X connect 3 0 14 0;
#X connect 4 0 33 0;
#X connect 5 0 6 0;
#X connect 6 0 7 0;
#X connect 7 0 8 0;
#X connect 7 0 22 0;
#X connect 8 0 10 1;
#X connect 9 0 10 0;
#X connect 10 0 18 0;
#X connect 11 0 26 1;
#X connect 12 0 27 0;
#X connect 13 0 3 1;
#X connect 13 0 4 1;
#X connect 14 0 9 0;
#X connect 14 1 5 0;
#X connect 15 0 16 1;
#X connect 15 0 19 1;
#X connect 15 0 20 1;
#X connect 16 0 17 0;
#X connect 17 0 24 0;
#X connect 17 1 25 0;
#X connect 18 0 16 0;
#X connect 18 1 15 0;
#X connect 19 0 21 0;
#X connect 20 0 23 0;
#X connect 20 0 34 0;
#X connect 21 0 23 0;
#X connect 21 0 34 0;
#X connect 24 0 20 0;
#X connect 25 0 19 0;
#X connect 26 0 3 0;
#X connect 27 0 26 0;
#X connect 27 1 4 0;
#X connect 28 0 29 0;
#X connect 30 0 31 0;
#X connect 31 0 32 0;
#X connect 32 0 28 0;
#X connect 33 0 6 1;
#X connect 34 0 28 0;



More information about the Pd-list mailing list