Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

convert frequency to keyboard note

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

update

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 ?

like image 913
ufk Avatar asked Jun 28 '26 08:06

ufk


2 Answers

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.

like image 192
Flash Avatar answered Jul 01 '26 19:07

Flash


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.

like image 26
xofon Avatar answered Jul 01 '26 19:07

xofon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!