Is it possible to create a wav file from PDM microphone. I am using Adafruit PDM Microphone Breakout with Arduino MKR zero. Is it necessary to convert PDM data to PCM format to save it in wav file?
Yes. [u]WAV files[/u] are PCM.
Virtually all digital audio is PCM, although it my be compressed/decompressed or converted to/from some other format.
Almost all ADCs and DACs are integer-PCM. Almost all audio editing/processing is done in PCM.
PCM is a sequence of amplitude sample-values, sampled at a fixed sample-rate. If you don't know what I'm talking about, the [u]Audacity Website[/u] has a nice-gentile introduction to how digital audio works.
PDM is a digital signal--it's either on or off--but it's not really like an ADC. It's more like a raw Sigma-Delta signal.
You could try sampling the signal with a digital input pin (at 1-3MHz) and then average a bunch of on-off samples in software into PCM samples, or you could add a hardware low-pass filter (a simple RC filter may do) and sample it with the ADC.
The first option seems like a difficult task to me (and is more suitable to low-level assembly programming), and the second option defeats the purpose of using PDM in the first place.
Some heavyweight DSP processing is needed to handle PDM - an I2S microphone is the sort to go for if you don't want to handle that task and just want the samples. PDM's advantage seems to be only one signal wire is needed to send it.
You can crudely filter PDM with an analog RC filter and sample that, but don't expect hifi performance!
The latest release (1.42) of Teensyduino can handle a PDM microphone. Don’t know about its ability to record to SD card but have a look here about half way down the page.
I wrote that PDM filter! :)
It has much better passband flatness than the usual CIC approach, but even using a huge table lookup for pre-computed groups of 8 multiply-accumulate operations, it uses about 40% of the CPU time on a Teensy running at 96 MHz.
The remaining 60% is probably enough to get the data written to a SD card. If you get a Teensy 3.x board to try this, in Arduino (with Teensy selected in the boards menu) click File > Examples > Audio > Recorder for code to continuously write incoming audio to a SD card. The example uses normal I2S input, but it should be fairly straightforward to replace the I2S input object with the PDM one.
A Teensy 3.6 would be ideal for this sort of project, since the 180 MHz speed will let you run the filter in about half the time, and it has a SD card socket with native 4-bit SDIO which is faster than the SPI-based SD card interface used on most other boards.
What if you want to store the raw PDM output then convert it to a wav file later? Is there a tool for doing this?