Effacer les filtres
Effacer les filtres

I am simulating a DPCM transmitter and receiver with a 5th order predictor and a 4-bit mid-riser quantizer using a recorded sound file, and the code is as follow:

1 vue (au cours des 30 derniers jours)
clc;
clear all;
close all;
y=audioread('MySpeech.wav'); %audioread used to read our speech signal
sound(y); %plays the recorded sound
subplot(3,1,1),
plot(y);
title('recorded voice signal');
grid;
n=length(y);
rxx=xcorr(y); %auto-correlation vector of y
o=5; % order of the predictor
rx=rxx(n+1:n+o); %autocorrelation for the audio signal
R=rxx(n:n+o-1); %autocorrelation vector
Rxx=toeplitz®; %symmetric Toeplitz matrix for real R. Hermitian matrix.
alpha=-inv(Rxx)*rx; %predictor parameter
Vpp=max(y);
delta=2*Vpp/16; %to calculate stepsize
x_t=zeros(1,o); %1*P matrix of zeros
c=zeros(1,n+o);
x_c=zeros(1,n+o);
%transmitter of DPCM
for p=o+1:n+o
for j=16:o % to calculate output of predictor
x_c(p)=x_c(p)-x_t(p-j)*alpha(j);
end;
d(p)=y(p-o)-x_c(p); %to calculate differential input
fori=1:(16/2) % loop to calculate output of quantizer
if((i-1)*delta<=d(p) && d(p)<(i)*delta &&i<(16/2))
d_c(p)=(i-0.5)*delta;
elseif (d(p)>=(i-1)*delta)
d_c(p)=(i-0.5)*delta;
elseif (d(p)< -(i-1)*delta)
d_c(p)= -(i-0.5)*delta;
elseif (-(i+1)*delta<=d(p) && d(p)<-(i)*delta &&i<(l/2))
d_c(p)=-(i-0.5)*delta;
end;
end;
x_t(p)=d_c(p)+x_c(p); %to calculate input of predictor
if(d_c(p)>=0) % to calculate output of encoder
c(p)=((d_c(p)/delta)-0.5);
else
c(p)=(abs((-d_c(p)/delta))-0.5)+(16/2);
end;
subplot(3,1,2)
plot(d);
sound(d)
title('transmitted signal');
grid;
cTx=dec2bin(c,4); %decimal to binary conversion
%receiver of DPCM
cRx=bin2dec(cTx); %binary to decimal conversion
ydr=zeros(1,o); %1*P matrix of zeros
y_cr=zeros(1,n+o);
for p=o+1:n+o
for j=1:o
y_cr(p)=y_cr(p)-ydr(p-j)*alpha(j);%to calculate output of prediction
end;
fori=0:16-1 % to calculate output of decoder
if (cRx(p)==i)
j=i;
if (cRx(p)<(16/2))
d_cr(p)=(j+0.5)*delta;
elseif (cRx(p)>=(16/2))
d_cr(p)=-((j-(16/2))+0.5)*delta;
end;
break;
end;
end;
ydr(p)=d_cr(p)+y_cr(p); %to calculate input of predictor
subplot(3,1,3)
plot(ydr);
title('reconstructed voice signal');
grid;
sound(ydr);
#################
and i am getting this message:
would anyone please help me solving this problem pleeeeease

Réponses (0)

Catégories

En savoir plus sur Audio Processing Algorithm Design dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by