I have been trying to output audio from the SD card reader through the S/PDIF OUT pin without success, I'm a trying to run the example code but the file doesn't seem to be playing, the code detects and reads the SD card and showing the files in it when using the Hardware test. I am using a WAV file from FL Studio called VOCALS_FALL_SILENTLY.WAV. Serial shows the "Playing now" message but no audio is heard. I am connecting S/PDIF OUt (pin 14) to a digital coax jack input and ground of a small DAC audio board to output it to regular RCA jacks connected to a speaker, the board is working properly, I tested it several times already with different devices. Here's the code I am running (NOTE: I am not using a POT to control volume):
---------------------------------------------
SERIAL OUTPUT:
Start Playing
Start Playing
Start Playing
Start Playing
---------------------------------------------
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySdWav playSdWav1;
AudioOutputSPDIF3 spdif3_1;
AudioConnection patchCord1(playSdWav1, 0, spdif3_1, 0);
AudioConnection patchCord2(playSdWav1, 1, spdif3_1, 1);
//AudioControlSGTL5000 sgtl5000_1;
// Use these with the Teensy Audio Shield
//#define SDCARD_CS_PIN 10
//#define SDCARD_MOSI_PIN 7
//#define SDCARD_SCK_PIN 14
// Use these with the Teensy 3.5 & 3.6 SD card
#define SDCARD_CS_PIN BUILTIN_SDCARD
#define SDCARD_MOSI_PIN 11 // not actually used
#define SDCARD_SCK_PIN 13 // not actually used
void setup() {
Serial.begin(9600);
AudioMemory(8);
//sgtl5000_1.enable();
//sgtl5000_1.volume(0.6);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
delay(1000);
}
void loop() {
if (playSdWav1.isPlaying() == false) {
Serial.println("Start playing");
playSdWav1.play("VOCALS_FALL_SILENTLY.WAV");
delay(10); // wait for library to parse WAV info
}
// do nothing while playing...
}
---------------------------------------------
SERIAL OUTPUT:
Start Playing
Start Playing
Start Playing
Start Playing
---------------------------------------------
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySdWav playSdWav1;
AudioOutputSPDIF3 spdif3_1;
AudioConnection patchCord1(playSdWav1, 0, spdif3_1, 0);
AudioConnection patchCord2(playSdWav1, 1, spdif3_1, 1);
//AudioControlSGTL5000 sgtl5000_1;
// Use these with the Teensy Audio Shield
//#define SDCARD_CS_PIN 10
//#define SDCARD_MOSI_PIN 7
//#define SDCARD_SCK_PIN 14
// Use these with the Teensy 3.5 & 3.6 SD card
#define SDCARD_CS_PIN BUILTIN_SDCARD
#define SDCARD_MOSI_PIN 11 // not actually used
#define SDCARD_SCK_PIN 13 // not actually used
void setup() {
Serial.begin(9600);
AudioMemory(8);
//sgtl5000_1.enable();
//sgtl5000_1.volume(0.6);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
delay(1000);
}
void loop() {
if (playSdWav1.isPlaying() == false) {
Serial.println("Start playing");
playSdWav1.play("VOCALS_FALL_SILENTLY.WAV");
delay(10); // wait for library to parse WAV info
}
// do nothing while playing...
}
Last edited: