Digital Signal Processing Reference
In-Depth Information
frequency components and the high frequency components. The MATLAB list for the simulation is
shown in Program 8.11.
Program 8.11. MATLAB program for the digital audio equalizer.
close all; clear all
% Filter Coefficients (Butterworth type designed using the BLT)
B0 ¼ [0.0031954934 0 -0.0031954934]; A0 ¼ [1.0000000000 -1.9934066716 0.9936090132];
B1 ¼ [0.0063708102 0 -0.0063708102]; A1 ¼ [1.0000000000 -1.9864516324 0.9872583796];
B2 ¼ [0.0126623878 0 -0.0126623878]; A2 ¼ [1.0000000000 -1.9714693192 0.9746752244];
B3 ¼ [0.0310900413 0 -0.0310900413]; A3 ¼ [ 1.0000000000 -1.9181849043 0.9378199174];
B4 ¼ [0.0746111954 0.000000000 -0.0746111954];
A4 ¼ [1.0000000000 -1.7346085867 0.8507776092];
B5 ¼ [0.1663862883 0.0000000000 -0.1663862884];
A5 ¼ [1.0000000000 -1.0942477187 0.6672274233];
B6 ¼ [0.3354404899 0.0000000000 -0.3354404899];
A6 ¼ [1.0000000000 0.7131366534
0.3291190202];
[h0,f] ¼ freqz(B0,A0,2048,44100);
[h1,f] ¼ freqz(B1,A1,2048,44100);
[h2,f] ¼ freqz(B2,A2,2048,44100);
[h3,f] ¼ freqz(B3,A3,2048,44100);
[h4,f] ¼ freqz(B4,A4,2048,44100);
[h5,f] ¼ freqz(B5,A5,2048,44100);
[h6,f] ¼ freqz(B6,A6,2048,44100);
loglog(f,abs(h0),f,abs(h1), f,abs(h2), .
f,abs(h3),f,abs(h4),f,abs(h5),f,abs(h6));
xlabel( ' Frequency (Hz) ' );
ylabel( ' Filter Gain ' );grid
axis([10 10^5 10^(-6) 1]);
figure(2)
g0 ¼ 10;g1 ¼ 10;g2 ¼ 0;g3 ¼ 0;g4 ¼ 0;g5 ¼ 10;g6 ¼ 10;
p0 ¼ 0;p1 ¼ pi/14;p2 ¼ 2*p1;p3 ¼ 3*p1;p4 ¼ 4*p1;p5 ¼ 5*p1;p6 ¼ 6*p1;
n ¼ 0:1:20480;
% Indices of samples
fs ¼ 44100;
% Sampling rate
x
¼
sin(2*pi*100*n/fs)
þ
sin(2*pi*200*n/fs
þ
p1)
þ .
sin(2*pi*400*n/fs
þ
p2)
þ
sin(2*pi*1000*n/fs
þ
p3)
þ .
sin(2*pi*2500*n/fs
þ
p4)
þ
sin(2*pi*6000*n/fs
þ
p5)
þ .
sin(2*pi*15000*n/fs
þ
p6);
% Generate test audio signals
y0
¼
filter(B0,A0,x);
% Bandpass filter 0
y1
filter(B1,A1,x); % Bandpass filter 1
y2 ¼ filter(B2,A2,x); % Bandpass filter 2
y3 ¼ filter(B3,A3,x); % Bandpass filter 3
y4 ¼ filter(B4,A4,x); % Bandpass filter 4
y5 ¼ filter(B5,A5,x); % Bandpass filter 5
y6 ¼ filter(B6,A6,x); % Bandpass filter 6
y ¼ g0.*y0 þ g1.*y1 þ g2.*y2 þ g3.*y3 þ g4.*y4 þ g5.*y5 þ g6.*y6 þ x; % Equalizer output
N ¼ length(x);
Axk ¼ 2*abs(fft(x))/N;Axk(1) ¼ Axk(1)/2; % One-sided amplitude spectrum of the input
f ¼ [0:N/2]*fs/N;
¼
Search WWH ::




Custom Search