0
$\begingroup$

I am curious to know the relation between the 16-bit amplitude values in the PCM-encoded signal and the values inside the corresponding spectrogram. I am using Scipy reading a 44100-sample rate song:

from scipy import signal
from scipy.io import wavfile


sample_rate, samples = wavfile.read('some_song.wav')
freq, times, spectrogram = signal.spectrogram(samples, sample_rate, window='hamming',
                                                             nperseg=4410, noverlap=0)

The integer values of samples (in my song) is [-15039, 16432] which I interpret as the relative amplitude level at the particular sample.

However, the integer values of the spectrogram ranges from [0, ~16.7 million]

Can someone explain the relation between those intervals? I guess they're both saying something about the amplitude.

Thanks

$\endgroup$

1 Answer 1

1
$\begingroup$

Spectrogram contains magnitude values only, that explains why the values start at 0 instead of some negative value. And scipy seems to calculate it with 24bit accuracy, where $2^{24}\approx 16.7\cdot10^6$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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