I'm working on an embedded system (NUCLEO-L476RG) with a pdm (pulse-density modulation) MEMS microphone. Mind you that I'm not very familiar with audio processing. The program can currently convert pdm values into the frequency domain through fast fourier transform. However, I need the data in the time domain or convert it into PCM. Basically audio data that would enable me to create wav files. So I tried capturing the pdm data by itself but somehow when I print them out I get multiples of 125. i.e. 0 -1024 -1792 -256 -256 -1024 -1280 -768 -768 -1536 -256
What do these values represent? Shouldn't pdm values be single bits? What drivers/middleware would I need to convert pdm to pcm if at all possible? For reference I'm using arm_math.h from the CMSIS DSP Library if that's relevant. This is likely not enough info so feel free to ask me questions about things I missed, thanks.
I have not tried too many things as its not my codebase so I don't fully understand it to begin with.
// I think pdm data comes from this function
// and stored in 'Buff'
HAL_DFSDM_FilterRegularStart_DMA(&hdfsdm1_filter0, Buff,
FFT_SampleNum)
.
.
.
.
.
// This is where pdm values are plugged into fast fourier transform
// input data
for (uint32_t i = 0; i < FFT_SampleNum; i++)
FFT_inp[i] = (float) FFT_inp_int32[i];
// Windowing
arm_mult_f32(FFT_inp, FFT_window, FFT_inp, FFT_SampleNum);
// Execute FFT
arm_rfft_fast_f32(&S, FFT_inp, FFT_oup, 0);
// calculate magnitude
arm_cmplx_mag_f32(FFT_oup, FFT_mag, FFT_SampleNum / 2);
// Normalization (Unitary transformation) of magnitude
arm_scale_f32(FFT_mag, 1.0f / sqrtf((float) FFT_SampleNum),
FFT_mag, FFT_SampleNum / 2);
// AC coupling
for (uint32_t i = 0; i < FFT_SampleNum / 2; i++)
{
if (*(FFT_frq + i) < FFT_AC_COUPLING_HZ)
FFT_mag[i] = 1.0f;
else
break;
}
Heres the base code: https://github.com/y2kblog/NUCLEO-L476RG_DFSDM_PDM-Mic