ピッチと周波数の相互変換
C4を60、440Hzを69としたとき(MIDIの仕様通り) $ P2F(p) = 440 \cdot 2^{\frac{p-69}{12}}
$ F2P(f) = 12 \cdot \log_2 \frac{f}{440} + 69
code:glsl
#define p2f(i) (440.*exp2(((i)-69.)/12.)) #define f2p(i) (12.*(log2(i/440.))+69.) https://gyazo.com/6900c0ec6116919646298d02267162fb
凡例
table:p2f
pitch key freq
24 C1 32.70 Hz
36 C2 65.41 Hz
48 C3 130.81 Hz
60 C4 261.63 Hz
72 C5 523.25 Hz
84 C6 1046.50 Hz
96 C7 2093.00 Hz