Use microphone and speaker to get distance
I’m not sure where to start with this, but here is the idea:
I want to use the microphone and speakers on the iPhone to measure distance. The speakers send out a pulse, the microphone pics up the pulse, and tells you the output in feet or inches or something.
The math is the easy part I think. What I can’t seem to find is where to start. Is there an API for the microphone and speakers? Any help is appreciated, thanks!
this will require some objc to be able to any sort of precision timing.
there were some threads recently about high performance audio generation. we would need to incorporate mic input into those audiounits.
The speed of sound is about 343 m/s or 13.5 inch per msec.
so we need resolution of about 800 microsec to get one inch.
the sample rate in the mic will be around 40kHz, maybe, so what you suggest might be feasible
That’s good to know it’s feasible. Is there a way to do in Pythonista? Or is it going to need Objc? Within a few inches is fine for accuracy.