Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

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

  1. #1
    Junior Member
    Join Date
    Jun 2021

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


    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 ?


  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts