[Solved] How to increase recording duration in HAL code

If I increase, seconds_to_record in https://github.com/matrix-io/matrix-creator-hal/blob/master/demos/micarray_recorder.cpp , I am encountering segmentation fault. I can only record 5 seconds of data. How to increase it ?

I just tested and I could record up to 28 min by just changing the seconds_to_record variable. With numbers bigger than this I get the same segmentation fault error you got.

This is a simple demo about how to use the mic interface from C++ using HAL. To be able to record for longer periods a different implementation is required. The error occurs in line 50 while the buffer its been created, probably because is too big for the Pi to handle it.

Another simple change that would allow you to record more time would be to record fewer channels, so the buffer is smaller.

PD: I used the default sampling freq of 16kHz

Yes, I understand but if you increase the sampling rate upto 48 KHz you can only upto 10 sec. I think that you need a circular buffer with producer/consumer to record higher sampling rate for longer duration ?

Hello @swadhinp,

Did you try with something like:https://github.com/matrix-io/matrix-creator-hal/blob/master/demos/micarray_alsa_pipes.cpp in this example, we create pipes to connect with the dummy_card and then use the Microphone Array with ALSA.

Let me know how your test work.

Thank You

Kevin Patino

Can you elaborate a bit on this ?

Hi @swadhinp

The example has been parameterized:

usage:

./micarray_recorder  --duration 20 --sampling_frequency 48000

– afc

That’s great. But, I am getting empty files after converting to wav files. What am I doing wrong ?

Sorry, I forgot to perform a reboot after updating. Recording across all the channels are not noisy at all. And the sampling rate support is 48K. Gradual LED light change is excellent. I am becoming a bit greedy but when will be the tentative 96K sampling release ?

@swadhinp
We will do a new release the next week :slight_smile:

BR,

– afc