%% LMS Homework Assignment % % Introduction % % This homework assignment requires you to experiment with a simple LMS % filter architecture. Slide 15 of the most recent lecture % (http://www.echelonembedded.com/dsphwlab/notes/class11.pdf) gives the LMS % architecture for Adaptive Noise Cancellation. % % For this homework assignment, implement an LMS filter on your DSP board. % The easiest way to do this is likely to start with one of the Chassaing % examples. You should feel free to use as much pre-written code from the % book (or any other source except another student). The goal is simply to % experiment with an LMS filter; not to spend much time implementing code. % % To experiment, inject the "signal" through one side of the stereo audio % input, and the "noise reference" into the other side or the stereo input % (so, for example, the right channel could be dedicated to the signal, and % the left channel to the noise reference). % % The adaptively filtered signal "e" should be played real-time out the % audio output. % % Demonstration % % Three .mat files are available on the class website (and are referenced % by this .m file). Each includes the following signals: % * input: The input signal corrupted by a noise source. * noiseRef: The % reference noise. This will be adaptively filtered, and removed from the % input to produce the error signal, e. * e: The input - noiseRef; i.e., % the "filtered" signal. This is the result we are observing on the codec % output. * sig: The vector used to form the signal portion of input. * % noiseInFilt: A filtered version of the noise added to the sig. This is % the corrupting noise source. For the lawnmower example, this input has % undergone two transformations (filtering and summation with a delayed % copy). * fs: The sample rate of the vectors. % % For your demonstration, you simply need to inject each of the three input % and noiseRef signals and play the output signal. Note that the error % signal examples provided were formed at different beta values. % % In addition to demonstrating the operation of your LMS filter, you will % need to be prepared to intelligently discuss your architecture and the % operation of the filter. %% Sin Example load sin.mat % creates fs, sig, noiseInFilt, input, noiseRef, e soundsc(sig(7*fs:fs*10),fs); soundsc(input(7*fs:fs*10),fs); soundsc(e(7*fs:fs*10),fs);f %% Lawnmower Example % noiseInFilt = noiseInFilt1 + [zeros(1, nDelay), .1 * noiseInFilt2(nDelay+1:end)]; load lawnmower.mat soundsc(sig(1:fs*10),fs); soundsc(input(1:fs*10),fs); soundsc(e(1:fs*10),fs); %% White Noise Example % noiseInFilt = noiseInFilt1 + [zeros(1, nDelay), .1 * noiseInFilt2(nDelay+1:end)]; load noise.mat soundsc(sig(1:fs*10),fs); soundsc(input(1:fs*10),fs); soundsc(e(1:fs*10),fs);