The software estimates how loud the sound is by using an algorithm devised by David Robinson (
http://replaygain.hydrogenaudio.org/equal_loudness.html that takes into account how it sounds to a person. This way we can increase the gain on hard to hear sounds, and reduce the gain on sounds that a person is very sensitive to.
The loudness estimator, implemented in the Analysis procedure in GainAnalysis.cs, uses the following algorithm:
- Uses a combination of two (IIR) filters to make the sound to reflect how our ears hear it.
- Compute the Mean-Square value of the filtered sound (called MS)
- Track the last 750 ms of these values.
- Make a sorted copy of these.
- Retrieve the first non-zero value at least 95% of the way into the buffer. This is so that we don’t take the loudest sample and assume that is how the person is talking.
- If MS (the value computed in step 2) is much quieter, use that one instead
- Convert this value into dB scale by performing a logarithm on it.
To “normalize” the sound into how a person hears, the sound is first sent thru a yulewalk filter (implemented as an IIR). The output of the yulewalk filter is then fed into a 150Hz high pass filter.