Outputting audio from SD card?

Status
Not open for further replies.

DeMoeP

Member
I am building a MIDI controller/Launchpad with a Teensy 4.1 and I would like some guidance on developing a code to read WAV files from an SD card and output the audio. I already developed the MIDI part of my code and it works, but I am also planning on using it as a standalone device, feeding the Teensy from the 5v pin and displaying a folder menu on my LCD screen to select an audio library and assign different WAV files to the buttons of the Launchpad. I need help understanding the necessary functions to 1) output audio from the Teensy 4.1 (S/PDIF seems to be the audio port). 2) Reading and selecting WAV files from the micro SD card the Teensy will be reading from it's slot 3) Separate MIDI from standalone (I understand the MCU can be set to serial+MIDI+audio). Thank you in advance 😀
 
You should start with this tutorial that Paul did some years ago to better understand the pieces. Note with Teensy 4.0/4.1 some of the pins used are different than the 3.2/3.5/3.6 examples.

In the examples, there is a simple WAV player (Examples -> Audio -> WavFilePlayer).

You will need to modify the example to use the correct pins.

If you want to use the built-in micro SD card reader of the Teensy 4.1, change the pins to:
Code:
// Use these with the Teensy 4.1 SD card
#define SDCARD_CS_PIN    BUILTIN_SDCARD
#define SDCARD_MOSI_PIN  11  // not actually used
#define SDCARD_SCK_PIN   13  // not actually used

If you want to use the slower micro SD card reader on the audio board you would need to use:
Code:
// Use these with the Teensy Audio Shield (revision D)
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  11
#define SDCARD_SCK_PIN   13
 
Status
Not open for further replies.
Back
Top