faiface / beep

A little package that brings sound to any Go application. Suitable for playback and audio-processing.
MIT License
2.08k stars 152 forks source link

Decibel calculation #26

Closed lordwelch closed 6 years ago

lordwelch commented 6 years ago

At hydrogenaudio for ReplayGain they calculate decibels as

10^(gain in dB/20) Or, in words, ten raised to the power of one-twentieth of replay gain.

So Replay gain only works with their equation. Is 10^(gain in dB/10) in your documentation wrong or is that just their own calculation.

In order to adjust volume along decibells, pick 10 as the Base and set Volume to dB/10.

faiface commented 6 years ago

If I'm reading the wiki correctly, my formula is correct: https://en.wikipedia.org/wiki/Decibel, so it's probably just their own hack.

lordwelch commented 6 years ago

So I did a little bit of research through Wikipedia on it, turns out neither is technically wrong but ReplayGain appears to be correct. If you look at the table on the right hand side of the Decibel page it has the conversion from dB to Power ratio and to Amplitude ratio which you can test and Power ratio is 10^(dB/10) and Amplitude ratio is 10^(dB/20). So that is why you didn't get the same equation that the ReplayGain people have.

Now Power ratio maps to Sound power and Amplitude ratio maps to Sound pressure. and this pdf explains the difference between the two http://www.sengpielaudio.com/SoundPressureAndSoundPower.pdf Basically power level is a measure of how much sound something makes and pressure level is a measure of how much noise you hear so in almost all cases it seems that someone would want Sound pressure which is 10^(gain in dB/20)