The Fourier series assumes the violin sound is periodic with periodicity N Ts seconds. Hence, the fundamental period is T0 = N Ts seconds and the fundamental frequency is
The FFT takes the vector of N samples for the recorded signal, and returns the N exponential Fourier series coefficients.
fourierSeriesCoeffs = fft(instrumentSound);In the discrete-time case, we have a finite number of exponential Fourier series coefficients unlike the continuous-time Fourier series which has infinite terms.
The first half of the fourierSeriesCoeffs
vector contains the Fourier
series coefficients for non-negative frequencies, and the second half of the vector
contains the Fourier series coefficients for negative frequencies.
In Matlab, the first element is at index 1.
In fourierSeriesCoeffs
,
The kth harmonic frequency is fk = k f0 where f0 = fs / N.
If the frequency is non-negative, then we can convert nonNegativeFrequency
to an FFT vector index into by
N = length(instrumentSound); f0 = fs / N; fftIndex = round(nonNegativeFrequency / f0) + 1;and compute
fftCoeffGain = abs(fourierSeriesCoeffs(fftIndex)); fftCoeffPhase = angle(fourierSeriesCoeffs(fftIndex));Please see Appendix A in the mini-project #1 assignment for more information about using the FFT to compute the Fourier series.
fourierSeriesCoeffs
vector
so negative, zero, and positive frequencies are plotted.
In part (b), you'll use the Data Tips tool to find the horizontal coordinate (frequency)
and vertical coordinate (absolute value of the Fourier series coefficient) from the
frequency domain plot.
The absolute value is the gain.
To find the phase, you'll need to convert the frequency to an index into the
fourierSeriesCoeffs
vecor using the information in the section above
"Finding a harmonic frequency in the Fourier series coefficient vector".
In part (d), you're asked to find "for what range of time is the principal frequency present". The principal frequency is 261.63 Hz. You can zoom into the spectrogram to see over what time the principal frequency is present.
In part (c), you'll need to determine the range of FFT indices that corresponds to a range of frequencies from -7.5 Hz to 7.5 Hz.
During playback of the synthesized signal, please use the soundsc
command
instead of the sound
command.