I'm trying to "standardize" the results of the fast Fourier transformation. I've one wav with two peaks (3000 and 3300 Hz) saved with three different encodings(int16, float32, int32).
And these are the scipy.fft plots:
It's clear enough that, while the peaks are coherent at 3000 and 3300Hz, their amplitudes are not so coherent.
I tried to "standardize" the amplitudes with a logarithmic scale, since using a dbFS worked fine in the time domain using the following code:
data=*array containing file.wav data*
data_log=20*log10(data/max_value_of_dtype)
The problem is that once I clean the signal with some filters and use scipy.fft I obtain only a float64 array "losing" information about the encoding and its scale.
Since they represent the same exact signal (even if with different types of encoding) I was expecting the same values of amplitudes with a logarithmic scale like:
fft_data=scipy.fft.fft(wav_audio_data)
fft_mod=numpy.abs(fft_data)
20*log10(fft_mod/max_value_of_fft_mod)
but I didn't obtain the expected result.
My best guess is, for now, re-encoding the wav file in run time to an "arbitrary" standard (for example at int16) and then calculate fft and stuff like that even if with this method the information about different types of encoding would be useless.
Am I missing something? I mean of course, different encodings means different "bit depth" but still they should represent the same signal. I tried different approaches and solutions to have a sort of "universal" dB scale but once I change encoding they stop working.
soundfile
for loading audio files then the returned array will be automatically stored in -1/+1 range, independently from the original bit-depth. This way you won't have to worry about scaling. Alternatively, you can do this normalization upon loading yourself. $\endgroup$