# function for inverting

Ok, I am trying to figure out an equation that will allow me to get the number rhythm vales for a given unit of time (expressed in seconds)...

so my thinking was as follows:

Get the percentage of the tempo and scale it down:

(100 / 60.0 * tempo) * 0.01


... This will take a tempo of 30, and return 0.5... a tempo of 60 returns 1.0, a tempo of 120, 2.0, etc..

Then I need to inverse that so that 60 is actually 1.0, 30 is 2.0, and 120 is 0.5-- since a metronome marking of 30 should take 2x as long as 60... So I used exponents to do this:

(100 / 60.0 * tempo) * 0.01 / (tempo / 60.0) ^ 2


This gives me 1.0 for a tempo of 60, 2.0 for a tempo of 30, 0.5 for a tempo of 120... Exactly what I want.

So the last step now (and what I am struggling with), is to make this related to the rhythmic note value...

So, if I say quarter note = 120, that means there should be 2 quarter notes for every second...

The equation above will already give me 0.5 for a tempo of 120.. So it feels like I am half way there... But I still need to figure out how to get the highest note value... So if there are 2 quarter notes in a second, that should mean there are 4 8ths, 8 16th, 16 32nds, and 32 64ths...

so, if I traverse the list of rhythmic notes, dividing that 0.5 each time.. I should get where I want to be (which is to figure out what 0.5 converts to for 64ths, the fastest note duration)...

...

0.5 / 1 (quarter) = 0.5
0.5 / 2 (8th)     = 0.25
0.5 / 3 (16th)    = 0.166666


..... Ok already I know that is wrong, and I can see why... I don't want to be doing that.. I think what I want to be doing is:

0.5 / 2 (8th) = 0.25
0.5 / 2 / 2 (16th) = 0.125
0.5 / 2 / 2 / 2 (32nd) = 0.0625
0.5 / 2 / 2 / 2 / 2 (64th) = 0.03125


....... And that is where I am stuck.. What can I do to figure out this / 2 / 2 / 2 recursive business? Something tells me this is a logarithm since it's the inverse of an exponent.. but-- I don't quite get how to calculate Log base 2 against this...

-
I've seen your recent question on tempos and scaling - do you have any questions on my answer to the question here? –  Gerry Myerson Sep 20 '12 at 5:07

Now for an $n$th note, you want "240 divided by (tempo times $n$)".
Going the other way, for a half note use $n=2$, for a whole note use $n=1$.