Skip to content

Conversation

nseidle
Copy link
Member

@nseidle nseidle commented Nov 20, 2019

Thanks to @justiceamoh we have a sketch that outputs PDM values over serial and with the help of a python sketch, we can visualize the audio data and create a wav file. Works well.

Also in this PR, I moved some of the variables around inside of PDM.cpp, namely sTransfer was a locally declared variable. It's now a global. This allows us to remove the 100ms wait every time we check for new PDM data. getData works more straightforward as well.

I'm skeptical that the PDM library is very useful. Because of the audio data rates you really need to write your own ISR rather than poll for myPDM.available(). Example 4 demonstrates this nicely but has an awful lot of HAL calls. This is a good incremental step forward but the PDM library could be improved further.

Previously it was a bit bad: sTransfer was locally declared and used which is bad. It's now global. getData now expects the caller to provide buffer and transfers the PDM data to caller. This simplifies how the example sketches look an act.
@nseidle
Copy link
Member Author

nseidle commented Nov 20, 2019

Please don't merge just yet. I am going to try to reduce the bitrate.

@nseidle
Copy link
Member Author

nseidle commented Nov 21, 2019

justiceamoh had a quick fix for the bitrate. Wav files are now playable by most any audio player.

In the end I went with the dual buffer method. This is better but not yet ideal. The user is locked into a 4096 uint16_t read from the buffer but it works well. If we come back to this I've left my work in place for the circular buffer method.

Ready to merge. PDM lib is now much better.

@oclyke oclyke merged commit 4a4d739 into master Dec 3, 2019
@oclyke oclyke deleted the pdmFixing branch December 3, 2019 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants