I'm sampling a 16-bit PCM audio signal at 44100 Hz and I'm trying to understand the amplitude level of both the digital audio signal and its corresponding spectrum. The final goal is creating audio fingerprints for visualization and sound comparison. By now, I'm conscious I'm not calibrating my hardware so that dB scale is just a relative measurement to itself
First, for the 16-bit PCM audio signal I do understand the signal (Audio ADC lectures) ranges from -32768 to 32767, scaled to [-1 to 1) sig_scaled = sig_int16 / 32768
so that both -32768 and 32767 correspond to the maximum amplitude in db (0 db):
max_db = 20*np.log10(abs(+-1))= 0 dB
*Here, I do also understand it could be scaled to [0, 1) sig_scaled=(sig_int16-+32768)/65536
Meanwhile, the minimum one (~96db) corresponds to:
min_db = 20*np.log10(1/65536) ~= -96 dB
- Which scaling is better [-1 to 1) or [0 to 1)?
- How to avoid the
"RuntimeWarning: divide by zero encountered in log10"
when the ADC lecture or sig_int16 value is 0?
I think [-1,1) makes more sense since a sine wave goes from -1 to 1 but the obtained spectograms for both scales are similar.
Second, regarding the spectrum I've performed an stft on the [-1, 1) scaling, obtaining the following image (stft_db = 20*np.log10(stft/np.max(stft))
):
- What's the meaning of the -159.93 dB minimum and 0 dB maximum value? / Shouldn't the minimum value be -96 dB or bigger?
- Which scaling ([-1, 1), [0, 1) or dB amplitud) should the STFT be performed on?
Thank you folks, let me know if you need more explanations or code!