100 6. REAL-TIME FILTERING
Also, note that as a result of coefficient quantization, the actual frequency response
O
H
e
j
would become different than the desired frequency response H
e
j
. For example,
for an FIR filter having N coefficients, it can be easily shown that the amount of error in the
magnitude of the frequency response,
ˇ
ˇ
H
e
j
ˇ
ˇ
, is bounded by
ˇ
ˇ
ˇ
H
e
j
ˇ
ˇ
ˇ
D
ˇ
ˇ
ˇ
H
e
j
O
H
e
j
ˇ
ˇ
ˇ
N 2
b
: (6.1)
6.5 REFERENCES
[1] J. Proakis and D. Manolakis, Digital Signal Processing: Principles, Algorithms, and Appli-
cations, Prentice Hall, 1996. 99
L6 LAB 6:
REAL-TIME FIR FILTERING, QUANTIZATION
EFFECT, AND OVERFLOW
e purpose of this lab is to design and then run an FIR filter written in C on the ARM proces-
sor of a smartphone. Also, the quantization effect and overflow are examined. e application
shells introduced in the previous labs are used here for collecting audio signal, passing a sampled
signal to a C code segment for filtering, and saving the output to a file for analysis. e design of
the FIR filter, i.e., generation of filter coefficients, is realized using the MATLAB filter design
tool. Other filter design tools may be used for the generation of filter coefficients. e lab ex-
periment involves the implementation of this filter in C code. e base application shell is used
here to insert the filtering C code. Note that the previous lab provided a floating-point C code
implementation of FIR filtering while the fixed-point C code implementation of FIR filtering
is covered here.
L6.1 FILTER DESIGN
To generate the filter coefficients, the Parks–McClellan method is used to design a lowpass filter
for the specifications stated below.
rpass = 0.1; %passband ripple
rstop = 20; %stopbad ripple
fs = 44100; %sampling frequency
f = [1600 2400]; %cutoff frequencies
a = [1 0]; %desired amplitudes
%compute deviations
dev = [(10^(rpass/20)-1)/(10^(rpass/20)+1) 10^(-rstop/20)];
L6. LAB 6: REAL-TIME FIR FILTERING, QUANTIZATION EFFECT, AND OVERFLOW 101
[n,fo,ao,w] = firpmord(f,a,dev,fs); %estimate filter parameters
B = firpm(n,fo,ao,w); %generate filter coefficients
is code creates an array of n C 1 double precision filter coefficients meeting the above spec-
ifications. In order to confirm that the filter matches the specifications, a synthesized signal is
considered for testing via the following MATLAB code (see Figure L6.1). is code synthe-
sizes a sinusoidal signal composed of three frequency components. e signal gets filtered and
the spectrum of the input and output signals are displayed along with the frequency response of
the filter.
ts = 1/fs; %sample time
ns = 512; %number of fft points
t = [0:ts:ts*(ns-1)];
%generate test signal to verify filter
f1 = 750;
f2 = 2500;
f3 = 3000;
x = sin(2*pi*f1*t) + sin(2*pi*f2*t) + sin(2*pi*f3*t);
%plot fft of synthesized signal
X = abs(fft(x,ns));
X = X(1:length(X)/2);
frq = [1:1:length(X)];
subplot(3,1,1);
plot(frq*(fs/ns),X);
grid on;
%plot normalized frequency of filter
A = 1;
[h,w] = freqz(B,A,512);
subplot(3,1,2);
plot(w/(2*pi),10*log(abs(h)));
grid on;
%plot fft of filtered signal
Y = filter(B,A,x);
Y = abs(fft(Y,ns));
Y = Y(1:length(Y)/2);
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.90.141