Delay Sum Beamformer

I have just been doing a bit of work on the linear beamformer

Which works apart from a slight clicking which I know what it is as there is an offset somewhere on each chunk that means there is a slight mismatch.
If you cut an audio signal or mismatch so its not smooth then it will create clicks and I am looking at the code and just not seeing where in the indexing this is happening.

They way a linear delay sum works is for that chunk it works out TDOA (Time Difference of Arrival) in samples from the ref mic and it picks from the other mics ±samples and just sums and provides the average.
There is a margin constraint that is set to the physical max of the distance of the 2 mics as possible to not detect tdoa and get out of sync.
Also the margin length *2 of the last chunk is added to the next chunk as the delay sum can me ± samples so we work on the chunk + 2x margin lengths and start work a margin in.
Anyway the actually beamformer is really simple and it could just be a dropped sample and I am just not seeing where the indexing is wrong.

If you know a smattering of C or Java maybe have a look for me as the Delay is the really simple part and I am doing something stupid where I am just out of align with the indexes.
Maybe a fresh set of eyes can see it as know when I spot it I will kick myself but just not spotting it.

PS I know I keep mixing C/C++ syntax and for a guru this must be hack hell but its my 1st from scratch C/C++ project but ignoring syntax as its not that there is definitely an index offset causing this and I am just not seeing where.
I guess I will just have to create a synthetic wav of an incrementing float and pass that through to see where its happening by results but would rather not write all the additional but may have too.

I added some debug lines and prob need to give it a rest as its not making much sense at the moment

i=4410 tdoa=0 j=0
i=4410 tdoa=-1 j=1
i=4411 tdoa=0 j=0
i=4411 tdoa=-1 j=1
i=4412 tdoa=0 j=0
i=4412 tdoa=-1 j=1
i=4413 tdoa=-1146436736 j=0
i=4413 tdoa=-1 j=1
i=4414 tdoa=-1146436736 j=0
i=4414 tdoa=-1135547904 j=1
i=4415 tdoa=-1146436736 j=0
i=4415 tdoa=-1135547904 j=1
i=4416 tdoa=-1146436736 j=0
i=4416 tdoa=-1135547904 j=1
i=4417 tdoa=-1146436736 j=0
i=4417 tdoa=-1135547904 j=1
sample max amplitude = 0.662743
sample average = 0.183766
255.458 ms

4410 is the chunk size so why I go awry @ 4413 and its just the end 4 samples is confusing me

Ignore the above as same problem but there where others



It screwing with me as only 8 samples and if like current debug is the margin and 1st 16 elements of the next chunk dumped to Cli look exactly like you would expect.

j=0 k=0 config->in_data=-0.045845 j=0 k=1 config->in_data=-0.022904 j=0 k=2 config->in_data=-0.025806 j=0 k=3 config->in_data=-0.041800 j=0 k=4 config->in_data=-0.051914 j=0 k=5 config->in_data=-0.059092 j=0 k=6 config->in_data=-0.068978 j=0 k=7 config->in_data=-0.074245 j=0 k=8 config->in_data=-0.077567 j=0 k=9 config->in_data=-0.058900 j=0 k=10 config->in_data=-0.045883 j=0 k=11 config->in_data=-0.045579 j=0 k=12 config->in_data=-0.056342 j=0 k=13 config->in_data=-0.063518 j=0 k=14 config->in_data=-0.074399 j=0 k=15 config->in_data=-0.079553
index=16 in_data=-0.085278 index=17 in_data=-0.075619 index=18 in_data=-0.065352 index=19 in_data=-0.055655 index=20 in_data=-0.054587 index=21 in_data=-0.057909 index=22 in_data=-0.076383 index=23 in_data=-0.096385 index=24 in_data=-0.118906 index=25 in_data=-0.126350 index=26 in_data=-0.123182 index=27 in_data=-0.104516 index=28 in_data=-0.073750 index=29 in_data=-0.037601 index=30 in_data=-0.010727 index=31 in_data=0.002365
j=1 k=0 config->in_data=-0.065085 j=1 k=1 config->in_data=-0.087758 j=1 k=2 config->in_data=-0.110739 j=1 k=3 config->in_data=-0.117686 j=1 k=4 config->in_data=-0.118373 j=1 k=5 config->in_data=-0.114442 j=1 k=6 config->in_data=-0.103219 j=1 k=7 config->in_data=-0.085201 j=1 k=8 config->in_data=-0.056725 j=1 k=9 config->in_data=-0.036150 j=1 k=10 config->in_data=-0.036340 j=1 k=11 config->in_data=-0.044929 j=1 k=12 config->in_data=-0.058290 j=1 k=13 config->in_data=-0.074741 j=1 k=14 config->in_data=-0.090812 j=1 k=15 config->in_data=-0.101806
index=4426 in_data=-0.110281 index=4427 in_data=-0.112342 index=4428 in_data=-0.097492 index=4429 in_data=-0.085278 index=4430 in_data=-0.079934 index=4431 in_data=-0.079743 index=4432 in_data=-0.083942 index=4433 in_data=-0.097188 index=4434 in_data=-0.112610 index=4435 in_data=-0.126579 index=4436 in_data=-0.129365 index=4437 in_data=-0.122495 index=4438 in_data=-0.095469 index=4439 in_data=-0.076499 index=4440 in_data=-0.063443 index=4441 in_data=-0.043364
tdoa=0 tdoa=-1
sample max amplitude = 0.424913
sample average = 0.100337
frames = 4410
35.9124 ms
j=0 k=0 config->in_data=-0.014316 j=0 k=1 config->in_data=-0.006185 j=0 k=2 config->in_data=0.006183 j=0 k=3 config->in_data=0.016146 j=0 k=4 config->in_data=-0.004428 j=0 k=5 config->in_data=-0.032867 j=0 k=6 config->in_data=-0.046992 j=0 k=7 config->in_data=-0.042600 j=0 k=8 config->in_data=-0.034012 j=0 k=9 config->in_data=-0.026455 j=0 k=10 config->in_data=-0.015613 j=0 k=11 config->in_data=-0.017216 j=0 k=12 config->in_data=-0.029661 j=0 k=13 config->in_data=-0.032370 j=0 k=14 config->in_data=-0.019508 j=0 k=15 config->in_data=0.006909
index=16 in_data=0.031033 index=17 in_data=0.039660 index=18 in_data=0.035232 index=19 in_data=0.037751 index=20 in_data=0.050425 index=21 in_data=0.051876 index=22 in_data=0.050692 index=23 in_data=0.049126 index=24 in_data=0.045500 index=25 in_data=0.045652 index=26 in_data=0.050767 index=27 in_data=0.044126 index=28 in_data=0.030994 index=29 in_data=0.028666 index=30 in_data=0.054547 index=31 in_data=0.095621
j=1 k=0 config->in_data=-0.052755 j=1 k=1 config->in_data=-0.033515 j=1 k=2 config->in_data=-0.016796 j=1 k=3 config->in_data=-0.014125 j=1 k=4 config->in_data=-0.020118 j=1 k=5 config->in_data=-0.026339 j=1 k=6 config->in_data=-0.039013 j=1 k=7 config->in_data=-0.051685 j=1 k=8 config->in_data=-0.058671 j=1 k=9 config->in_data=-0.043861 j=1 k=10 config->in_data=-0.022408 j=1 k=11 config->in_data=-0.019240 j=1 k=12 config->in_data=-0.013400 j=1 k=13 config->in_data=-0.003360 j=1 k=14 config->in_data=0.018819 j=1 k=15 config->in_data=0.035155
index=4426 in_data=0.045881 index=4427 in_data=0.054508 index=4428 in_data=0.054433 index=4429 in_data=0.050577 index=4430 in_data=0.035690 index=4431 in_data=0.017674 index=4432 in_data=0.005916 index=4433 in_data=0.013704 index=4434 in_data=0.027636 index=4435 in_data=0.041569 index=4436 in_data=0.046568 index=4437 in_data=0.053250 index=4438 in_data=0.059814 index=4439 in_data=0.068595 index=4440 in_data=0.070540 index=4441 in_data=0.067525
tdoa=0 tdoa=-1
sample max amplitude = 0.356891
sample average = 0.107044
frames = 4410
35.8349 ms
j=0 k=0 config->in_data=-0.084133 j=0 k=1 config->in_data=-0.047257 j=0 k=2 config->in_data=-0.025004 j=0 k=3 config->in_data=-0.021111 j=0 k=4 config->in_data=-0.048402 j=0 k=5 config->in_data=-0.090470 j=0 k=6 config->in_data=-0.126159 j=0 k=7 config->in_data=-0.145055 j=0 k=8 config->in_data=-0.162806 j=0 k=9 config->in_data=-0.190823 j=0 k=10 config->in_data=-0.219377 j=0 k=11 config->in_data=-0.243120 j=0 k=12 config->in_data=-0.261327 j=0 k=13 config->in_data=-0.269421 j=0 k=14 config->in_data=-0.273160 j=0 k=15 config->in_data=-0.280222
index=16 in_data=-0.274801 index=17 in_data=-0.268770 index=18 in_data=-0.262816 index=19 in_data=-0.260984 index=20 in_data=-0.257395 index=21 in_data=-0.251097 index=22 in_data=-0.241515 index=23 in_data=-0.228194 index=24 in_data=-0.216323 index=25 in_data=-0.207848 index=26 in_data=-0.211208 index=27 in_data=-0.212811 index=28 in_data=-0.204719 index=29 in_data=-0.189181 index=30 in_data=-0.177502 index=31 in_data=-0.162042
j=1 k=0 config->in_data=-0.079095 j=1 k=1 config->in_data=-0.055732 j=1 k=2 config->in_data=-0.040578 j=1 k=3 config->in_data=-0.037943 j=1 k=4 config->in_data=-0.059741 j=1 k=5 config->in_data=-0.092989 j=1 k=6 config->in_data=-0.121389 j=1 k=7 config->in_data=-0.137153 j=1 k=8 config->in_data=-0.161010 j=1 k=9 config->in_data=-0.177731 j=1 k=10 config->in_data=-0.187694 j=1 k=11 config->in_data=-0.200443 j=1 k=12 config->in_data=-0.208993 j=1 k=13 config->in_data=-0.213230 j=1 k=14 config->in_data=-0.215062 j=1 k=15 config->in_data=-0.208077
index=4426 in_data=-0.201053 index=4427 in_data=-0.208002 index=4428 in_data=-0.218461 index=4429 in_data=-0.227163 index=4430 in_data=-0.223537 index=4431 in_data=-0.212543 index=4432 in_data=-0.205748 index=4433 in_data=-0.204032 index=4434 in_data=-0.204794 index=4435 in_data=-0.208689 index=4436 in_data=-0.207925 index=4437 in_data=-0.191854 index=4438 in_data=-0.175210 index=4439 in_data=-0.159829 index=4440 in_data=-0.144978 index=4441 in_data=-0.131771
tdoa=0 tdoa=-1
sample max amplitude = 0.623810
sample average = 0.152095
frames = 4410
36.203 ms
j=0 k=0 config->in_data=-0.060199 j=0 k=1 config->in_data=-0.049014 j=0 k=2 config->in_data=-0.050311 j=0 k=3 config->in_data=-0.060008 j=0 k=4 config->in_data=-0.059970 j=0 k=5 config->in_data=-0.031035 j=0 k=6 config->in_data=0.003091 j=0 k=7 config->in_data=0.012634 j=0 k=8 config->in_data=0.000800 j=0 k=9 config->in_data=-0.014010 j=0 k=10 config->in_data=-0.040693 j=0 k=11 config->in_data=-0.064015 j=0 k=12 config->in_data=-0.079095 j=0 k=13 config->in_data=-0.098639 j=0 k=14 config->in_data=-0.120167 j=0 k=15 config->in_data=-0.132115
index=16 in_data=-0.123640 index=17 in_data=-0.093714 index=18 in_data=-0.058099 index=19 in_data=-0.025194 index=20 in_data=0.012863 index=21 in_data=0.044203 index=22 in_data=0.075426 index=23 in_data=0.105774 index=24 in_data=0.116462 index=25 in_data=0.104362 index=26 in_data=0.075655 index=27 in_data=0.052334 index=28 in_data=0.036531 index=29 in_data=0.001945 index=30 in_data=-0.031989 index=31 in_data=-0.051114
j=1 k=0 config->in_data=-0.017637 j=1 k=1 config->in_data=-0.015347 j=1 k=2 config->in_data=-0.020385 j=1 k=3 config->in_data=-0.016644 j=1 k=4 config->in_data=-0.008514 j=1 k=5 config->in_data=-0.000841 j=1 k=6 config->in_data=-0.011339 j=1 k=7 config->in_data=-0.018399 j=1 k=8 config->in_data=-0.026149 j=1 k=9 config->in_data=-0.040310 j=1 k=10 config->in_data=-0.055846 j=1 k=11 config->in_data=-0.064244 j=1 k=12 config->in_data=-0.069397 j=1 k=13 config->in_data=-0.080811 j=1 k=14 config->in_data=-0.083713 j=1 k=15 config->in_data=-0.074780
index=4426 in_data=-0.071841 index=4427 in_data=-0.060160 index=4428 in_data=-0.034166 index=4429 in_data=0.003968 index=4430 in_data=0.034889 index=4431 in_data=0.057678 index=4432 in_data=0.074281 index=4433 in_data=0.076839 index=4434 in_data=0.064051 index=4435 in_data=0.056036 index=4436 in_data=0.051035 index=4437 in_data=0.039621 index=4438 in_data=0.018474 index=4439 in_data=-0.002596 index=4440 in_data=-0.013742 index=4441 in_data=-0.016300
tdoa=0 tdoa=-1
sample max amplitude = 0.433503
sample average = 0.120053
frames = 4410
35.7361 ms
j=0 k=0 config->in_data=0.228496 j=0 k=1 config->in_data=0.218459 j=0 k=2 config->in_data=0.213992 j=0 k=3 config->in_data=0.210632 j=0 k=4 config->in_data=0.200785 j=0 k=5 config->in_data=0.187234 j=0 k=6 config->in_data=0.152038 j=0 k=7 config->in_data=0.099666 j=0 k=8 config->in_data=0.048364 j=0 k=9 config->in_data=0.032178 j=0 k=10 config->in_data=0.020345 j=0 k=11 config->in_data=-0.009697 j=0 k=12 config->in_data=-0.045654 j=0 k=13 config->in_data=-0.063443 j=0 k=14 config->in_data=-0.080392 j=0 k=15 config->in_data=-0.081537
index=16 in_data=-0.073215 index=17 in_data=-0.068520 index=18 in_data=-0.086575 index=19 in_data=-0.109479 index=20 in_data=-0.127991 index=21 in_data=-0.131886 index=22 in_data=-0.118983 index=23 in_data=-0.095202 index=24 in_data=-0.086690 index=25 in_data=-0.087797 index=26 in_data=-0.089590 index=27 in_data=-0.101654 index=28 in_data=-0.118487 index=29 in_data=-0.129481 index=30 in_data=-0.141085 index=31 in_data=-0.149215
j=1 k=0 config->in_data=0.179255 j=1 k=1 config->in_data=0.192310 j=1 k=2 config->in_data=0.189372 j=1 k=3 config->in_data=0.167422 j=1 k=4 config->in_data=0.151696 j=1 k=5 config->in_data=0.134020 j=1 k=6 config->in_data=0.095048 j=1 k=7 config->in_data=0.066953 j=1 k=8 config->in_data=0.061494 j=1 k=9 config->in_data=0.056685 j=1 k=10 config->in_data=0.029391 j=1 k=11 config->in_data=0.012291 j=1 k=12 config->in_data=0.004351 j=1 k=13 config->in_data=-0.020195 j=1 k=14 config->in_data=-0.044892 j=1 k=15 config->in_data=-0.046037
index=4426 in_data=-0.041723 index=4427 in_data=-0.052565 index=4428 in_data=-0.070009 index=4429 in_data=-0.082834 index=4430 in_data=-0.090660 index=4431 in_data=-0.095356 index=4432 in_data=-0.093447 index=4433 in_data=-0.080086 index=4434 in_data=-0.073787 index=4435 in_data=-0.079208 index=4436 in_data=-0.095927 index=4437 in_data=-0.111807 index=4438 in_data=-0.121350 index=4439 in_data=-0.130435 index=4440 in_data=-0.130358 index=4441 in_data=-0.130932
tdoa=0 tdoa=-1
sample max amplitude = 0.711663
sample average = 0.182032
frames = 4410
35.441 ms
j=0 k=0 config->in_data=-0.126159 j=0 k=1 config->in_data=-0.145971 j=0 k=2 config->in_data=-0.155972 j=0 k=3 config->in_data=-0.158072 j=0 k=4 config->in_data=-0.167767 j=0 k=5 config->in_data=-0.180250 j=0 k=6 config->in_data=-0.191129 j=0 k=7 config->in_data=-0.206206 j=0 k=8 config->in_data=-0.230065 j=0 k=9 config->in_data=-0.258044 j=0 k=10 config->in_data=-0.270679 j=0 k=11 config->in_data=-0.262472 j=0 k=12 config->in_data=-0.238005 j=0 k=13 config->in_data=-0.214756 j=0 k=14 config->in_data=-0.224034 j=0 k=15 config->in_data=-0.249609
index=16 in_data=-0.276710 index=17 in_data=-0.291865 index=18 in_data=-0.305530 index=19 in_data=-0.311296 index=20 in_data=-0.308509 index=21 in_data=-0.293851 index=22 in_data=-0.273656 index=23 in_data=-0.257549 index=24 in_data=-0.254457 index=25 in_data=-0.265183 index=26 in_data=-0.272398 index=27 in_data=-0.273237 index=28 in_data=-0.268809 index=29 in_data=-0.259839 index=30 in_data=-0.252892 index=31 in_data=-0.238692
j=1 k=0 config->in_data=-0.137917 j=1 k=1 config->in_data=-0.150018 j=1 k=2 config->in_data=-0.165134 j=1 k=3 config->in_data=-0.181395 j=1 k=4 config->in_data=-0.200978 j=1 k=5 config->in_data=-0.215101 j=1 k=6 config->in_data=-0.225598 j=1 k=7 config->in_data=-0.241898 j=1 k=8 config->in_data=-0.262091 j=1 k=9 config->in_data=-0.282283 j=1 k=10 config->in_data=-0.289688 j=1 k=11 config->in_data=-0.291484 j=1 k=12 config->in_data=-0.282932 j=1 k=13 config->in_data=-0.279000 j=1 k=14 config->in_data=-0.277588 j=1 k=15 config->in_data=-0.279916
index=4426 in_data=-0.281292 index=4427 in_data=-0.291445 index=4428 in_data=-0.299460 index=4429 in_data=-0.291942 index=4430 in_data=-0.263846 index=4431 in_data=-0.243272 index=4432 in_data=-0.232049 index=4433 in_data=-0.233577 index=4434 in_data=-0.245104 index=4435 in_data=-0.253464 index=4436 in_data=-0.260601 index=4437 in_data=-0.261175 index=4438 in_data=-0.261671 index=4439 in_data=-0.262778 index=4440 in_data=-0.254609 index=4441 in_data=-0.254074
tdoa=0 tdoa=-1
sample max amplitude = 0.488108
sample average = 0.157377
frames = 4410
35.8703 ms
j=0 k=0 config->in_data=-0.221705 j=0 k=1 config->in_data=-0.209222 j=0 k=2 config->in_data=-0.201474 j=0 k=3 config->in_data=-0.189984 j=0 k=4 config->in_data=-0.186320 j=0 k=5 config->in_data=-0.186243 j=0 k=6 config->in_data=-0.193419 j=0 k=7 config->in_data=-0.197618 j=0 k=8 config->in_data=-0.191702 j=0 k=9 config->in_data=-0.174487 j=0 k=10 config->in_data=-0.157346 j=0 k=11 config->in_data=-0.140627 j=0 k=12 config->in_data=-0.114632 j=0 k=13 config->in_data=-0.095698 j=0 k=14 config->in_data=-0.084210 j=0 k=15 config->in_data=-0.094286
index=16 in_data=-0.113945 index=17 in_data=-0.126579 index=18 in_data=-0.123756 index=19 in_data=-0.100394 index=20 in_data=-0.072948 index=21 in_data=-0.041265 index=22 in_data=-0.001796 index=23 in_data=0.027521 index=24 in_data=0.044775 index=25 in_data=0.060730 index=26 in_data=0.071991 index=27 in_data=0.086459 index=28 in_data=0.104246 index=29 in_data=0.127266 index=30 in_data=0.147381 index=31 in_data=0.153106
j=1 k=0 config->in_data=-0.143452 j=1 k=1 config->in_data=-0.130245 j=1 k=2 config->in_data=-0.130626 j=1 k=3 config->in_data=-0.132954 j=1 k=4 config->in_data=-0.138643 j=1 k=5 config->in_data=-0.149215 j=1 k=6 config->in_data=-0.172004 j=1 k=7 config->in_data=-0.168188 j=1 k=8 config->in_data=-0.152956 j=1 k=9 config->in_data=-0.142078 j=1 k=10 config->in_data=-0.142459 j=1 k=11 config->in_data=-0.127533 j=1 k=12 config->in_data=-0.117838 j=1 k=13 config->in_data=-0.109975 j=1 k=14 config->in_data=-0.105890 j=1 k=15 config->in_data=-0.104058
index=4426 in_data=-0.111082 index=4427 in_data=-0.113755 index=4428 in_data=-0.111501 index=4429 in_data=-0.099401 index=4430 in_data=-0.083865 index=4431 in_data=-0.051381 index=4432 in_data=-0.017102 index=4433 in_data=0.011031 index=4434 in_data=0.032178 index=4435 in_data=0.048745 index=4436 in_data=0.063899 index=4437 in_data=0.075884 index=4438 in_data=0.088749 index=4439 in_data=0.088978 index=4440 in_data=0.084131 index=4441 in_data=0.085963
tdoa=0 tdoa=-1
sample max amplitude = 0.508912
sample average = 0.167793
frames = 4410
35.9088 ms
j=0 k=0 config->in_data=-0.139366 j=0 k=1 config->in_data=-0.128184 j=0 k=2 config->in_data=-0.130893 j=0 k=3 config->in_data=-0.128526 j=0 k=4 config->in_data=-0.136008 j=0 k=5 config->in_data=-0.158033 j=0 k=6 config->in_data=-0.174258 j=0 k=7 config->in_data=-0.174371 j=0 k=8 config->in_data=-0.170746 j=0 k=9 config->in_data=-0.175439 j=0 k=10 config->in_data=-0.194144 j=0 k=11 config->in_data=-0.206512 j=0 k=12 config->in_data=-0.193344 j=0 k=13 config->in_data=-0.151850 j=0 k=14 config->in_data=-0.122686 j=0 k=15 config->in_data=-0.135550
index=16 in_data=-0.168417 index=17 in_data=-0.176623 index=18 in_data=-0.157500 index=19 in_data=-0.132077 index=20 in_data=-0.106844 index=21 in_data=-0.085316 index=22 in_data=-0.068749 index=23 in_data=-0.065046 index=24 in_data=-0.075734 index=25 in_data=-0.078369 index=26 in_data=-0.081040 index=27 in_data=-0.109211 index=28 in_data=-0.151505 index=29 in_data=-0.177235 index=30 in_data=-0.175784 index=31 in_data=-0.175632
j=1 k=0 config->in_data=-0.146315 j=1 k=1 config->in_data=-0.146467 j=1 k=2 config->in_data=-0.149215 j=1 k=3 config->in_data=-0.154904 j=1 k=4 config->in_data=-0.179983 j=1 k=5 config->in_data=-0.196282 j=1 k=6 config->in_data=-0.193380 j=1 k=7 config->in_data=-0.183266 j=1 k=8 config->in_data=-0.170440 j=1 k=9 config->in_data=-0.164180 j=1 k=10 config->in_data=-0.173723 j=1 k=11 config->in_data=-0.179296 j=1 k=12 config->in_data=-0.171242 j=1 k=13 config->in_data=-0.158301 j=1 k=14 config->in_data=-0.164332 j=1 k=15 config->in_data=-0.184143
index=4426 in_data=-0.194296 index=4427 in_data=-0.190748 index=4428 in_data=-0.190709 index=4429 in_data=-0.188610 index=4430 in_data=-0.157804 index=4431 in_data=-0.117151 index=4432 in_data=-0.091157 index=4433 in_data=-0.094476 index=4434 in_data=-0.105624 index=4435 in_data=-0.111998 index=4436 in_data=-0.137269 index=4437 in_data=-0.164751 index=4438 in_data=-0.177845 index=4439 in_data=-0.187540 index=4440 in_data=-0.201665 index=4441 in_data=-0.232394
tdoa=0 tdoa=-1
sample max amplitude = 0.589148
sample average = 0.145950
frames = 4410
35.7512 ms
j=0 k=0 config->in_data=0.116882 j=0 k=1 config->in_data=0.129975 j=0 k=2 config->in_data=0.158337 j=0 k=3 config->in_data=0.178455 j=0 k=4 config->in_data=0.172347 j=0 k=5 config->in_data=0.151390 j=0 k=6 config->in_data=0.144976 j=0 k=7 config->in_data=0.151045 j=0 k=8 config->in_data=0.151657 j=0 k=9 config->in_data=0.133945 j=0 k=10 config->in_data=0.100621 j=0 k=11 config->in_data=0.069166 j=0 k=12 config->in_data=0.047677 j=0 k=13 config->in_data=0.023437 j=0 k=14 config->in_data=-0.012865 j=0 k=15 config->in_data=-0.049205
index=16 in_data=-0.066114 index=17 in_data=-0.066878 index=18 in_data=-0.057832 index=19 in_data=-0.054397 index=20 in_data=-0.052143 index=21 in_data=-0.053175 index=22 in_data=-0.058863 index=23 in_data=-0.068062 index=24 in_data=-0.072184 index=25 in_data=-0.079170 index=26 in_data=-0.104058 index=27 in_data=-0.122992 index=28 in_data=-0.127916 index=29 in_data=-0.123640 index=30 in_data=-0.120015 index=31 in_data=-0.106960
j=1 k=0 config->in_data=0.085353 j=1 k=1 config->in_data=0.086727 j=1 k=2 config->in_data=0.095086 j=1 k=3 config->in_data=0.098979 j=1 k=4 config->in_data=0.102836 j=1 k=5 config->in_data=0.104820 j=1 k=6 config->in_data=0.111653 j=1 k=7 config->in_data=0.106461 j=1 k=8 config->in_data=0.083863 j=1 k=9 config->in_data=0.064663 j=1 k=10 config->in_data=0.057714 j=1 k=11 config->in_data=0.055959 j=1 k=12 config->in_data=0.028552 j=1 k=13 config->in_data=-0.017025 j=1 k=14 config->in_data=-0.053746 j=1 k=15 config->in_data=-0.061802
index=4426 in_data=-0.065618 index=4427 in_data=-0.058022 index=4428 in_data=-0.046686 index=4429 in_data=-0.038517 index=4430 in_data=-0.031683 index=4431 in_data=-0.033708 index=4432 in_data=-0.060122 index=4433 in_data=-0.093753 index=4434 in_data=-0.125130 index=4435 in_data=-0.143565 index=4436 in_data=-0.150589 index=4437 in_data=-0.145590 index=4438 in_data=-0.144864 index=4439 in_data=-0.145474 index=4440 in_data=-0.137840 index=4441 in_data=-0.114059
tdoa=0 tdoa=-1
sample max amplitude = 0.457188
sample average = 0.123329
frames = 4410
36.0589 ms

I thought a kip and a new day woud have a eurika moment that has failed to arrive and bugging me as know this is real simple.

Wow that really twisted my melon always hate complex array manipulation but think that is fixed.
Or at least the complete mismatch on the circular buffer is fixed maybe a few extras as prob need some sort of damping on the beamformer if it changes drastically between chunks.
The bug I have been hair pulling for the last couple of days means I will be leaving as is for a while :slight_smile:

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

[EDIT] spoke too soon that slight mismatch on the circ buffer is till there just going to give it a rest and prob it will become apparent on next try.

Yeah wow fixed and hate arrays!!!