Created
April 1, 2017 19:55
-
-
Save merryhime/ba6b5f78b8f57066dcd544b9a2d5fd62 to your computer and use it in GitHub Desktop.
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
// Note that our hearing is logarithmic. | |
// 0 dB = 1.0 | |
// For the below equations, ratio refers to the amplitude ratio. | |
// 0 dB = same power = same amplitude = same psycho-acoustic volume | |
// -3 dB = half power | |
// -6 dB = half amplitude | |
// -10 dB = half psycho-acoustic volume = 32% amplitude | |
double dB_to_ratio(double dB) { | |
return exp(10.0, dB / 20.0); | |
} | |
double ratio_to_dB(double ratio) { | |
return 20.0 * log10(ratio); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment