-1

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')
  • 3
    If this is a part of an important graded assignment for your Education, best pray that the professor(s) aren't part of SO. – J. Murray Sep 29 '19 at 11:53
  • Perhaps reading the [docs](https://nl.mathworks.com/help/dsp/ref/dsp.lmsfilter-system-object.html) would help. – rinkert Sep 29 '19 at 12:49
  • 2
    "This is a program I found online." Please provide proper attribution for any code you post on Stack Overflow just as you would when you submit your project for grading. (You were going to do that, right?) – beaker Sep 29 '19 at 14:52
  • Yes I was. Sorry, I didn't realise. Will do so always... – Archit Srivastav Sep 30 '19 at 12:21
  • This is the original paper: https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=2ahUKEwiF1f7-xPjkAhVp8HMBHdXjDAUQFjAAegQIBhAC&url=http%3A%2F%2Fwww.iosrjournals.org%2Fiosr-jece%2Fpapers%2FVol.%252012%2520Issue%25205%2FVersion-1%2FL1205016475.pdf&usg=AOvVaw0ilPnGldQJ83PdELCTbeMB – Archit Srivastav Sep 30 '19 at 12:25

1 Answers1

0

I tried your code and got this error.

  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);

This means you are giving one extra parameter in LMSFilter function. whereas the code from internet which you copied might be like this

 ha=adaptfilt.lms(256,mu);

here adaptfilt might have lms functions that accepts 2 arguments

Faisal Afroz
  • 603
  • 7
  • 11
  • Yes, this is the error I got. Originally, the code was making use of adaptfilt.lms(). However, when I ran the original code it said that adaptfilt.lms() is no longer supported by the newer versions of MATLAB and I was given a suggestion to use dsp.LMSFilter(). Problem is, I don't know how to give the correct parameters... – Archit Srivastav Sep 30 '19 at 12:23
  • I have already checked that paper that is why suggested in previous answer to use one arguments. see if you want to use dsp.LMSFilter() then you just need to provide one parameter like ha= dsp.LMSFilter(mu); But if you want to provide two args then you need to use other filters like adaptfilt.lms(256,mu). I hope this help. – Faisal Afroz Sep 30 '19 at 12:44