# How can I calculate audio Decibels?

**URL:** <https://discourse.processing.org/t/how-can-i-calculate-audio-decibels/31248>\
**Category:** Libraries\
**Created:** [July 14, 2021, 1:28pm UTC](https://discourse.processing.org/t/how-can-i-calculate-audio-decibels/31248 "2021-07-14T13:28:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ankur](https://avatars.discourse-cdn.com/v4/letter/a/91b2a8/32.png) [@ankur](https://discourse.processing.org/u/ankur)\
**Post date:** [July 14, 2021, 1:28pm UTC](https://discourse.processing.org/t/how-can-i-calculate-audio-decibels/31248/1 "2021-07-14T13:28:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![th75](https://avatars.discourse-cdn.com/v4/letter/t/ebca7d/32.png) [@th75](https://discourse.processing.org/u/th75)\
**Post date:** [July 15, 2021, 11:59pm UTC](https://discourse.processing.org/t/how-can-i-calculate-audio-decibels/31248/2 "2021-07-15T23:59:30Z")

</div>

hi,

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](https://en.wikipedia.org/wiki/Decibel),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](https://processing.org/reference/map_.html) if it s linear , if not … something more complex)

---

<div class="post-metadata">

**Author:** ![robertesler](https://avatars.discourse-cdn.com/v4/letter/r/ec9cab/32.png) [@robertesler](https://discourse.processing.org/u/robertesler)\
**Post date:** [July 21, 2021, 2:48pm UTC](https://discourse.processing.org/t/how-can-i-calculate-audio-decibels/31248/3 "2021-07-21T14:48:41Z")

</div>

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](https://github.com/robertesler/Pd4P3/tree/main/examples/Analysis/Decibels)
