Created
June 16, 2019 11:49
-
-
Save npisanti/6979e12535ab5e8d60373aa2982f4415 to your computer and use it in GitHub Desktop.
pitch to frequency and frequency to pitch conversions
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
#define TUNINGFREQ 440.0 | |
float p2f( float pitch ){ | |
return pow( 2.0, (pitch-69.0)/12.0 ) * TUNINGFREQ; | |
} | |
float f2p( float freq ){ | |
return (log2( freq / TUNINGFREQ ) * 12.0f ) + 69.0f; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment