The challenge I'm looking at is to design an iPhone component that listens to microphone input and triggers when it hears a particular blip (preferably < 0.1sec duration).
I can design the blip myself, and also false positives are okay.
The key constraint is that the listener is lightweight, so it doesn't drain CPU.
Can anyone suggest a mechanism, or point me in a good direction?
π
EDIT: this is as far as I have got:
I should be feeding audio into a ~1s buffer
so the first check may throw up lots of false positives, but this allows a second check to delve into the one second history and determine whether it was indeed a false positive or a valid blip.
so the first check may just be listening for the presence of a particular frequency sustained over 0.1s
to do this I could feed incoming audio into a 100 sample (for example) ring buffer, and then, 50 times per second multiply the ring-data by a sine wave (giving x) and cosine wave (giving y), effectively manually calculating a single FFT bin x+iy. then I could flag whenever the phase remains roughly constant over three frames.
or maybe I could use 3 such rings, length 99, 100, 101 samples. and monitor the amount of energy getting accumulated in each; if the 100-sample-ring wins and the neighbours are roughly balanced, that would be an indicator that the 100-ring's resonant frequency has been detected.
but this approach would require feeding all audio data into three rings. it isn't particularly lightweight... maybe I could only feed one in 17 (say) samples into each ring, throwing away the other 16. As 17 is co-prime with 99,100,101 it would fill all cells of the ring before overwriting the first again.