How can I calculate audio Decibels?

How can I calculate audio in Decibels using Processing on Java Mode.?


sounds complex to me:
first it depends what you want to do,

if you need to compare two signals and calculate variation, +1db for eg, then you can set a signal as reference and calculate the ratio as you can found it there,can work with audio files, but if input is from microphone, it needs that your audio input is converted linearly by audio card, i will not bet much on that

if you want an absolute value, it’s even more complex, as it is a mesure of energy, it depends on microphone used (mv/db) then convertion of this to values by the audio card

i will try to find a device measuring db, then calibrate the value you get in processing with this mesure (map if it s linear , if not … something more complex)

If you can get the linear volume (0 - 1) then the conversion is:
100 + 20./2.302585092994 * log(x), where x is the linear volume.
Otherwise you need something that can analyze a small window of the sample and calculate the amplitude of the signal. Here is an example that does this using the Pd4P3 library in Processing: Pd4P3 dB Analysis

1 Like