30
D. Rocchesso: Sound Processing
We have seen that an FIR filter is the realization of a convolution between
the input signal and the sequence of coefficients. The computation of this con-
volution can be made explicit in a language such as Octave and, indeed, this
is what we have done in the appendix B.1 for the simple filter of length 2. For
high-order filters it is more convenient to use algorithms that increase the ef-
ficiency of convolution. In Octave, there is the function fftfilt that, given a
vector b of coefficients and an input signal x, returns the output of the FIR
filter
6
. In order to perform this computation, the fftfilt computes an FFT
of the coefficients and an FFT of the input signal, it multiplies the two trans-
forms point by point (convolution in the time domain is multiplication in the
transform domain), and it applies an inverse FFT to the result. Since the FFT
of a length-N sequence has complexity of the order of N log N and the point-
by-point multiply has complexity of the order of N , the convolution computed
in this way has complexity of the order of N log N . For sequences longer than a
few samples, such a procedure is much faster than direct convolution. For even
longer sequences, it is convenient to decompose the sequences into blocks and
repeat the operations block by block. The partial results are then recomposed
by partial addition of neighboring blocks of results. The detailed explanation of
this technique is reported in several signal processing books, such as [67].
Most sound processing languages and real-time sound processing environ-
ments have primitive functions to compute the output of FIR filters. For in-
stance, in SAOL (see appendix B.2) there is the function fir(input, h0, h1,
h2, ...) that takes the input signal and the filter coefficients as arguments.
Example 2. In order to strengthen our understanding of FIR filters, we
approach the design of a 10-th order linear phase filter having unit response at
dc and an attenuation of 20dB at F
s
/6. The impulse response of a 10-th order (or
length 11) filter can be considered as the convolution of the responses of 5 2-nd
order filters. Therefore, it is sufficient to design a length-3 filter with a slighter
attenuation at F
s
/6 and to convolve five copies of this filter. The reader is invited
to design the filter and to experience its effect using a sound processing language
or real-time environment. A related task is the design of a highpass filter of the
same length having a magnitude response that is symmetric to the response of
the lowpass filter. Is there any law of symmetry that relates the coefficients of
the two filters? How are the zeros distributed in the complex plane in the two
cases? A further interesting exercise is the analysis and experimentation of the
frequency response of the parallel connection of the two filters.
Development. The Octave/Matlab script that follows answers most of the
questions. The remaining questions are left to the reader.
global_decl;
plat = platform('octave');
w0=0; A0=1;
% Response at dc
w1=pi/3; A1=0.1^(1/5); % Response at Fs/6 (1/5 of 20 dB)
%% coefficients of the length-3 FIR filter
A = [1 2*cos(w0); 1 2*cos(w1)]; b = [A0; A1];
6
In Matlab, the same function is available in the Signal Processing Toolbox. In any case,
the Octave version fftfilt, avaliable in the web repository of this book, can also be used in
Matlab.
Next Page >>
<< Previous Page
Back to the Table of Contents