this is my first post here, so ... nice to meet you (and forgive my English)
I'm trying to understand how audacity peak meter works, and so far these are my knowledges:
1) the "core" thing is into Meter::UpdateDisplay(int numChannels, int numFrames, float *sampleData)
2) the formula: average of a window of samples (something like 1/10 seconds of audio data), then 20 * log10 (fabs(average of samples))
Now, let's take for example a sine wave with a -1.0 / 1.0 range of amplitude and apply the formula 2): the average will be something like 0.6 which means a value of -4.4 dB (values very approximated). This is obviously NOT the maximum. So why Audacity displays correctly a peak in its meter, drawing the bar exactly at 0 dB? Maybe the secret lies into ClipZeroToOne(float) or the strange conversion (db + range) / range, which I can't understand completely?
Thank you in advance for any suggestion!