I am new to signal processing.

I have a signal that I want to convert to dB, process and then transform back.

My understanding of the transformation to dB scale is

$X_\mathrm{db} = 20 \cdot \mathrm{log}_{10}(|X|)$ and therefore $|X| = 10^{X_\mathrm{db} / 20}$

However, when calculating the reverse of my audio the sample sounds distorted. See reproducible example below

Can someone explain why this occurs?

import wget
import os
import librosa
import IPython.display

filepath = str(os.getcwd()+"/metallic-drums.wav")
wget.download("https://tinyurl.com/wx9amev", filepath)

MD, sr = librosa.load('metallic-drums.wav')

#Playing the orginal file
IPython.display.Audio(MD, rate = sr)

#Chaning to db
MD_db = librosa.amplitude_to_db(MD)
#Changing back to amp
MD_r = librosa.db_to_amplitude(MD_db)

#Play the result
IPython.display.Audio(MD_r, rate = sr)
  • 1
    $\begingroup$ What does SAP stand for? $\endgroup$
    – Engineer
    Apr 8 '20 at 21:46
  • $\begingroup$ Apologies - Signal Audio Processing. I have amended. $\endgroup$
    – Sean Mci
    Apr 9 '20 at 17:25

Consider that you're calculating the dB value of the magnitude of the signal, which is the absolutely value of the amplitude. By taking the magnitude, you've discarded the sign, as you're interesting only in the size, not direction. So, you can't recover the signs. That means this will work only for positively-offset signals.

But also, we are not usually interested in the dB value of a signal on a sample-by-sample basis. We use dB to express a ratio, perhaps relative to full scale, on a log scale to match our ears' perception, and typically of a bigger picture. For instance, the peak, average, or RMS magnitude of a an entire sound file, or a moving average of that so we can see how a signal is changing over time. As such, we don't normally care about deriving the signal from it.


You have the abs(X) in the formula, which is not a reversible operation.

All the negative values in the original audio sample has been converted to positive.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.