I've searched through a ton of posts and haven't found anybody that's used an analog sound sensor to act as a switch for a specific whistle pattern. I am building a project that will utilize two different whistle patterns to activate two different LED's. I don't know how to utilize an FFT into a code in order to recognize a pattern. I have seen plenty of examples of codes recognizing a whistle, but not a pattern. What's the missing piece? Again, I'm using an analog sensor with amplifier, but still can only do simple functions b/c I don't know where to introduce/use an FFT. Thanks!
What do you mean by a "whistle pattern"?
The FFT function will tell you what frequencies at what amplitude are present in a given short sample of sound. If the whistles emit significantly different frequencies, then the FFT might help to distinguish them.
I have seen plenty of examples of codes recognizing a whistle, but not a pattern. What's the missing piece?
If you have something that recognises a 'whistle,' then the 'pattern' is a matter of timing the software to listen for sound... not sound... sound.
The whistler must know the timing that the whistlee expects to hear in order to recognise the pattern.
For example, if the pattern is 1-sec whistle, 1-sec dead air, 1-sec whistle, then...
Whistlee first listens for any whistle. Then it sets a time to wait 'a little more' than 1-sec, because you don't want it to bother listening for the dead air until the first whistle is guaranteed to have ended.
The whistlee listens for the dead air.
If it hears dead air it then it turns on another timer of 1-sec to wait before it starts to listen for the whistle again.
If it -does- hear a whistle when there should have been dead air, then it assumes that the first whistle wasn't part of 'the patern,' and loops back to the start.
The whistlee listens for the next whistle.
If it hears the whistle then it again waits 1-sec, and listens for dead air that signals the end of the second whistle. If it hears that dead air then SUCCESS.
If it doesn't hear the whistle then it assumes that the whistle... dead air... that it heard wasn't part of the pattern, and cycles back to the start.
That’s a great idea. The one issue I have is that the mic sensitivity is very touchy. When I try to adjust, the analog read I get jumps significantly with the slightest of turns on the adjustment knob on that board. Will an FFT allow me to better increase that scale in order for me to dial in the sensitivity of the sound heard in order for the arduino to listen for a more specific whistle?
Also, how would I write that program? Sounds like an “If/Then” statement right? Again, any and all help would be greatly appreciated. I only have a few more days to write this and test it out, and I’m completely stuck.
Arduino analog input is around 10000 samples a second. This timing accuracy is unknown to me. At best you can get say 5KHz, but in reality probably 1-2KHz. Whistles are high in frequency, 1KHz or higher. Can you prove you are able to resolve your whistle fundamental frequency? Id the pattern talking about overtones?