guys below are my code. I want to remove noise from audio signal which I added up by myself using random function.The following code removes somehow noise but it is still too noisy that I can't hear the sound. I also want to add the audio file for this code but i didn't find any option while posting my question so you can add any two channel .wav sound file . Any comment or hint will be helpful thanks.
close all
clear
clc
[x,fs] = audioread('cello.wav');
whos x;
pOrig = audioplayer(x,fs); %Signal Play
pOrig.play;
N = size(x,1);
figure;
subplot(2,1,1);
stem(1:N, x(:,1));
title('Left Channel of Origional signal');
subplot(2,1,2);
stem(1:N, x(:,2));
title('Right Channel of origional signal');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
df = fs/N;
w = (-(N/2):(N/2)-1)*df;
y1= fft(x(:,1),N)/N;
y2 = fftshift(y1);
figure;
plot(w,abs(y2));
title('Fast Fourier Transform of Origional Signal')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pause
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');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
df = fs/N;
w = (-(N/2):(N/2)-1)*df;
y1= fft(y(:,1),N)/N;
y2 = fftshift(y1);
figure;
plot(w,abs(y2));
title('Fast Fourier Transform of Noisy Signal')
pause
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% filter design
n = 10;
beginFreq = 100 / (fs/2);
endFreq = 2000 / (fs/2);
%[b,a] = butter(n, endFreq, 'low');
%fout = filter(b,a,y); % input y(noisy signal)
[b,a] = butter(n, endFreq, 'low');
fout = filter(b,a,y); % input y(noisy signal)
figure;
subplot(2,1,1);
stem(1:N, fout(:,1));
title('Left channel after filtering');
subplot(2,1,2);
stem(1:N, fout(:,2));
title(' Right channel after filtering');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%plot(fout);
df = fs/N;
w = (-(N/2):(N/2)-1)*df;
y1= fft(fout(:,1),N)/N;
y2 = fftshift(y1);
figure;
plot(w,abs(y2));
title('Fast Fourier Transform after filtering');
pOrig = audioplayer(fout,fs);
pOrig.play;
You are adding noise using randn() function, which generatares Gaussian noise, i.e. white noise. The white noise has constant power over the spectrum, that means you are adding noise from 0 to 20kHz (only considering the audio spectrum).
Your filter is a bandpass filter between 0.1-2 kHz, so according to what I pointed out above, you still have noise components in these frequency bands. Theoritecally, it is impossible to filter all of the noise components, however you may want to check out Wiener filters to get better results. Actually, it is the optimal filter if you know about the Gaussian noise parameters, which is only the variance of the noise in your case.
If you want to see an example that removes all the noise, you can add out-of-band noise on to your original signal. That is possible by generating a random sequence by rand() and using a filter to make it bandlimited. For example, filter the generated noise sequence with a 3-10kHz bandpass filter then add to the original audio sequence. Finally, apply the same butter filter in your script to see all the noise is removed.