I'm trying to get the impulse response and transfer function of a filter with an exponential sweep.
To do so, I convolved the output of the filter (measure
in my code) with the inverse filter of the sweep (invFilter
).
This should give me the impulse response of the filter.
Then I computed the FFT of this impulse response to get the transfer function of the filter.
You can notice that I'm only keeping a part of the impulse response, because my next step is too measure non-linear system with this method (cf Farina's publications).
invFilter = inverseFilter(fmin,fmax,duration)
print("Calcul de la IR...")
farinaTempIR = np.convolve(measure,invFilter,mode="full")
farinaTempIR = farinaTempIR[sweep.size-1:] * 2
timeFarinaTempIR = np.arange(0,farinaTempIR.size,1) / fs
plt.figure("IR")
plt.plot(timeFarinaTempIR,farinaTempIR,'--',label = "Farina Temp")
plt.legend()
print("Calcul de la TF...")
farinaTempTF = np.fft.rfft(farinaTempIR) / farinaTempIR.size * 2
freqFarinaFreqTF = np.fft.rfftfreq(farinaTempIR.size,1/fs)
plt.figure("Fonction de transfert")
plt.semilogx(freqFarinaFreqTF,20*np.log10(np.abs(farinaTempTF)),'--',label = "Farina Temp")
plt.legend()
But the amplitude of the impulse response isn't correct and so the transfer function (see figures). Maybe I should normalize by a factor, but which one ? number of points? sampling frequency ?
I'm pretty sure the inverse filter is correct. Because when I did the same operation in frequency domain (multiplying the FFT of the measure with the FFT of the inverse filter), I got good results
EDIT : I forget to say, on the figure, the method that gives wrong results is "Farina temp" the other methods are what I'm expecting.