Using GetSpectrumData

I’ve been using the GetSpectrumData method to try and “listen” for a couple beats that trigger at a specific time. So far I’m able to get the Unity project to react to notes but when I try and separate it and have only certain notes get picked up by GetSpectrumData I run into issues.

void Update () {
            musicTrack.GetSpectrumData(this.samples,0,FFTWindow.BlackmanHarris);  

            for(int i=0; i<samples.Length;i++)  
            {  
                Debug.Log(samples*);*

if(samples == spectrumData1)
{
Debug.Log(“spectrum match”);
foreach (GameObject thing in things) {
thing.SendMessage(“DoThat”);
}
break;
}
if(samples == spectrumData2)
{
Debug.Log(“spectrum match”);
foreach (GameObject thing in things) {
thing.SendMessage(“DoThat”);
}
break;
}
if(samples == spectrumData3)
{
Debug.Log(“spectrum match”);
foreach (GameObject thing in things) {
thing.SendMessage(“DoThat”);
}
break;
}
}
Even though the music track is just a couple beats I see wildly varying results when I print out the array of spectrum data. I was hoping that since it is just three notes that are three different frequencies that I could examine the spectrum data to see what the three “spectrums” I should have the program wait for but the numbers never show any kind of pattern.
Any help would be greatly appreciated!

I believe that an FFT analysis should return an array of amplitudes of signals at different frequencies, 16 bands, 256 bands etc, i am not sure exactly, personally i prefer 1024 bands to have a clear image of the peaks.

the frequencies come out like 8hz (note 0) 16,32,64,etc etc.i think you would be seeing amplitudes at said freqs i dunno for sure, havent used unities fft.

i can’t say that i love FFT, i think it’s fast but it’s not as precise as an array of bandpass filters. 128 thin bandpass filters is super precise and also consumes alot of cpu.

fft can be of any level of precision so i am told, even can hear a pin drop, for sonar level equipment.