Audio Compression with DCT method

조회 수: 5 (최근 30일)
Mohammad Azhar
Mohammad Azhar 2022년 4월 21일
댓글: Mohammad Azhar 2022년 4월 21일
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
Mohammad Azhar
Mohammad Azhar 2022년 4월 21일
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')

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio I/O and Waveform Generation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by