LPF FP
LPF FP
warning('off','all')
[V,Fs] = audioread('D:\LABS\PES\Comb_Filter_Design\Voice.m4a');
%sound(V,Fs);
[N,Fs] = audioread('D:\LABS\PES\Comb_Filter_Design\Noise6.m4a');
%sound(N,Fs);
Fs = 10000;
audiowrite('Voice_write.wav',V,Fs)
audiowrite('Noise_write.wav',N,Fs)
[V,Fs] = audioread('D:\LABS\PES\Comb_Filter_Design\Voice_write.wav');
[N,Fs] = audioread('D:\LABS\PES\Comb_Filter_Design\Noise_write.wav');
f = 50;
Ts=1e-04;
w = 0.01*sin(2*pi*f*Ts*[0:(length(y)-1)]'); %Pure Sinusoidal signal
yn=y+w;
V1 = 10*V(50000:54000);
N1 = N(50000:54000)+yn(1000:5000);
X = V1+N1;
plot(X)
title ("Noisy Signal")
1
GENERATING THE FILTER COEFFICIENTS
h2 = struct2cell( h1 );
h = cell2mat( h2 );
W = 8
hmax = 0.1871
b = log((2^(W-1)-1)/hmax)
2
b = 6.5204
b = 6
ht = 1×32
-0.0001 0.0001 0.0003 0.0004 0.0003 0.0001 -0.0002 -0.0004
eh = 100*(h-double(hf))./h;
ex = 100*(X-double(Xf))./X;
ey = 100*(yfloat-double(yfixed))./yfloat;
bar(eh)
title("Error in Filter Coefficients values")
3
bar(ex)
title("Error in Filter Input values")
bar(ey)
title("Error in Filter Output values")
4
plot(yfloat) % Filtered signal using the floating point representation
title ("Filtered Signal in Floating Point")
5
plot(yfixed) % Filtered signal using the fixed point representation
title ("Filtered Signal in Fixed Point")
6
Here we shall see the results of filtering with fixed point coefficients and the comparison of plots for different
word lengths and the corresponsing fraction length hence obtained.
W = 16
hmax = 0.1871
b = log((2^(W-1)-1)/hmax)
b = 12.0734
b = 12
ht = 1×32
10-4 ×
-0.0139 0.0149 0.0423 0.0568 0.0503 0.0211 -0.0235 -0.0691
eh = 100*(h-double(hf))./h;
ex = 100*(X-double(Xf))./X;
ey = 100*(yfloat-double(yfixed))./yfloat;
bar(eh)
title("Error in Filter Coefficients values")
7
bar(ex)
title("Error in Filter Input values")
8
bar(ey)
title("Error in Filter Output values")
9
plot(yfloat) % Filtered signal using the floating point representation
title ("Filtered Signal in Floating Point")
10
plot(yfixed) % Filtered signal using the fixed point representation
title ("Filtered Signal in Fixed Point")
11
% For a Word Length of 32
W = 32
W = 32
hmax = 0.1871
b = log((2^(W-1)-1)/hmax)
b = 23.1638
b = 23
ht = 1×32
10-7 ×
-0.0068 0.0073 0.0206 0.0277 0.0245 0.0103 -0.0115 -0.0337
eh = 100*(h-double(hf))./h;
ex = 100*(X-double(Xf))./X;
ey = 100*(yfloat-double(yfixed))./yfloat;
bar(eh)
title("Error in Filter Coefficients values")
12
bar(ex)
title("Error in Filter Input values")
13
bar(ey)
title("Error in Filter Output values")
14
plot(yfloat) % Filtered signal using the floating point representation
title ("Filtered Signal in Floating Point")
15
plot(yfixed) % Filtered signal using the fixed point representation
title ("Filtered Signal in Fixed Point")
16
The error converges to a very small value for Word length 32 , Thus as the word length increases error reduces
and filtered signal becomes more accurate.
17