Delay Sum Beamformer

Ok only for linear arrays as this was purposely aimed at Pi3 and tried more complex beamform algs such as GSC (generalised sidelobe cancellor) and forgot what MVDR stands for but far to much load for a Pi3.
Its not that you can not do more complex beamforming with Delay Sum its just the geometry we have is going to cause loads of aliasing (false lower frequencies) so its linear only for now.

To get it working modprobe a loopback sudo modprobe snd-aloop
So if you aplay -l you will get a new loopback card with device with 0,1 & 8 subdevices.
If you play into device 0 then it will be available on device 1 also you don’t have to as play 0,0,0 is default but each subdevice is its own device so you can play and record to x8 simultaneous if you so wished.

The command for DS is [options] then devices
./ds --frames=4410 --channels=2 --margin=8 --sample_rate=44100 --display_levels=1 1 2
If you want to see devices just drop the device indexes or just ./ds`
So 1st device is your soundcard 2nd should be loopback
The resolution of the TDOA (Time Difference of Arrival) is dependent on your mic spacing divided by your sample rate so the higher the sample rate the more resolution.
The math is speed of sound 343ms / samplerate = the distance of a single sample.
So how many times that divides into you mic spacing is your max resolution which you should set the margin to or the next integer up.

44100/48000 are pretty common so pick one of those to whatever is hardware supported to get less load.
Then on the other side of the looback say with my setup

 aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 H                                                              eadphones]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 1: Dongle [VIA USB Dongle], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: vc4hdmi [vc4-hdmi], device 0: MAI PCM i2s-hifi-0 [MAI PCM i2s-hifi-0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 3: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
card 3: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM]
  Subdevices: 8/8
  Subdevice #0: subdevice #0
  Subdevice #1: subdevice #1
  Subdevice #2: subdevice #2
  Subdevice #3: subdevice #3
  Subdevice #4: subdevice #4
  Subdevice #5: subdevice #5
  Subdevice #6: subdevice #6
  Subdevice #7: subdevice #7
pi@raspberrypi:~ $ ./ds --frames=4410 --channels=2 --margin=8 --sample_rate=44100 --display_levels=1 1 2

Would be how I run DS

to record the other side of the loopback is
arecord -Dhw:3,1 -r44100 -fFLOAT_LE -c1 test.wav
But your prob going to want to alter the sample rate and format so use a plughw so its autoconverted
arecord -Dplughw:3,1 -r16000 -fS16_LE -c1 test.wav

If you have a PS3 eye give it a try or one of those horrid 2mic hats.

I have got a KWS that focusses the beam on KW coming next but have a couple of other algs planned.
As really its the TDOA that is all the load but really needs to only fire on voice and locate.

To check your input vols and see the TDOA set --display_levels=1 but --display_levels=0 to stop the cli output.

PS I have no idea how it will behave on a 4mic square hat but could be interesting even if totally wrong type of alg as broadside its delay and sum but endfire it should be delay invert and sum.

Or wget https://github.com/StuartIanNaylor/ProjectEars/raw/main/ds/ds

Too hasty as still 1 sample out of align hence clicking I will give it a break and get back to it as hate array indexing probs.

Dunno how I managed a single sample out of align but all well now get your ps3eye out and pi3/z2 out and give it a try.