Coding noise cancellation in matlab

124 vues (au cours des 30 derniers jours)
Archit Srivastav
Archit Srivastav le 29 Sep 2019
%This is a program I found online. It's supposed to take an audio file from the folder, add noise and then filter it out. However, ha=dsp.LMSFilter(256,mu); is wrong and how to add the correct arguments to dsp.LMSFilter(), I have no idea. Alos, I don't understand the working of the code. Any help would be appreciated. This is a part of a very important and graded project in my college.
load handel.mat;
d= 'Recording.m4a';
samples = [1,20*Fs];
clear d Fs
[d,Fs] = audioread('Recording.m4a',samples);
sound(d,Fs)
pause(3)
x=awgn(d,20);
sound(x,Fs)
pause(3)
mu=0.017;%stepsize
ha=dsp.LMSFilter(256,mu);
[y,e]=filter(ha,x(:,1),d(:,1));
sound(y,Fs)
subplot(4,1,1),plot(d)
grid on
xlabel('iterations')
ylabel('amplitude')
title('original voice signal')
subplot(4,1,2)
plot(x)
grid on
xlabel('iterations')
ylabel('amplitude')
title('signal with AWGN')
subplot(4,1,3)
plot(y)
grid on
title('filtered output')
xlabel('iterations')
ylabel('amplitude')
subplot(4,1,4)
plot(e)
grid on
title('error signal')
xlabel('iterations')
ylabel('amplitude')
  4 commentaires
darova
darova le 30 Sep 2019
11Untitled.png
Archit Srivastav
Archit Srivastav le 1 Oct 2019
Thank you for pointing that out. However, I still don't understand. What exactly is missing? Do I need to add parameters to it?
The code runs so far and the audio signal is read. The audio signal is heard and then the audio signal+the added noise. After this, it stops and gives an error in dsp.LMSFilter() saying that more parameters have been added than needed.
Error using matlab.system.SystemProp/parseInputs
dsp.LMSFilter System object constructor
supports only 1 value-only inputs. You have
specified 2 value-only inputs. A common cause
of this error is misspelling a property name.
Error in
matlab.system.SystemProp/setProperties
Error in dsp.LMSFilter
Error in SO (line 12)
ha=dsp.LMSFilter(256,mu);

Connectez-vous pour commenter.

Réponses (1)

Asvin Kumar
Asvin Kumar le 3 Oct 2019
Consider using either of the following syntaxes:
ha=dsp.LMSFilter('Length',256,'StepSize',mu);
ha=dsp.LMSFilter(256,'StepSize',mu);
For more details have a look at the following example:
For more details on the syntax for object creation and object properties refer to:

Catégories

En savoir plus sur Propagation and Channel Models dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by