Last active
August 29, 2015 14:21
-
-
Save suzukiplan/72b59327d492f424bded to your computer and use it in GitHub Desktop.
88鍵ピアノの音階周波数とサンプリング周波数1Hzあたりのラジアン増分を求めて表示
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 88鍵ピアノの音階周波数 & サンプリング周波数1Hzあたりのラジアン増分を求めて表示 */ | |
#include <stdio.h> | |
#define S 44100.00 | |
#define B 1.0594631 | |
#define PI 3.1415926535897932 | |
#define PI2 6.2831853071795864 | |
int main(int argc,char* argv[]) | |
{ | |
const char* t[12]={ | |
"A " | |
,"A#" | |
,"B " | |
,"C " | |
,"C#" | |
,"D " | |
,"D#" | |
,"E " | |
,"F " | |
,"F#" | |
,"G " | |
,"G#" | |
}; | |
double hz[88]; | |
int n=0; | |
double a=13.75; | |
double b; | |
for(n=0;n<88;n++) { | |
if(n%12==0) { | |
a*=2.0; | |
hz[n]=a; | |
} else { | |
hz[n] = hz[n-1] * B; | |
} | |
b=PI2/(S/hz[n]); | |
printf("%s : %9.4fHz : %.4f rad/1Hz\n",t[n%12],hz[n],b); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
結果: