I would like to develop an android app to meassure sound pressure level but i am not sure how to implement time weighting. For the moment my algorithm works as follows:
- Record 20ms of audio (160 samples @ 8000Hz)
- Compute RMS
- Calculate SPL
- Update displayed value and start again
Here you can see the main part of the algorithm:
// The Google ASR input requirements state that audio input sensitivity
// should be set such that 90 dB SPL at 1000 Hz yields RMS of 2500 for
// 16-bit samples, i.e. 20 * log_10(2500 / mGain) = 90.
double Gain = 2500.0 / Math.pow(10.0, 90.0 / 20.0);
// This method is called every 20ms:
@Override
public void processAudioFrame(short[] audioFrame) {
// Compute the RMS value.
double rms = 0;
for (int i = 0; i < audioFrame.length; i++) {
rms += audioFrame[i]*audioFrame[i];
}
rms = Math.sqrt(rms/audioFrame.length);
final double rmsdB = 20.0 * Math.log10(rms / Gain) + refSPL;
// refSPL is obtained by calibration with a professional spl meter
}
I know that the grade of sound level meter can be Fast, Slow, or Impulse time weighted. But i am not sure how and where to implement this time weighting in my algorithm.
Q: Does time weighting means after which time i update the meassured dB value?
Q: Should i simply change the update interval to 125ms to get a fast weighted result or am i completly wrong?
Thanks for your support