2024-04-25 9:01 PM
I have some questions and remarks about the PDMFilter (used for PDM MICs).
I have it working fine on a Portenta H7. Almost all OK.
I have studied the UM2372 : STM32Cube PDM2PCM software library for the STM32F4/F7/H7 Series - User manual
Here are my questions:
1. Source Code:
Is there any chance to get the source code (GitHub) for this (new version of) filter implementation?
2. Filter implementation details:
OK, the current version is now using an IIR filter (OK, I understand maybe why: code size, speed, latency). The older version (not recommended and supported anymore), was based on FIR, I could still find here:
codec2_m4f/lib/PDM_filter at master · piratfm/codec2_m4f · GitHub
a) the IIR filter:
generates some artefacts (in spectrum, even documented in UM2372, e.g. a remarkable 3rd harmonics). I think to see that also other "side tones" are generated (OK).
The PDM2PCM filter is very sensitive for the right amplification setting (and with which amplitude the signal from PDM comes in). Obvious.
If you do something not really "right", e.g. too much amplification (gain) or a too strong signal, what happens (and I can "see" and hear):
All this is acceptable (and obvious), just: "maybe a 'better' " filter design is possible.
b) Please, may I get more details about the filter implementation:
Below some examples what I get (from a generated 1KHz PDM sine signal, fed into PDMFilter (not a real MIC signal, no MIC or a speaker involved, a "pure" PDM signal played from buffer - OK, it generates also "side tones").
So, even it works nice, I am thinking to implement my own PDMFilter (as FIR, with ARM DSP and Fix Point math, potentially using the HW FPU).
Or: does anybody has one already? (or if STM thinking to provide source code for one?)
Solved! Go to Solution.
2024-05-02 10:19 PM
I have now created my own FIR based PDM2PCM filter (based on ARM CMSIS DSP):
sounds better and makes a bit more sense, but potentially too slow (I hear discontinuities).
For implementing your own filter, here two helpful links:
https://www.keil.com/pack/doc/CMSIS/DSP/html/group__FIR__decimate.html
http://t-filter.engineerjs.com/
Here some slides comparing the original (latest) STM PDM2PCM filter with my one:
Conclusion:
Actually, the STM PDM2PCM filter is not bad (it has just still too much high frequency noise and distortion due to it). It sounds a bit sharp (harsh).
It might make sense to use this filter (in order to convert from PDM to PCM), but to add another low pass filter (with few taps) afterwards (in order to remove the still remaining high frequency noise).
My project (with my own filter) can be found here:
2024-04-26 3:26 PM
I found this great document: AN5795
Exactly what I am looking for. For Portenta H7 (STM32H747) I had to implement in SW (as ARM CMSIS DSP). But for the STM32U5xx it is supported by HW. Very nice!
Luckily, I have a STM32U5A5 project and PCB working. So, I can give it a try on STM32U5.
What a cool MCU!
Question:
In AN5795 is mentioned, a comparison was done with an ARM DSP implementation.
Is there a chance to get the source code for SW implementation of the filter? Thank you.
2024-05-02 10:19 PM
I have now created my own FIR based PDM2PCM filter (based on ARM CMSIS DSP):
sounds better and makes a bit more sense, but potentially too slow (I hear discontinuities).
For implementing your own filter, here two helpful links:
https://www.keil.com/pack/doc/CMSIS/DSP/html/group__FIR__decimate.html
http://t-filter.engineerjs.com/
Here some slides comparing the original (latest) STM PDM2PCM filter with my one:
Conclusion:
Actually, the STM PDM2PCM filter is not bad (it has just still too much high frequency noise and distortion due to it). It sounds a bit sharp (harsh).
It might make sense to use this filter (in order to convert from PDM to PCM), but to add another low pass filter (with few taps) afterwards (in order to remove the still remaining high frequency noise).
My project (with my own filter) can be found here: