how to remove noise from audio using fourier transform and filter and to obtain back the original audio signal
[y,Fs]=audioread(‘audio.wav’);
%Normal sound
sound(y,Fs);
subplot(3,1,1);
plot(y);
x=y(1:2:length(y));%x=y(1:2:end)
%Decimated sound
sound(x,Fs);
subplot(3,1,2);
plot(x);
xn=randn(384362,1);
yn=y+xn;
sound(yn,Fs);
x1(1)=y(1);
g=length(y)-1;
j=2;
i=2;
while g~=0
m=rem(i,2);
if m==0
x1(i)=0;
else
x1(i)=y(j);
j=j+1;
g=g-1;
end
i=i+1;
end
%Interpolated sound
sound(x1,Fs);
subplot(3,1,3);
plot(x1);
srate = 10000;
time = 0:1/srate:2;
npnts = length(time);
% signal
signal = y;
% Fourier spectrum
signalX = fft(signal);
hz = linspace(0,srate/2,npnts);
% amplitude
ampl = abs(signalX(1:length(hz)));
figure(1);
stem(signal);
figure(2), clf
stem(hz,ampl,’ks-‘,’linew’,3,’markersize’,10,’markerfacecolor’,’w’)
% make plot look a bit nicer
set(gca,’xlim’,[0 10])
xlabel(‘Frequency (Hz)’), ylabel(‘Amplitude (a.u.)’)[y,Fs]=audioread(‘audio.wav’);
%Normal sound
sound(y,Fs);
subplot(3,1,1);
plot(y);
x=y(1:2:length(y));%x=y(1:2:end)
%Decimated sound
sound(x,Fs);
subplot(3,1,2);
plot(x);
xn=randn(384362,1);
yn=y+xn;
sound(yn,Fs);
x1(1)=y(1);
g=length(y)-1;
j=2;
i=2;
while g~=0
m=rem(i,2);
if m==0
x1(i)=0;
else
x1(i)=y(j);
j=j+1;
g=g-1;
end
i=i+1;
end
%Interpolated sound
sound(x1,Fs);
subplot(3,1,3);
plot(x1);
srate = 10000;
time = 0:1/srate:2;
npnts = length(time);
% signal
signal = y;
% Fourier spectrum
signalX = fft(signal);
hz = linspace(0,srate/2,npnts);
% amplitude
ampl = abs(signalX(1:length(hz)));
figure(1);
stem(signal);
figure(2), clf
stem(hz,ampl,’ks-‘,’linew’,3,’markersize’,10,’markerfacecolor’,’w’)
% make plot look a bit nicer
set(gca,’xlim’,[0 10])
xlabel(‘Frequency (Hz)’), ylabel(‘Amplitude (a.u.)’) [y,Fs]=audioread(‘audio.wav’);
%Normal sound
sound(y,Fs);
subplot(3,1,1);
plot(y);
x=y(1:2:length(y));%x=y(1:2:end)
%Decimated sound
sound(x,Fs);
subplot(3,1,2);
plot(x);
xn=randn(384362,1);
yn=y+xn;
sound(yn,Fs);
x1(1)=y(1);
g=length(y)-1;
j=2;
i=2;
while g~=0
m=rem(i,2);
if m==0
x1(i)=0;
else
x1(i)=y(j);
j=j+1;
g=g-1;
end
i=i+1;
end
%Interpolated sound
sound(x1,Fs);
subplot(3,1,3);
plot(x1);
srate = 10000;
time = 0:1/srate:2;
npnts = length(time);
% signal
signal = y;
% Fourier spectrum
signalX = fft(signal);
hz = linspace(0,srate/2,npnts);
% amplitude
ampl = abs(signalX(1:length(hz)));
figure(1);
stem(signal);
figure(2), clf
stem(hz,ampl,’ks-‘,’linew’,3,’markersize’,10,’markerfacecolor’,’w’)
% make plot look a bit nicer
set(gca,’xlim’,[0 10])
xlabel(‘Frequency (Hz)’), ylabel(‘Amplitude (a.u.)’) audio MATLAB Answers — New Questions