Spectral Substraction for removing noise
3 views (last 30 days)
Show older comments
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)
0 Comments
Answers (1)
Thiago Henrique Gomes Lobato
on 26 Jan 2020
Edited: Thiago Henrique Gomes Lobato
on 26 Jan 2020
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)
0 Comments
See Also
Categories
Find more on Argument Definitions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!