Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I implement the piano key frequency function in C#?

How can I implement the following function in C#?

alt text

like image 696
Alon Gubkin Avatar asked Dec 11 '09 23:12

Alon Gubkin


3 Answers

double F = 440.0 * Math.Pow(2.0, (n-49.0)/12.0);
like image 179
Khaled Alshaya Avatar answered Nov 18 '22 20:11

Khaled Alshaya


440 * Math.Pow(Math.Pow(2, 1.0/12), n - 49)
like image 23
Yuriy Faktorovich Avatar answered Nov 18 '22 19:11

Yuriy Faktorovich


440 * 12th root of 2 raised to n-49 
 = 440 * (2 ^ 1/12) ^(n-49)
 = 440 * 2^(n/12) / 2^(49/12)
 = 440 * 2^(n/12) / (2^4 * 2^1/12)
 = 440 * ( 1 / 2^4 ) * 2^((n-1) /12)
 = 8 * 55 * ( 1/16 ) * 2^((n-1) /12)
 = 27.5 * 2^((n-1) /12)

so ....

double d = 27.5 * Math.Pow(2, (n-1) / 12.0)

And since 12th root of 2 = 1.0594630943592952645618252949463, then

double d  = 27.5 * Math.Pow(1.0594630943592952645618252949463, (n-1))

so...

 double d = 27.5 * Math.Pow(1.059463094359295, (n-1));
like image 2
Charles Bretana Avatar answered Nov 18 '22 21:11

Charles Bretana