Spectral Substraction for removing noise

2 ビュー (過去 30 日間)
Amirhosein Khanlari
Amirhosein Khanlari 2020 年 1 月 26 日
i have this code buy i get index out of range.how can i fix it
[x,fs]=audioread('NoisyTest.wav');
y=x(1:350,1);
Y=fft(y);
length(Y)
magY=abs(Y);
b=[];
for i=0:2000;
n=350;
x1=x(1+n*i:n+n*i);
X1=fft(x1);
magX=abs(X1);
S=(magX.^2-magY.^2);
S1=abs(S).^0.5;
s1=ifft(S1);
a=s1';
b=[b a];
end
x2=b';
plot(x2);
sound(x2,fs);
audiowrite('13.wav',x2,fs)

回答 (1 件)

Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato 2020 年 1 月 26 日
編集済み: Thiago Henrique Gomes Lobato 2020 年 1 月 26 日
Probably your signal is not long enough for you to use 2000 blocks of 350 samples, you can make your loop signal dependent to avoid this problem:
[x,fs]=audioread('NoisyTest.wav');
y=x(1:350,1);
Y=fft(y);
length(Y)
magY=abs(Y);
b=[];
for i=0:round(length(x)/350)-1;
n=350;
x1=x(1+n*i:n+n*i);
X1=fft(x1);
magX=abs(X1);
S=(magX.^2-magY.^2);
S1=abs(S).^0.5;
s1=ifft(S1);
a=s1';
b=[b a];
end
x2=b';
plot(x2);
sound(x2,fs);
audiowrite('13.wav',x2,fs)

カテゴリ

Help Center および File ExchangeData Import and Network Parameters についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by