How to calculate dB from audio signal amplitude (or its dbFS equivalent)

Hello!

I am a software developer, and I am writing a software to measure the average perceived volume of an MP3 file using ReplayGain algorithm. I don't know that much about that topic myself, so if you know more than me, feel free to explain me any concept I might have misunderstood.

With that out of the way, I'd like to make a brief introduction to this topic:

An audio can be represented as a sequence of amplitude values, that is, numbers ranging from -1 to 1 (basically a wave). The ReplayGain algorithm transform these amplitude values using IIR filters to approximate their "absolute" amplitude with the amplitude for which human hears usually perceive the sound as (based on their frequency [Hz] and their overall power). The ReplainGain website has a great explanation of the application of these filters for those who are interested (see here).

As a last step, we calculate the RMS of the transformed audio samples (a very small fraction of a second of an audio) to find its average value. For audios with multiple channels, we just take the average of their channels.

With that said, how can I convert this average amplitude value to a (positive) dB scale? What do I need to know in advance and to consider when performing such conversion?

I am currently using these two functions I found on the internet to do that:

  • from a simple value: 20 * log10(x+ 1^-10), where x is the amplitude (ranging from -1 to 1)
  • from a squared value: 10 * log10(x + 1^-10), where x is the amplitude

The issue is that these functions convert the amplitude of the audio to dBFS, which is not what I was looking for because users usually expect to see positive dB values, not negative values.

And here am I, asking how can I convert either the amplitude values (-1 to 1) or the dBFS value into the dB scale. If you could explain me how do I figure out what noise floor to use (when calculating dBFS), and how to propertly calculate the dBFS value given the audio amplitude, I would be grateful.

It's important to point out that the software has access to the audio metadata such as bitrate, audio bit depth, etc, so these infos are available (if we need them to calculate these values).

Thanks in advance!
  • Very low bounty!

    • Secretx Secretx
      +1

      Then what value do you think this question is worth? It's my first time using the website, I didn't know a good value to put.

    • If you are looking for someone to read the details you provided and provide a somewhat detailed answer to your question, it will take at least 30 minutes of time. Assuming a $50/hour rate for an expert, that would be at least $25.

Answer

Answers can only be viewed under the following conditions:
  1. The questioner was satisfied with and accepted the answer, or
  2. The answer was evaluated as being 100% correct by the judge.
View the answer
Kav10 Kav10
1.9K
The answer is accepted.
Join Matchmaticians Affiliate Marketing Program to earn up to a 50% commission on every question that your affiliated users ask or answer.