Removing random noise from audio signal

7 次查看(过去 30 天)
Hi, guys below are my code .. I am a newbie in Matlab and in my code audio file I add random noise in my audio file and after adding it I want to design a filter which removes that noise. Any hint or comment will be helpful to me. I also attached the audio file. Thanks
clear
close all
clc
[x,fs] = audioread('D.wav');
whos x; % Name Size Bytes Class sampling frequency
% x 556542x2 8904672 double 44100
% pOrig = audioplayer(x,fs);
% pOrig.play;
N = size(x,1); % Determine total number of samples in audio file
figure;
subplot(2,1,1);
stem(1:N, x(:,1));
title('Left Channel');
subplot(2,1,2);
stem(1:N, x(:,2));
title('Right Channel');
pause
%Adding Noise in audio signal
y=x;
y = y + randn(size(y));
% pOrig = audioplayer(y,fs);
% pOrig.play;
figure;
subplot(2,1,1);
stem(1:N, y(:,1));
title('Left Channel with Noise');
subplot(2,1,2);
stem(1:N, y(:,2));
title('Right Channel with Noise');
%nyquist frequncy = fs/2;44100/2=22050
%plot the spectrum
df = fs/N;
w = (-(N/2):(N/2)-1)*df;
y1= fft(y(:,1),N)/N;
y2 = fftshift(y1);
figure;
plot(w,abs(y2));
pause
n = 7;
beginFreq = 50 / (fs/2);
endFreq = 150 / (fs/2);
[b,a] = butter(n, [beginFreq, endFreq], 'stop');
fout = filter(b,a,y2);
% A = audioplayer(fout,fs);
% pOrig.play;
figure;
plot(b,a);
  6 个评论
Ameer Hamza
Ameer Hamza 2020-12-6
I am looking for zip file, and it does seem to be present here. Kindly someone mention here
Jan
Jan 2020-12-6
For which zip file are you looking?

请先登录,再进行评论。

回答(2 个)

harsini j
harsini j 2019-8-19
clear
close all
clc
[x,fs] = audioread('D.wav');
whos x; % Name Size Bytes Class sampling frequency
% x 556542x2 8904672 double 44100
% pOrig = audioplayer(x,fs);
% pOrig.play;
N = size(x,1); % Determine total number of samples in audio file
figure;
subplot(2,1,1);
stem(1:N, x(:,1));
title('Left Channel');
subplot(2,1,2);
stem(1:N, x(:,2));
title('Right Channel');
pause
%Adding Noise in audio signal
y=x;
y = y + randn(size(y));
% pOrig = audioplayer(y,fs);
% pOrig.play;
figure;
subplot(2,1,1);
stem(1:N, y(:,1));
title('Left Channel with Noise');
subplot(2,1,2);
stem(1:N, y(:,2));
title('Right Channel with Noise');
%nyquist frequncy = fs/2;44100/2=22050
%plot the spectrum
df = fs/N;
w = (-(N/2):(N/2)-1)*df;
y1= fft(y(:,1),N)/N;
y2 = fftshift(y1);
figure;
plot(w,abs(y2));
pause
n = 7;
beginFreq = 50 / (fs/2);
endFreq = 150 / (fs/2);
[b,a] = butter(n, [beginFreq, endFreq], 'stop');
fout = filter(b,a,y2);
% A = audioplayer(fout,fs);
% pOrig.play;
figure;
plot(b,a);

harinie Jr
harinie Jr 2020-10-5
clear
close all
clc
[x,fs] = audioread('D.wav');
whos x; % Name Size Bytes Class sampling frequency
% x 556542x2 8904672 double 44100
% pOrig = audioplayer(x,fs);
% pOrig.play;
N = size(x,1); % Determine total number of samples in audio file
figure;
subplot(2,1,1);
stem(1:N, x(:,1));
title('Left Channel');
subplot(2,1,2);
stem(1:N, x(:,2));
title('Right Channel');
pause
%Adding Noise in audio signal
y=x;
y = y + randn(size(y));
% pOrig = audioplayer(y,fs);
% pOrig.play;
figure;
subplot(2,1,1);
stem(1:N, y(:,1));
title('Left Channel with Noise');
subplot(2,1,2);
stem(1:N, y(:,2));
title('Right Channel with Noise');
%nyquist frequncy = fs/2;44100/2=22050
%plot the spectrum
df = fs/N;
w = (-(N/2):(N/2)-1)*df;
y1= fft(y(:,1),N)/N;
y2 = fftshift(y1);
figure;
plot(w,abs(y2));
pause
n = 7;
beginFreq = 50 / (fs/2);
endFreq = 150 / (fs/2);
[b,a] = butter(n, [beginFreq, endFreq], 'stop');
fout = filter(b,a,y2);
% A = audioplayer(fout,fs);
% pOrig.play;
figure;
plot(b,a);

类别

Help CenterFile Exchange 中查找有关 Audio Processing Algorithm Design 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by