SensoryBridge icon indicating copy to clipboard operation
SensoryBridge copied to clipboard

Possible method to optionally remove all harmonics from FFT

Open connornishijima opened this issue 2 years ago • 0 comments

  • Starting with the highest note of a piano (C8) test for the presence of a peak at its fundamental frequency.
  • If a peak is found, the frequency we are testing for is divided by 2.
  • Check for the presence of a peak at our new target, which is 1/2 the frequency of C8
  • If found, this is now considered the fundamental.
  • The division process is repeated until the tested frequency falls below A0 (27.5 Hz) OR:
  • Once the tested frequency no longer has a detectable peak, the previous frequency above it is known (to a good enough extent for entertainment purposes) to be the fundamental frequency of the playing note.
  • Knowing which FFT bins are the fundamental and which are harmonics, begin extracting the fundamental peak
  • Starting from the center, a bounding box is "grown" away from the center of the peak until the values at its edges have little difference to their neighbors or reach zero (flat/black area of FFT image)
  • This area (the fundamental peak) of the FFT is added in-place to a temporary buffer the same size as the FFT image
  • This is repeated to all detected fundamental peaks.
  • The resulting buffer includes the original signal image, minus the harmonics.
  • This is repeated for the 11 semitones below C8.

Extra Note: while the C8 range is used as the reference frequency to start from, all iterations that are > the top frequency of the displayed FFT are skipped, since we can't observe them anyways.

connornishijima avatar Jul 09 '22 07:07 connornishijima