I am trying to capture audio PDM samples at every 5s interval blocks, but at the time of "pevt->buffer_released" event when i am giving the new buffer to PDM driver it results in some noisy data at every block of my buffer size(PDM_SAMPLE_SIZE). I have set the PDM driver at default sample rate 16KHz, Mono channel (right), 16 bit PCM encoding. I am getting noise while fetching DMA data.
Questions:
Why i am getting noise at every memory block (attached binary file of 100K data samples around 5 seconds of voice data) ?
Is there any document which shows internal easy DMA handling and buffer collection such that i can copy the chunk of buffers to other memory without losing/avoid data corruption on the incoming voice data samples?
Attaching code snippet, on how i handle the PDM data buffers and copy it to RAM(100k buffer) for further processing.
#define PDM_SAMPLE_SIZE 400 void pdm_event_handler (const nrfx_pdm_evt_t* pevt) { if (pevt->buffer_released == g_pdmBuffers[0]) { g_voiceActivityDetected[0] = 1; memcpy(&g_FlashStoreSample[g_pdmBufAcqCount * PDM_SAMPLE_SIZE], g_pdmBuffers[0], PDM_SAMPLE_SIZE * 2); g_errcode = nrfx_pdm_buffer_set(g_pdmBuffers[0], PDM_SAMPLE_SIZE); g_pdmBufAcqCount++; } else if (pevt->buffer_released == g_pdmBuffers[1]) { g_voiceActivityDetected[1] = 1; memcpy(&g_FlashStoreSample[g_pdmBufAcqCount * PDM_SAMPLE_SIZE], g_pdmBuffers[1], PDM_SAMPLE_SIZE * 2); g_errcode = nrfx_pdm_buffer_set(g_pdmBuffers[1], PDM_SAMPLE_SIZE); g_pdmBufAcqCount++; } if(g_pdmBufAcqCount >= 200) { g_pdmBufAcqCount = 200; } }
Output file converted from binary PDM data file:
Input audio file:
Note: Using ICS-41351 Microphone sensor to capture PDM samples