Not Getting any Audio Output from Teensy 4.1

Status
Not open for further replies.

DeMoeP

Member
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...
}
 
Last edited:
Which version of Teensyduino are you using? In Arduino, click Help > About.

For long filenames like VOCALS_FALL_SILENTLY.WAV, you need 1.54-beta. It uses SdFat which supports long filenames.

Version 1.53 has the old Arduino SD library which supports only 8.3 names. This program should work, but you will need to rename your file. Also make sure the encoding is 16 bits at 44.1 kHz. WAV files with different encoding won't play.
 
Which version of Teensyduino are you using? In Arduino, click Help > About.

For long filenames like VOCALS_FALL_SILENTLY.WAV, you need 1.54-beta. It uses SdFat which supports long filenames.

Version 1.53 has the old Arduino SD library which supports only 8.3 names. This program should work, but you will need to rename your file. Also make sure the encoding is 16 bits at 44.1 kHz. WAV files with different encoding won't play.

I had the 1.53 version and updated to 1.54 beta, also I changed the name of my file to just VOCALS.WAV but couldn't get audio. I also tried with the test files from the website SDTEST1.WAV to make sure it wasn't the file but still no audio. When I plug the cable from pin 14 or press the reboot button of the Teensy4.1 I do hear a pop in my speakers
 
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.
S/PDIF voltage is meant to be between 0.2 and 0.6V, you might be blowing away the head end of the S/PDIF->analog converter?

A 240:100 ohm divider will take a 3.3V logic signal down to about 0.5V into a 75 ohm load. You also need a DC blocking cap,
say 100nF on the input to the divider.

[ https://en.wikipedia.org/wiki/S/PDIF#Hardware_specifications - note the 0.6V peak-to-peak limit on S/PDIF signals... ]
 

I appreciate the help and the advice but I couldn't get the audio to work and I am running out of time to finish my project so I opted to buy a Teensy Audio Shield so now I am using i2c to output straight to RCA and it works now.
 
Status
Not open for further replies.
Back
Top