Teensy4.1 Play .wav from sdio and output PWM audio

3EB2C70F

New member
Hello

I want to use teensy4.1 to play wave file from on-board sdio, and output as PWM (wave frequency range mapped to PWM duty range).

The audio lib seemed to be a good place to start. However I soon found out:

1.Audio lib does not support sdio
2.Audio lib does not support PWM output for Teensy4.1

So the audio library seems useless to me.

Without audio library, I have no idea how to read a .wav file.

Is there an example for reading wave file without audio library ?

Thanks!
 
First, install Teensyduino 1.57. Version 1.56 and earlier had MSQ output, which is basically PWM but with extra noise shaping stuff. Versions 1.57 adds PWM output for Teensy 4. But you still might prefer to use MSQ. With 1.57 you have 2 ways to get PWM output.

You can indeed play a WAV file from the build in SD card. In Arduino, click File > Examples > Audio > WavFilePlayer. To use SDIO, look for the comments about BUILTIN_SDCARD.

To output PWM, change AudioOutputI2S to either AudioOutputPWM or AudioOutputMQS.
 
Back
Top