<< Chapter < Page | Chapter >> Page > |
where n = 1, ... 12, ai is the linear magnitude of the ith peak, and fi is the frequency value of the ith peak. i = 1, ... nPeaks, where nPeaks is the number of spectral peaks that we consider, and w is the weight of the frequency fi.
Basically, the note represented by integer n is compared with every peak in FFT. The weighting function represents the similarity between the note and the peak. This correlation is then multiplied by the square of the amplitude of the peak. We do this for every peak and add all the correlation up to get the "likelihood" that note n is compatible with the FFT graph. We repeat the same operations for all 12 values of n, and the HPCP vector is complete.
STEP ONE:
STEP TWO:
STEP THREE:
Here is the input file:
One problem with the HPCP algorithm is that it ignores what octave the original note was in. We have written a function findOctave to rectify this.
First off, we exploit the fact that a note's fft is the same regardless of what pitch it is: spikes the the note's pitch's fundamental frequency and all its multiples. So an A4 starts at 440 Hz, and has spikes at 880, 1320, etc. Our HPCP will identify this note as an A. To find out what octave it is in, we just look at the location of the lowest spike because all other spikes are multiples of this one frequency. So we find it at 440 Hz.
This process is repeated for every pitch detected by the HPCP, so for the C Major chord above, it'd look for the harmonics of C and find the lowest at 261 Hz (C4), then E at 330 Hz (E4), and G at 392 Hz (G4).
This method is fast and accurate -- however there is one limitation: if there are multiple notes of the same pitch but in different octaves (e.g. C4 and C5 and C6), their spectra would overlap and the algorithm would only detect the lowest note, C4.
Notification Switch
Would you like to follow the 'Noise resilient piano note & Chord recognition' conversation and receive update notifications?