Académique Documents
Professionnel Documents
Culture Documents
Assignment # 3 ADSP
Signal Modeling (Levinson-Durban Recursion)
Submitted by:
Maj Muhammad Sajid
NS Asad Rehman
MS (Computer Engineering) - 81
Assignment # 3 Statement
Write the code in C or in Matlab and show its working in the lab or on your laptops .
Take a speech file. For every 256 samples of the file repeat the following:
Generate a 10th order all pole model.
Solve the model using Livenson Durbun recursion.
Write the difference equation using the coefficients obtained in (b)
Generate 256 samples from the difference equation in (c) save these samples
in a file
5. Keep the intermediate samples in the difference equation for the next
iteration
6. Repeat (a) to (e) for next 256 samples until you reach end of the file, append
zeroes in the last iteration if required.
1.
2.
3.
4.
speech file. Code given below fulfills all the requirements given above.
Main Code
%% Assignment3 Maj Muhammad Sajid & NS Asad Rehman
%% Run file MajSajid_NSAsad.m
%% Output Wave File will be generated at 'D:\outputfile.wav'
%% Wave File selected is of length 32768 and has 128 complete Frames of 256 samples, no
requirement of %%appending Zeros.
%% Sampling Frequency is 8KHz and 32 ms frame size gives frame size of 256 Samples
clear all;
%% Reading the input file
[WaveFile, FS, nbits] = wavread('cleanSpeech.wav');
wavplay(WaveFile, FS);
end
FilterCoefficients
% %Playing the output audio
wavplay(Total_output,FS);
% % Plotting the input and output
figure1 = figure;
axes('Parent',figure1,'FontWeight','bold');
box('on');
hold('all');
plot(Total_output - WaveFile');
xlabel('Samples','FontWeight','bold');
ylabel('Error','FontWeight','bold');
title(['Sample by Sample Error b/w Original vs Modeled Signal - Levinson Durbin Algorithm
with M=',num2str(FilterOrder)],'FontWeight','bold');
%% Writing the output audio to a seperate file
wavwrite(Total_output, FS, 'D:\outputfile.wav');
a(1,1) = 1;
tau(1) = - r(2) / epsilon(1) ;
for m = 2:FilterOrder
for l = 1: m-1
gamma(m) = gamma(m) + r(m - l + 1)* a(m-1,l);
end
tau(m) = - gamma(m) / epsilon(m-1);
epsilon(m) = epsilon(m-1)* (1-abs(tau(m))^2);
for k = 1:m
if(k==1)
a(m,k)=1;
else
a(m,k) = a(m-1,k) + tau(m)*a(m-1,m-k+1);
end
end
end
FilterCoefficients = a(FilterOrder, :);
b = numerator coefficients
a = denominator coefficients
x_in = input sample
Y = output sample
x,y = input & output buffers
N_b = length(b);
N_a = length(a);
% shift right input buffer
for n = N_b-1:-1:1
x(n+1) = x(n);
end
% new sample
x(1) = x_in;
% convolution of b(n) and x(n)
y1 = 0;
for k=1:1:N_b
y1 = y1 + b(k)*x(k);
end
% convolution of a(n) and y(n)
y2 = 0;
for k=1:1:N_a
y2 = y2 + a(k)*y(k);
end
% shift right output buffer
for n = N_a-1:-1:1
y(n+1) = y(n);
end
y(1) = y1+y2;
Y = y(1);
end
Output
Frames
a(2)
a(3)
a(4)
a(5)
a(6)
a(7)
a(8)
a(9)
a(10)
Max Error