#### Archived

This topic is now archived and is closed to further replies.

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

This topic is 6223 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

*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

##### Share on other sites

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.

##### Share on other sites
So logx(y) = log10(y)/log10(x)... interesting...

Anyways, thanks for sorting it out, seemed to do the trick

##### Share on other sites
Working with music, eh? =) FYI, I think MIDI f0 is 13.75 or 27.5, but I''m not sure. Definitely not 440.

##### Share on other sites

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

440 Hz is the frequency for middle A.

##### Share on other sites
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.

1. 1
2. 2
Rutin
22
3. 3
JoeJ
18
4. 4
5. 5

• 37
• 23
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631705
• Total Posts
3001827
×