Lab 6: Sinusoidal Modeling
A Sinusoidal Model assumes that not all the magnitude peaks of a
spectrum should be modeled by sinusoids, since peaks can also the
sidelobes of the analysis window, the result of noisy components
or of other transitional
effects. A sinusoid in the frequency domain is the transform of the
window used in the analysis, scaled by the magnitude of the sinusoid,
centered at the frequency of the sinusoid and with the phase of the
sinusoid at time 0 in the center of the window (if zero-phase windowing
A sinusoid can be synthesized by generating the transform of the window in the frequency domain and computing its inverse-FFT.
To do this lab you can start from stpt.m that performs spectral peak
analysis/synthesis without any consideration of sinusoidal constraints. Convert it to sinemodel.m
6.1: Peak interpolationRefine the peaks values obtained
from a simple location of the local maxima by performing parabolic
interpolation from each local maxima and its neighbour values.
Write a function to compute the interpolated peak locations, magnitudes
and phases from each spectrum and the obtained local maxima. ex: function [iploc, ipmag, ipphase] = peakinterp (mX, pX, ploc)
The three spectral magnitude values needed for the interpolation can be obtained by:
The center of the parabola (interpolated location) can be computed by
- lval = mX((ploc-1).*((ploc-1)>0)+((ploc-1)<=0).*1);
- rval= mX((ploc+1).*((ploc+1)<N2)+((ploc+1)>=N2).*N2);
- val = mX(ploc);
and the interpolated magnitude and phase by
- iploc = ploc + .5*(lval - rval) ./(lval - 2*val + rval);
- iploc = (iploc>=2).*iploc + (iploc<2).*1;
- iploc = (iploc>N2-1).*(N2-1) + (iploc<=N2-1).*iploc;
Incorporate this function into the sinusoidal modeling program and plot
the interpolated peak values on top of each magnitude spectrum.
- lphase = pX(floor(iploc));
- rphase= pX(floor(iploc)+1);
- intpfactor = iploc-ploc;
- intpfactor = (intpfactor>0).*intpfactor+(intpfactor<0).*(1+intpfactor);
- diffphase = unwrap(rphase-lphase);
- ipphase = lphase+intpfactor.*diffphase;
- ipmag = val-.25*(lval-rval).*(iploc-ploc);
6.2: Sinusoidal synthesis
To generated a sinusoid in the frequency domain we will be using the
main-lobe of the transform of the Blackman-Harris 92dB window.
Without zero-padding this lobe has 9 bins. We will be using a 4096
table storing a big main-lobe, from which we will obtain the bins
needed for any frequency. The function genbh92lobe.m can be used to initialize the table array bh92lobe. 1. Generate sinusoids in the frequency domain by adding main-lobes of the Blackman-Harris 92dB window. You can use the function genspecsines.m. The function is called by genspecsines(iploc,ipmag,ipphase,M,N,bh92lobe) Try this function by itself by cheking the resulting spectrum with different sinusoidal values and zero-padding values.
To be able to use different analysis windows we have to undo the effect
of the Blackman-Harris 92dB window after the ifft is performed and and
a simple window with wich we can overlapp-add by 50%. For example you
can define a synthesis window like ws = triang(M)./blackmanharris(M) and multiply it by the ouput buffer before adding it to the output array, like: y(pin+1:pin+M) = y(pin+1:pin+M) + x1(1:M).*ws;
3. Create a new function called sinemodel with the same input parameters as the example above called stpt. Use all that code and add the peak interpolation, the sinusoidal synthesis and the synthesis window.
6.3: Limits of the sinusoidal modelThe
assumption that spectral peaks can be considered sinusoids has its
limitations. For it to work best we have to perform an stft
analysis and peak detection process that only detects the stable
sinusoids. To control that we can use the following parameters: window
type and window size (w), fft-size (N), hop-size (H), and threshold (t).
1. Try different types of sounds and different parameters. What parameter combination works best for each sound? Expain it?