rserota / wad

Web Audio DAW. Use the Web Audio API for dynamic sound synthesis. It's like jQuery for your ears.
MIT License
1.88k stars 160 forks source link

How to get the decibel from audio meter ? #126

Closed RizkyArifNur closed 3 years ago

RizkyArifNur commented 3 years ago

I've implemented the code(same as the example on ReadMe) to get the volume with Poly Wad, but when I compare the result with the decibel meter from another app it shows that the result is very different, and I also checked the average decibel value of human speech is about 60dB, but the result from PolyWad is about 200-300dB, is this correct behavior?

rserota commented 3 years ago

Yes, you are seeing the correct behavior, but there might be some confusion about the units used here. You're talking about acoustic decibels. When working with digital audio, you'd typically be using dBFS, where the max value is 0dB. The actual values produced by the audio meter in WadJS are root mean squared measurements, which should range from 0 to 1 (values over 1 mean the audio signal is clipping). In the example in the readme, the values are multiplied by 1000 before being logged to the console, because I figured that for a quick visualization, it would be easier to read numbers ranging from 0-999 than to read numbers ranging from 0.001 to 0.999.

I hope that clears things up for you.

RizkyArifNur commented 3 years ago

Awesome! that was very clear to me, thank you for the explanation!