I have four microphones which I want to use to locate the direction of an audio source. Is there any Python module that implements an algorithm that, given the recordings of the four microphones, will give me a vector pointing to/angles of the audio source? Thanks in advance
I wish I could say that there are 2 different approaches to determining the direction of a source relative to some phase center of an array but that wouldn’t be correct.
Firstly I don’t think there is a Python module that does it generally because there are no algorithms that are completely general.
Having said that there are not 2 general classes of algorithms, I’m going to ignore what I just said. There is beamforming and there is cross correlation.
Beamforming seeks to use coherent gain to determine direction.
Cross Correlation seeks to determine the relative delays between the sensors and then pick the best solution.
Both categories are based on the principle that a propagating wave can be described by a wave front which is a surface in 3 or 2 dimensions of stationary phase. In a homogeneous 3 d free space, a point source the wavefront consists of expanding spheres where the amplitude drops off as $1/r$. Far enough away from the point source, the wavefront is sufficiently flat to assume a plane wave.
So in a real problem you have to make some assumptions about the propagating wavefronts. We can also have non radiating field components near the source.
The most typically standard approach is to assume plane waves from point sources impinging on your sensors. There are other kinds of assumptions that can be made like near point sources having wavefronts that have some curvature but you only have 4 sensors.
In beamforming we apply a set of delays to each received signal based on the assumption that it came from some direction and stack them up and sum them. The set of delays from the correct direction would produce the greatest coherent gain. This means that you have to form a lot of beams for a lot of proposed directions. Being off a little bit means that the estimated direction would be off a little as well. Beamforming is expensive in real time. Old fashioned RADAR solved the problem by scanning with a rotating parabolic antenna. In SONAR, rotating parabolas are mechanically undesirable and forming multiple beams is the better way to go.
The cross correlation method goes after the delays but you have to do all pairs and then you need to figure out which direction produced those delays.
There is something called split aperture beamforming which is a combination of the two.
When you have more than one source the basic ideas mostly hold but there are issues that are best left for a book or 2 or 10.
If your sensors are too close together, there are problems.
If your source is distributed some adjustments will help.
One good aspect of these problems is the Bessel Fourier relationship because like Fourier series in time, an arbitrary wavefront at a temporal frequency can be described by a sum of plane waves.
There is a very very large literature on direction finding. I sometimes wonder if there are more papers than there are actual arrays but that is getting less true (not actually true) as time goes on.