Sunteți pe pagina 1din 6

These exercises are based on the work of Xavier Serra at UPF

Exercise 1: Spectral Leakage

1. Create a cosine of 1 second at a sampling rate of 44100 Hz, with a frequency


that is a multiple of 44100/1024, for example 10*44100/1024.
2. Display 1024 samples of the function, horizontal axis in seconds.
3. Compute an FFT of size N = 1024 of the signal x1 and display its magnitude
spectrum (only the positive part). Use the "*" mode for plot: plot(abs(y),"*").
The horizontal axis should show the frequency ω in radians per second. This
means that the frequency range goes from 0 to π
4. From the magnitude spectrum, read out the frequency of the cosine and
compare it with the original frequency you used when generating it. To
calculate the frequency in Hz use the formula f = (fs ω)/(2 π)
5. Compute two other cosine functions x2 and x3 with frequencies at 10.25 and 10.50
times 44100/1024 and display 1024 samples of the functions.
6. Calculate the FFT of the two cosines x2 and x3, display the magnitude
spectrum and try to extract the frequency. What has changed? Try to explain
it?

Exercise 2: DFT

1. Take a look at the phase of the first fft generated in the section above
(fft(x1,1024)) with plot(arg(fft(x1(1:1024))). The phases will be distributed
randomly between -π and π. Explain why this doesn't affect the signal (hint:
take a look at the magnitudes)
2. Make another plot of the phases but this time only taking into account bins
with a magnitude higher than 0.0001
3. Make a FFT of the signal x1 with a different phase offset (start the FFT at
sample 5 of the vector x1 instead of sample 0). Display the phase of this FFT.
4. Describe the phase relation between the negative and the positive frequency
bins.
5. Display the amplitude and the phases of signal x2 using subplot(2,1,1). The
first plot should show the amplitude and the second one the phase.

Exercise 3: Time - Frequency duality

1. An impulse in the time domain corresponds to a constant offset in the


frequency domain (and the other way around). Create a vector z of 1024
zeros and set the first value to 1. ( z = zeros(1,1024);z(1)=1 ). Display the
magnitude, the real values and the complex values of the FFT of the vector
(use the functions real() and imag())
2. A rectangular function in the time domain corresponds to a sinc (sin(x)/x)
function in the frequency domain. Set all values from index 1 to 30 of
vector z to one and display the function and its spectral content (the
magnitude of the FFT). What can you say about the resulting function?
Set the values from index 1 to 60 to 1 and display its spectral content.
What changed?
3. The convolution is defined by

4. One of the properties of the DFT is that multiplication in the spectral


domain corresponds to circular convolution in the time domain and the
other way round. The convolution of a function with an impulse function is
equal to the function itself.
Multiply the cosine function from exercise 1 with the rectangular function
you have just created. Calculate the FFT from the result and display its
magnitude. Explain the result.
5. The inverse discrete Fourier transform (or IFFT) converts a signal from the
spectral domain to the time domain. Generate a Signal in the spectral
domain and convert it using the ifft() function from octave. The converted
function should be a cosine with frequency of 646 Hz. Choose an fft size
that is a power of 2. Sampling rate is 44100 Hz. Display both, the original
spectrum and the time domain signal.

Exercise 4: Windowing and STFT

1. Compare the spectral characteristics of the following windows: Rectangular,


Hanning, Hamming, Blackman-Harris 62dB, Blackman-Harris 70dB,
Blackman-Harris 74dB, Blackman-Harris 90dB. Plot the main-lobes of all the
windows on a single plot. Use bins in the x axis. Measure the bins of the main
lobe and the highest side-lobe level.

2. Measure the amplitude modulation, AM, caused in the STFT


analysis/synthesis process by all the Blackman-Harris windows when the
overlap factor is 50%. Plot all the modulation curves on a single plot.

3. Resynthesize a sinusoid with the STFT and using the 4 Blackman-Harris


windows overlapped by 50%. Plot the results. Can you see the AM? Can you
hear it? Where would you place acceptable distortion threshold? Do the same
with a 75% overlap. Where would you place the distortion threshold now?

Exercise 5: Sinusoidal Model part 1

1. Generate a sinusoid with a frequency of 440 Hz, amplitude of 0.5 (half the
maximum) and sampling rate of 44100 Hz. Compute its STFT with
parameters of your choice: window-type, window-size, FFT-size, hop-size.
Find the frequency and magnitude of the sinusoidal peak (without
interpolation). What is the error? Now use parabolic interpolation to measure
the frequency and amplitude of the sinusoidal peak. What is the error now?
Explain the results.
2. Generate two sinusoids of frequencies 440Hz and 550Hz, and sampling rate
44100 Hz. Compute its STFT with a Blackman-Harris 74dB window and a
window-size of 512 samples. Find the frequency and magnitude of the
sinusoidal peaks using spectral interpolation. Describe the interference effect
of one sinusoid into the other.
3. Implement the time-domain sinusoidal subtraction method proposed by
McAulay and Quatieri using matlab/octave.
4. Generate a 0.5 seconds sinusoid with an exponentially increasing frequency,
starting at 440Hz and ending at 880 Hz. Measure the sinusoidal peak in two
consecutive frames from the middle of the sound. Subtract the sinusoid using
the algorithm implemented in the previous exercise. Measure the magnitude
of the residual signal. Find the best analysis parameters to minimize the
magnitude of the residual. Explain the results.

Exercise 6: Sinusoidal Model part 2

1. Use the data produced by sms to draw a plot that shows the significant
feature(s) of the sound.
2. Change the analysis parameters of the sms.m program
1. Change the window-size and hop-size to values like: w1Length =
1028; n1 = 128; w1Length = 2048; n1 = 512;
2. Keeping all parameters above the same, change the number of
sinusoids to n=2, 5, 100
3. Describe the effect of these changes.
3. Analyze AfluteNaFr-C5.wav sound using the sms.m program

1. Listen to the sound. Perform an analysis of this file with the above given
parameters.
2. Change the parameters to get less artifacts in the resynthesis.
3. Describe the main characteristics of the sound.
4. Plot analysis data that display the characteristics of the sound.
Exercise 7: Transformations

The sms.m program can be extended by adding transformations. In the sms.m file
locate the line "Transformations". This is the place where the sinusoidal plus residual
data can be transformed before a sound is synthesized. The variable iloc holds an
array of peak positions, whereas the variable ival holds the corresponding amplitude
values. We can use these two arrays in order to fill syniloc and synival, the
corresponding arrays that get synthesized.

1. Filtering with arbitrary resolution

We can implement a band-pass filter defined by (x, y) points where x is the frequency
value in Hertz and y is the amplitude factor to apply. In the example code given
below, we define a band pass filter which suppresses frequencies not included in
the range [2100 3000]

2. Filter out specific partials


The following code filters out the even partials of the input sound. If applied to a
sound with a broadband spectrum, like a vocal sound, it will convert it to a clarinet-
like sound. Add this code to the "transform" function for mode = 2.

3. Frequency Scaling

In a similar way, we can apply a frequency scaling to the sinusoidal components of


our modeled sound. In that way, we can transpose all the partials in the spectrum or
reproduce pseudo-inharmonicities like the higher partials frequency stretching
characteristical in a piano sound. In this first example we introduce a frequency shift
factor to all the partials of our sound. Note, though, that if a constant is added to
every partial of a harmonic spectrum, the resulting sound will be inharmonic.
Implement this as mode 3 of the transform function.

Mode 4 is frequency stretch, where the fundamental stays the same but the sound
gets inharmonic.
Finally mode 5 is frequency scaling, where the pitch of the sound is changed, while
the duration stays the same.

4. Transformation plots

Add the function transform to the sms.m file and make a plot of the magnitude values
of a significant frame of DAFx_outresynth, the resynthesized sound, and the same
frame of DAFx_in, the input sound sax.wav. (In one plot, you can use the "hold on"
function). Make one plot for each of the five modes.

S-ar putea să vă placă și