Audio data (VECR a8/ bond1.audio, rooster1.audio, and spacemusic1.audio) has been corrupted by an added 2000 Hz. interference sine wave, with amplitude 1 and zero phase offset.
Write a C program to read audio data from standard input and cancel the
interference by subtracting a sine wave. The program output must be
playable using the WAV audio icon with input redirected from one of the
audio files, e.g. args: < bond1.audio
A sine wave is defined by sin(2πft+φ), where f is the frequency in Hz., t is real time, and φ is a phase offset. For a discrete-time sine wave, discrete time is an integer i = 0, 1, 2, ... and real time is t = i/8000.0, using a sampling frequency of 8000 Hz. So discrete time i is a counter, the input sample number, which starts at 0.
Audio data (VECR a8/ bond2.audio, rooster2.audio, and spacemusic2.audio) has been corrupted by an added 2000 Hz. interference sine wave, with unknown amplitude and phase.
Write a C program to read audio data from standard input and remove
the interference using a notch filter and N-point sliding window.
The program output must be
playable using the WAV audio icon with input redirected from one of the
audio files, e.g. args: < bond2.audio
Write a function to slide the window and write a function to compute the filter output.
N and the filter coefficients are contained in p2.h:
#include "p2.h" // defines N and c[0]...c[N-1]For sliding window
y[0]...y[n-1], the current input sample
is placed in y[n-1] after sliding the window, and the filter
output is the sum, i=0...(n-1), c[i]*y[i].
Notes: sliding windows, filters
The notch filter was designed using this Matlab script to have the desired frequency response.
Write a C program to compute and display the magnitude of the frequency response for the filter from the previous problem:
H(ω) = sqrt(R2+I2), where R = ∑ck*cos(k*ω*T), I = -∑ck*sin(k*ω*T)
ω = 2*π*f, T = 1/8000.0,
and the summations are for k = 0 to N-1.
N and the filter coefficients ck
are contained in p2.h:
#include "p2.h" // defines N and c[0]...c[N-1]
Use a linear scale of 101 frequencies f from 0 to 4000.
The output must be suitable for plotting, i.e. just two columns of numbers
(f and H) with no headings.
The plot should look like the desired frequency response shown in the previous problem.
Reference: w9/avg3-math code, plot
Write a C program using Monte-Carlo simulation to estimate the probability of at least one birthday collision in a sample of 23 people.
In this case the trial() function should use an array of counters
similar to a7/p3. For each trial, generate up to 23
random birthdays and return 1 if there is a collision, otherwise return 0.
Use 1000 trials for initial testing, then try using 1000000 trials to get a more accurate estimate.
The theoretical value is shown in the table in the week #3 notes from class.
Reference: monte-carlo.c from week #11 notes from class