Audio Compression with DCT method

5 Ansichten (letzte 30 Tage)
Mohammad Azhar
Mohammad Azhar am 21 Apr. 2022
Kommentiert: Mohammad Azhar am 21 Apr. 2022
I'm working on Audio Compression using DCT and I got this error
Array indices must be positive integers or logical values.
Error in cobadct (line 23)
frame=y([(framesize*(i-1)+1):framesize*i]);
How can I fix this error?
  1 Kommentar
Mohammad Azhar
Mohammad Azhar am 21 Apr. 2022
clc
clear
[y,Fs] =audioread('nokia.wav')
N=length(y);
[f0,idx] = pitch(y,Fs);
subplot(2,1,1)
plot(y)
ylabel('Amplitude')
xlabel('Sample Number')
x=[y];
n=round(length(x)/40);
p=zeros(n,40);
for k=0:39
p(:,k+1)=x(1+n*k:n*(k+1));
end
framesize=N/Fs;
M=round(y/framesize);
for...
i=(M)
if (i==M)
frame=y([(framesize*(i-1)+1):length(y)]);
else
frame=y([(framesize*(i-1)+1):framesize*i]);
end
end
X=dct(y,32768);
s=framesize*X;
b=length(s');
ratio=N/b;
A=idct(X,y);
[rows,columns]= size(A)
extra = rows*ceil(numel(A)/rows) - numel(A);
MU=reshape([X(:);nan(extra,1)],rows,columns)
for...
i=M
if (i==M)
frame1=MU([(framesize*(i-1)+1):length(MU)]);
else
frame1=MU([(framesize*(i-1)+1):framesize*i]);
end
end
[R,C]= size(y);
err = (((y-MU).^2)/(R*C)); % error in this line
MSE=sqrt(err)
subplot(2,1,2)
plot(MU)
ylabel('Amplitude')

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by