I'm trying to write an audio application.
I can play a cin wave from a frequency of 20 to 20K to hear sounds. my question is how can i convert frequencies to keyboard notes in order to create a virtual keyboard (or piano) ? is there some kind of formula to achieve this ?
The programming language that I use is not important because I don't want to use other tools that calculate it for me. i want to write it myself so i need to understand the math behind it. thanks
i found the following url: http://www.reverse-engineering.info/Audio/bwl_eq_info.pdf
that contains the octave prequency chart. do i need to store that list or is there a formula that can be used instead ?
There are a few different ways to tune instruments. The most commonly used for pianos is the 12 tone equal temperament, a formula for which can be found here. The idea is that each pair of adjacent notes has the same frequency ratio.
See also equal temperament on Wikipedia.
You can calculate frequency of a tone as
f = 440 * exp(x*ln(2)/12)
where x is number of semitones above A in the middle of the piano keyboard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With