0

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

  • Those are multiples of 128 not 125 - i.e. the least significant 7 bits are always zero. That may simply mean that they are low amplitude samples left-shifted into machine integer type, or it could be an error earlier in the system PDM is converted to PCM by a low-pass filter digital. That is presumably what the `HAL_DFSDM_Filter` is doing? i.e. that are not PDM values. Who knows what the FFT of for? Is this not your code? – Clifford Jul 04 '19 at 14:11
  • Yes, it's 128, typo on my part. No it's not my code and I'm trying to convert the input into pcm data, ideally so that I can create wav files. This is the source code for the most part: https://github.com/y2kblog/NUCLEO-L476RG_DFSDM_PDM-Mic – HubbaBubba Jul 05 '19 at 17:32
  • I see; in that case the FFT stuff is irrelevant. The filter will output PCM. It is not clear, whether that samples you have reported are input to (from the DMA buffer), or output from the filter. – Clifford Jul 05 '19 at 17:42

0 Answers0