Created
April 23, 2012 19:35
-
-
Save bartolsthoorn/2473295 to your computer and use it in GitHub Desktop.
Measuring dB / max amp in Novocaine
This file contains hidden or 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
[audioManager setOutputBlock:^(float *data, UInt32 numFrames, UInt32 numChannels) | |
{ | |
// Measure dB | |
float maxAmp = abs(data[0]); | |
for (int i=0; i < numFrames; ++i) | |
{ | |
for (int iChannel = 0; iChannel < numChannels; ++iChannel) | |
{ | |
if (abs(data[i*numChannels + iChannel]) > maxAmp) { | |
maxAmp = abs(data[i*numChannels + iChannel]); | |
} | |
} | |
} | |
printf("Maximum Amp in dB: %f\n", 20 * log10f(maxAmp)); | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment