Trouble extracting data using DMIC

Hi there!

I am using the DMIC sample on a nrf5340dk. I have got it working, and now I want to develop it further. I want to record some sound and then transfer it to my PC. I have a lot of questions that I struggle with finding the answers to.

Now I understand that the data stored should already be stored as PCM data. So I can easily convert them to WAV files with a script on my PC. Is this correct?

When I record now I can leave it one for multiple seconds, but the data collected only corresponds to a few milliseconds. I suspect this is due to a lot of time being used logging to the console. The way I do it now, is that I log the collected data to the console, and then extract it onto the PC from there. However I can imagine this is quite slow. I was thinking of printing it out after the recording is done instead. But I struggle with understanding how the memory allocation in this sample works. I use:

void *buffer;

But this buffer get owerwritten with new data. How do I go about not overwriting the data and retrieving it later? (The recording does not need to be longer than a few seconds, maybe even shorter)

I also struggle with understanding the part the memory slab plays in the program. Defined as:

K_MEM_SLAB_DEFINE_STATIC(mem_slab, MAX_BLOCK_SIZE, BLOCK_COUNT, 4);
  • I had build a simple example that sends data out via Serial as ASCI HEX strings.
    It's not efficient but was an easy way for prototyping.
    You can find that project attached in this issue but I would recommend you use the fixed example Torbjørn posted in the accepted answer:
    RE: DMIC pop / click sounds between each memory block

    Just capture the Serial output on your computer and use the included Python script to convert it into raw PCM data that you can then import into Audacity or Adobe Audition for playback.

    If you get repeated data or junk data then you likely have a hardware issue, the pdm driver returns data no matter if there is a microphone attached or not, so you might just be reading whatever happens to be in uninitialized memory.

1 2 3