OT : f = 440 * 2>(n/12) -> n = ... help...

Started by
4 comments, last by Afterlife 22 years, 9 months ago
*Whoops just noticed there was a maths forum here too, oh well..* I'm making a "tracker" for my game programming library 'cause there isn't a track player for djgpp that I know of. Could someone see what n is from the algorithm f = 440 * 2>(n/12) (rotate > 90 degrees to the left)? Logarithms aren't my strongest quality... Here's what I came up with in a couple of minutes... : 5f/440 = 10>(n/12) log(f/88)=n/12 n=12*log(f/88) ...which is wrong... yay gads I feel brain dead tonight, can't sort an algorithm this simple... Thanks for replying (hopefully) Peace out! Edited by - Afterlife on June 30, 2001 3:56:33 PM
------------------------------If there be no heaven,may there atleast be a hell.-------------------------------Afterlife-
Advertisement

f = 440 * 2^(n/12)

f/440 = 2^(n/12)

log2(f/440) = (n/12) // I''m using "log2" meaning log base 2

12*(log2(f/440)) = n

n = 12*(log2(f/440))

n = 12*( log(f/440) / log(2) )

Viola.


So logx(y) = log10(y)/log10(x)... interesting...

Anyways, thanks for sorting it out, seemed to do the trick
------------------------------If there be no heaven,may there atleast be a hell.-------------------------------Afterlife-
Working with music, eh? =) FYI, I think MIDI f0 is 13.75 or 27.5, but I''m not sure. Definitely not 440.

Sounds like maybe he is working with MOD files (or some variant).

440 Hz is the frequency for middle A.
Yes, middle A, A3. The formula he quoted is the formula for finding music frequencies in equal-tempered scale tuned to A, but it misses most of the scale. In order to play A0, he''d need a negative value for n. From this page:

http://www.ibiblio.org/emusic-l/info-docs-FAQs/MIDI-doc/MIDI-Primer.txt

"The pitch bytes of notes are simply number of half-steps, with middle C = 60."

So if you want your algorithm to be midi-compliant, you should get middle C with n = 60.

Hence my comment.

This topic is closed to new replies.

Advertisement