1
$\begingroup$

Given a .wav file that is a LTI system's response to an impulse, what would you recommend as the simplest way to plot the frequency and phase output of the system? I'm already working in Python, so python-based solutions are welcome but alternatives are fine too.

$\endgroup$

2 Answers 2

1
$\begingroup$

The frequency response for a discrete time system is a continuous function in frequency, specifically it is the Discrete Time Fourier Transform (DTFT), not the DFT which is discrete in frequency (the FFT is just an algorithm to return the exact DFT solution). The DFT will be samples on the DTFT, so one approach is to zero pad the time domain impulse response first prior to using the FFT, since the DTFT is the DFT with the time and frequency axis extending to infinity. This is easily done by including the optional length parameter in the fft function: fft(x,N), such that if $N$ exceeds the length of $x$ the waveform will be automatically zero padded. Thus zero padding in time will interpolate more samples in frequency, approaching the continuous DTFT as more zeros are added.

The function freqz in Matlab, Octave and Python scipy.signal is the approach I would recommend, since it will return the DTFT when only numerator (FIR) coefficients are provided. Additionally it returns the properly scaled frequency axis with flexibility on how many samples to use.

$\endgroup$
1
$\begingroup$

The Frequency Response is the Fourier Transform of the Impulse Response.

So, for impulse response $h[n]$, compute $H[k] = \texttt{FFT}\{h[n]\}$, then the magnitude response is the absolute value $\lvert H[k]\rvert$ and the phase response is the angle $\angle H[k]$.

There are lots of packages than can do this. Here is working python example using Numpy. Alternatively, you can also take a look at scipy.signal.freqz (numerator is $h$ and denominator is $1$).

$\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.