Azzera filtri
Azzera filtri

Removing random noise from audio signal

7 visualizzazioni (ultimi 30 giorni)
Ali Khan
Ali Khan il 18 Gen 2018
Commentato: Jan il 6 Dic 2020
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 Commenti
Ameer Hamza
Ameer Hamza il 6 Dic 2020
I am looking for zip file, and it does seem to be present here. Kindly someone mention here
Jan
Jan il 6 Dic 2020
For which zip file are you looking?

Accedi per commentare.

Risposte (2)

harsini j
harsini j il 19 Ago 2019
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 il 5 Ott 2020
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);

Community Treasure Hunt

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

Start Hunting!

Translated by