Direction of Arrival ODAS demo code issue - some LEDs skipped

Hello, I have a MATRIX Voice i would like to run with my raspberry.
I followed your guide https://www.hackster.io/matrix-labs/direction-of-arrival-for-matrix-voice-creator-using-odas-b7a15b, and after resolving the conflict with Kernel modules by downgrading my kernel, the demo works.

However, when i try to use the code in the demo in a class in my own project, I am experiencing some weird behaviour. Only some of the LEDs light up when sound comes in from their direction, and the rest are completely non-reactive.
The working LEDs are LED 1, 2, 5, 6, 9, 11, 12, 15 and 16, which seems to be a pattern of 2 working, followed by 2 not working, repeating.

All of the working LEDs light up at startup, as shown below.
(Excuse the poor image quality)
image
A friend of mine with his own raspberry and MATRIX Voice has also tested the code, and experienced the same issue, but with different LEDs working in the same 2 on 2 off pattern.

I put the demo code (from matrix-odas.cpp) into a class and removed the forward decleration of json_parse in json_parse_array, as it was already declared in my .h file. Other than that i do not believe i made any significant changes to the code.
My class can be seen here: SoundNavigationF21/odas.cpp at main · ELindby/SoundNavigationF21 · GitHub

I am still able to run the demo outside my own project with no issues whatsoever. I also tried compiling the demo code(matrix-odas.cpp) with the same script i use to run my project, and experienced no issues, which leads me to believe the issue comes from using the code in a class somehow.

I’m at a loss for what is going wrong, and would appreciate any help/pointers. Thank you.

I managed to solve the issue (I don’t know how to mark the thread as solved, sorry).
The problem was the int array ‘energy_array’ in the demo wasn’t being initialised. When compiled in main, it somehow always set the integers to 0 when compiled in main (or a value large enough to be capped to MAX_VALUE by increase_pots), and set half of the integers to an absurdly large negative value when compiled as a class member variable.
The fix is somewhat simple for anyone else who might have this problem, just give energy array an initializer list:
int energy_array[ENERGY_COUNT] = {0};

Hope this might be of some use to any others who encounter this issue.