Professional Documents
Culture Documents
Example 1: Low-Pass Filtering by FFT Convolution
A plot of the synthesized input signal is shown in Fig.7.3. Next we design the lowpass
filter using the window method:
% Filter parameters:
L = 257; % filter length
fc = 600; % cutoff frequency
% Design the filter using the window method:
hsupp = (-(L-1)/2:(L-1)/2);
hideal = (2*fc/Fs)*sinc(2*fc*hsupp/Fs);
h = hamming(L)' .* hideal; % h is our filter
The final acyclic convolution is the inverse transform of the pointwise product in the
frequency domain. The imaginary part is not quite zero as it should be due to finite
numerical precision:
y = ifft(Y);
relrmserr = norm(imag(y))/norm(y) % check... should be zero
y = real(y);
Figure 7.7: Filtered output signal, with close-up showing the filter start-up transient (``pre-ring'').
Figure 7.7 shows the filter output signal in the time domain. As expected, it looks like
a pure tone in steady state. Note the equal amounts of ``pre-ringing'' and ``post-
ringing'' due to the use of a linear-phase FIR filter.8.1
For an input signal approximately samples long, this example is 2-3 times faster
than the conv function in Matlab (which is precompiled C code implementing time-
domain convolution).
``Spectral Audio Signal Processing'', by Julius O. Smith III, (March 2010 Draft).
Copyright © 2010-08-13 by Julius O. Smith III
Center for Computer Research in Music and Acoustics (CCRMA), Stanford University