Thanks for the comments.
Vassilis: yes, the mics are placed in a square or rectangle (since that makes the math easier, multilateration can be done with any arbitrary location, as demonstrated daily by GPS, which works on the same principle), but I’m detecting a knock. It’s relatively easy to detect impulsive sounds and cross correlate their times of arrival, very hard to detect more complex noises and determine their correlation. Roger is absolutely right. If you wanted to detect a drone, the way to do it would be to have an ultrasonic emitter on the drone, ultrasonic receivers on the ground, and have the drone emit periodic ultrasonic impulses.
The interesting thing is that the math works even when the sound is outside of the “microphone rectangle”. Realistically, it’s limited only by the microphone sensitivity. With sensitive microphones and an impulsive sound well above the noise floor, you could detect things at any distance. Speed of sound changes with humidity and temperature, so there’s also a thermohygrometer to help correct for that
Roger: yes, memory is indeed a concern, that’s why I will need to balance the amount of available memory (good thing STM32F103VET6 boards are only ~$10 and have 64kb, in case I need more), sampling rate and microphone array size. The interesting thing about the math is that it only depends on the distance between microphones, not the distance of the sound (since I trigger conversion only when the mic closest to the sound receives it, and since sound travels at around ~343 m/sec, there’s only so many samples needed to detect sound as it travels from the triggered microphone to the farthest). The formula (if I have it right) is that the minimum number of samples needed is the maximum distance between microphones in meters (the diagonal of the rectangle) divided by speed of sound, times the sampling rate. Even for a microphone array as big as 6 by 4 meters, the maximum sound delay between microphones is less than a 1/40 sec, allowing me to sample 4 microphones at a theoretical maximum of ~500-550kHz (with 64kb RAM, leaving enough for the system and other tasks). For 100Khz and a 4x6m array, a Maple Mini with 20kb RAM should be enough
The more I can increase the sampling rate, the more I can decrease the microphone array size. The way the math works, you can detect location with a smaller array if you can sample faster (i.e. if you can reliably detect smaller and smaller TDOA). The more precisely you can measure TDOA, the more precisely you can locate a sound. You can either increase the size of the microphone array (to separate the sound arrival more), or sample faster (to get better resolution and ability to cross correlate signals). If I could manage 100-200 kHz per channel (with good timing precision) at 8 bits, I could make precise measurements with a smaller array
The sounds I want to detect are far enough from each other that any STM32 is fast enough (an AVR Arduino would be, if I could sample fast enough) can sample, cross correlate, calculate location and send the results to either an SD card or via Bluetooth/wifi, and have still plenty of time listening for the next sound. With fast ADC and a 72MHz processor, you could locate a sound multiple times a second, I think. Not the sound of a drone, granted, but any impulsive sound.
So, we are left with the problem that started the original question
: any idea on how I could sample 4 channels (8 bit) as fast as possible, and as consistently as possible, ideally using DMA?