Coding noise cancellation in matlab

132 次查看(过去 30 天)
%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 个评论
Archit Srivastav
Archit Srivastav 2019-10-1
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);

请先登录,再进行评论。

回答(1 个)

Asvin Kumar
Asvin Kumar 2019-10-3
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:

类别

Help CenterFile Exchange 中查找有关 Propagation and Channel Models 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by