There is an example in the Tympan_Library for playing WAV files. Currently, it’s here: Tympan_Library/examples/02-Utility/SDWavPlayer at master · Tympan/Tympan_Library · GitHub
If you’re having problems making this work, you could try the Teensy audio library’s version first. It is called and WavFilePlayer. I’ve adapted it to work with Tympan without using the underlying Tympan SD classes. It’s a great way to test if your setup is working without worrying if the Tympan library is working.
Here’s the adapted sketch:
// Simple WAV file player example from the Teensy audio library
//
// Adapted for Tympan RevD
//
// WAV files to put on your SD card can be downloaded here:
// http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
//
// This example code is in the public domain.
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
#include <Tympan_Library.h> // added for Tympan
AudioPlaySdWav playWav1;
AudioOutputI2S audioOutput;
AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
Tympan myTympan(TympanRev::D);
// Use these with the Teensy 3.5 & 3.6 SD card...Works for Tympan RevD
#define SDCARD_CS_PIN BUILTIN_SDCARD
#define SDCARD_MOSI_PIN 11 // not actually used?
#define SDCARD_SCK_PIN 13 // not actually used?
void setup() {
// Audio connections require memory to work.
AudioMemory(8);
//enable the flow of audio
myTympan.enable(); //switched to Tympan
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
// stop here, but print a message repetitively
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
}
void playFile(const char *filename)
{
Serial.print("Playing file: ");
Serial.println(filename);
// Start playing the file. This sketch continues to
// run while the file plays.
playWav1.play(filename);
// A brief delay for the library read WAV info
delay(5);
// Simply wait for the file to finish playing.
while (playWav1.isPlaying()) {} //wait while it plays
}
void loop() {
playFile("SDTEST1.WAV"); // filenames are always uppercase 8.3 format
delay(500);
}
Finally, you need a WAV files: “SDTEST1.WAV”. It needs to be 44.1 kHz, 16-bit, stereo. You can make your own or get one from: Audio Library, for high quality sound input, processing and output on Teensy 3
If this Teensy WAV player works, but the Tympan_Library SD player doesn’t, we know that we have a Tympan problem! Let me know!
Chip