DSPRelated.com
Free Books

Peak Matching (Step 5)

The peak detection process returns the prominent peaks in a given frame sorted by frequency. The next step is to assign some subset of these peaks to oscillator trajectories, which is done by the peak matching algorithm. If the number of spectral peaks were constant with slowly changing amplitudes and frequencies along the sound, this task would be straightforward. However, it is not always immediately obvious how to connect the spectral peaks of one frame with those of the next.

To describe the peak matching process, let's assume that the frequency tracks were initialized at frame $ 1$ and we are currently at frame $ m$ . Suppose that at frame $ m-1$ the frequency values for the $ p$ tracks are $ f_1, f_2, \ldots\,,f_p$ , and that we want to match them to the $ r$ peaks, with frequencies $ g_1, g_2, \ldots ,g_r$ , of frame $ m$ .

Each track looks for its peak in frame $ m$ by finding the one which is closest in frequency to its current value. The $ i$ th track claims frequency $ g_j$ for which $ \vert f_i - g_j\vert$ is minimum. The change in frequency must be less than a specified maximum $ \Delta(f_i)$ , which can be a frequency-dependent limit (e.g., linear, corresponding to a relative frequency change limit). The possible situations are as follows:

12pt (1) If a match is found inside the maximum change limit, the track is continued (unless there is a conflict to resolve, as described below).

12pt (2) If no match is made, it is assumed that the track with frequency $ f_i$ must ``turn off'' entering frame $ m$ , and $ f_i$ is matched to itself with zero magnitude. Since oscillator amplitudes are linearly ramped from one the frame to the next, the terminating track will ramp to zero over the duration of one frame hop. This track will still exist (at zero amplitude), and if it ever finds a frame with a spectral peak within its capture range $ \Delta(f_i)$ , it will ``turned back on,'' ramping its amplitude up to the newly detected value. It is sometimes necessary to introduce some hysteresis into the turning on and off process in order to prevent ``burbling'' of the tracks whose peaks sometimes make the cut and sometimes don't. Normally this problem can be avoided by searching for many more spectral peaks than there are oscillators to allocate.

12pt (3) If a track finds a match which has already been claimed by another track, we give the peak to the track which is closest in frequency, and the ``losing'' track looks for another match. If the current track loses the conflict, it simply picks the best available non-conflicting peak. If the current track wins the conflict, it calls the assignment procedure recursively on behalf of the dislodged track. When the dislodged track finds the same peak and wants to claim it, it will see there is a conflict which it loses and will move on. This process is repeated for each track, solving conflicts recursively, until all existing tracks are matched or ``turned-off''.

After each track has extended itself forward in time or turned off, the peaks of frame $ m$ which have not been used are considered to be new trajectories and a new track is ``started-up'' for each one of them up to the maximum number of oscillators specified (which again should be less than the number of spectral peaks detected). The new oscillator tracks are started at frame $ n-1$ with zero magnitude and ramp to the correct amplitude at the current frame $ m$ .

Once the program has finished, the peak trajectories for a sound look as in Fig.H.4.

Figure H.4: Peak trajectories for a piano tone.
\includegraphics[width=\twidth]{eps/fig6}


Next Section:
Parameter Modifications (Step 6)
Previous Section:
Peak Detection (Steps 3 and 4)