EE 285 Lab 7: Noise Filtering assignment help

engineering

Description

EE 285 Lab 7: Noise Filtering

Purpose

  •  Read in a .dat file similar to the one generated in Lab 5
  •  Loop through and calculate a moving average of the last N magnitudes
  •  Print out the new, filtered .dat file and listen to it with the play command.

Deliverables

  •  Demonstrate your completed source code to your TA.
  •  Completed noiseFilter.c source code file.
  •  Lab Report
  •  You should explain how your program handled the two different types of noise and

what effect the window size (N) had on the output.


This week you will be attempting to remove some imperfections from a sound file. We have

provided two sound files containing the same speech but marred by two different types of noise:

white and pink. It is not relevant for this class to know the difference between the two. Your

the program should meet the following requirements:

  •  Read in a .dat file via standard input (i.e. using scanf)
  •  N should be a constant in your program and specifies how large the averaging window

is.

  •  Store N magnitudes at a time in a history array (e.g. pushing the new values into index 0

and keeping the oldest at index N-1)

  •  Run a mean average
  •  Print out the new times and magnitudes to a new .dat file (i.e. via printf)
  •  Shouldn’t print any magnitudes until the history array is full.

When scanning in the initial .dat file, you will need to scan in the metadata lines at the beginning

before you start scanning in the floating-point times and magnitudes. Because using %s in scanf

stops at each whitespace, we want another function that can scan an entire line. C provides this

with the fgets function. fgets takes in a string, the maximum length of the string, and where you

want to get the string from. In our case, to read in a single line of metadata, we can write this

code to store up to 100 characters (or up to and including the newline)​ inside of myString.

fgets(myString, 100, stdin);

Once your metadata has been dealt with, you can start scanning in the data. To compute a

moving average, you’ll need to place the new values in an array and push the old values out.

Here is a decent animation of how this process looks when done on a line graph. Notice that it

doesn’t start averaging until there are N data points inside of the window (it doesn’t average


partial data). It is important to consider the order in which you replace things in your array to

make sure you don’t accidentally propagate your new value through to all of the indices.


Related Questions in engineering category