Skip to content

Instantly share code, notes, and snippets.

@npisanti
Created June 16, 2019 11:49
Show Gist options
  • Save npisanti/6979e12535ab5e8d60373aa2982f4415 to your computer and use it in GitHub Desktop.
Save npisanti/6979e12535ab5e8d60373aa2982f4415 to your computer and use it in GitHub Desktop.
pitch to frequency and frequency to pitch conversions
#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