Given a segment of audio, if you were to calculate the histogram of frequency amplitudes for all standard musical note frequencies present in the audio, how would you check to see if 2-3 specific musical notes exist in the audio?
This is a type of polyphonic detection, similar to this question. Except I'm not trying to comprehensively find all notes present in the audio. I already know what notes I'm looking for and am just trying to check to see if they're present.
My current (naive) approach is to:
- Calculate the average amplitude across all frequencies to use as a threshold for noise filtering. Any frequencies with an amplitude below this I ignore as background noise.
- For each note I'm searching for, I calculate the frequencies for the first 3 harmonics, lookup the amplitude for each of those frequencies, and if they're all above the average, then I assume that note is present.
I find this sort-of works, but isn't 100% reliable. The main problem I'm running into is that, given the type of musical instrument, the amplitudes of all the note's harmonics can be very inconsistent across the instrument's range, and this makes setting the noise threshold very error prone.
For example, on an acoustic guitar, playing the high E4 note, the fundamental frequency is very strong and larger than all the other harmonics. However, for the lower E2 note, the fundamental is so small, it's often excluded as background noise. And there's not always a consistent pattern within the bass strings. Some of the low bass string notes have a very strong fundamental as well.
How do I solve this? I know open-ended real-time polyphonic detection is a very difficult and unsolved problem, but are there any solutions for a constrained version where you're only checking for the existence of a few notes and their specific harmonics?