<< Chapter < Page Chapter >> Page >

In effort to improve the efficiency of this algorithm, we created an alternative called FAST Autocorrelation, which has yielded speed improvements in excess of 70%.

We exploit the nature of the signal, specifically the fact that if the signal was generated using a high sampling rate and if the windows are narrow enough, we can assume that the pitch will not vary drastically from window to window. Thus, we can begin calculating the r(s) function using values of s that correspond to areas near the previous minimum. This means that, if the previous window had a fundamental period of 156 samples, we begin calculating r(s) for s = 136. If we fail to find the minimal s in this area, we calculate further and further from the previous s until we find a minimum.

Also, we note that the first minimum (valued below the threshold) is always going to correspond to the fundamental frequency. Thus, we can calculate the difference equation dr(s)/ds as we generate r(s). Then, when we find the first minimum below threshold, we can stop calculating altogether and move on to the next window.

If we use only the second improvement, we usually cut down the range of s from 600 points to around 200. If we then couple in the first improvement, we wind up calculating r(s) for only about 20 values of s, which is a savings of (580) * (1200) = 700000 calculations per window. When the signal may consist of hundreds of windows, this improvement is substantial indeed.

Limitations of autocorrelation

The autocorrelation algorithm is relatively impervious to noise, but is sensitive to sampling rate. Because it calculates fundamental frequency directly from a shift in samples, it follows that if we have a lower sampling rate, we have lower resolution in pitch.

As stated earlier, autocorrelation is also extremely expensive computationally. However, using the adaptive techniques described above, computation can be expedited and run in near-real time.

Harmonic product spectrum

Theory

If the input signal is a musical note, then its spectrum should consist of a series of peaks, corresponding to fundamental frequency with harmonic components at integer multiples of the fundamental frequency. Hence when we compress the spectrum a number of times (downsampling), and compare it with the original spectrum, we can see that the strongest harmonic peaks line up. The first peak in the original spectrum coincides with the second peak in the spectrum compressed by a factor of two, which coincides with the third peak in the spectrum compressed by a factor of three. Hence, when the various spectrums are multiplied together, the result will form clear peak at the fundamental frequency.

Hps overview

First, the windowed frame is taken into the frequency domain and the magnitude of the spectrum is calculated (left). Next, the spectrum is downsampled to create more compressed versions of itself (center). Notice how the higher harmonics of the fundamental frequency align with each other in the downsampled spectra. Last, a multiplication of these spectra is performed and the maximum is found (right). This corresponds to the fundamental frequency.

Method

First, we divide the input signal into segments by applying a Hanning window, where the window size and hop size are given as an input. For each window, we utilize the Short-Time Fourier Transform to convert the input signal from the time domain to the frequency domain. Once the input is in the frequency domain, we apply the Harmonic Product Spectrum technique to each window.

The HPS involves two steps: downsampling and multiplication. To downsample, we compressed the spectrum twice in each window by resampling: the first time, we compress the original spectrum by two and the second time, by three. Once this is completed, we multiply the three spectra together and find the frequency that corresponds to the peak (maximum value). This particular frequency represents the fundamental frequency of that particular window.

Limitations of the hps method

Some nice features of this method include: it is computationally inexpensive, reasonably resistant to additive and multiplicative noise, and adjustable to different kind of inputs. For instance, we could change the number of compressed spectra to use, and we could replace the spectral multiplication with a spectral addition. However, since human pitch perception is basically logarithmic, this means that low pitches may be tracked less accurately than high pitches.

Another severe shortfall of the HPS method is that it its resolution is only as good as the length of the FFT used to calculate the spectrum. If we perform a short and fast FFT, we are limited in the number of discrete frequencies we can consider. In order to gain a higher resolution in our output (and therefore see less graininess in our pitch output), we need to take a longer FFT which requires more time.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Ece 301 projects fall 2003. OpenStax CNX. Jan 22, 2004 Download for free at http://cnx.org/content/col10223/1.5
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Ece 301 projects fall 2003' conversation and receive update notifications?

Ask