Eviltechie
Member
Hi,
I recently grabbed a Teensy 4.1 in hopes of using it as a S/PDIF tone generator. Unfortunately I am not having any luck, so hopefully somebody can help me figure out what's going wrong.
My initial goal is to play a WAV file on loop with a GLITS test tone. I created the test tone in Audacity, and have verified that it is 44.1KHz and 16 bit. The file is loaded onto a FAT32 partition on a micro SD card.
I am using the following code (which is basically just the WavFilePlayer example, with the output substituted to be AudioOutputSPDIF3 which I understand is the built in S/PDIF output on pin 14).
I am using the following circuit to drop the output level down to get about 0.6V max. This was based off a few other forum threads I saw here.
I bought a cheap S/PDIF to analog converter off Amazon in order to test the output.
Unfortunately I have had no luck getting any audio out. I did try the other two S/PDIF output modes and their respective pins, and also got absolutely nothing. I also tried substituting the WAV file for a sine block and got nothing as well.
What might I be doing wrong here?
Thanks
I recently grabbed a Teensy 4.1 in hopes of using it as a S/PDIF tone generator. Unfortunately I am not having any luck, so hopefully somebody can help me figure out what's going wrong.
My initial goal is to play a WAV file on loop with a GLITS test tone. I created the test tone in Audacity, and have verified that it is 44.1KHz and 16 bit. The file is loaded onto a FAT32 partition on a micro SD card.
I am using the following code (which is basically just the WavFilePlayer example, with the output substituted to be AudioOutputSPDIF3 which I understand is the built in S/PDIF output on pin 14).
C-like:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
AudioPlaySdWav playWav1;
AudioOutputSPDIF3 audioOutput;
AudioConnection patchCord1(playWav1, 0, audioOutput, 0);
AudioConnection patchCord2(playWav1, 1, audioOutput, 1);
#define SDCARD_CS_PIN BUILTIN_SDCARD
#define SDCARD_MOSI_PIN 11
#define SDCARD_SCK_PIN 13
void setup() {
Serial.begin(9600);
AudioMemory(8);
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);
playWav1.play(filename);
delay(25);
while (playWav1.isPlaying()) {
}
}
void loop() {
playFile("GLITS16.WAV"); // filenames are always uppercase 8.3 format
delay(500);
}
I am using the following circuit to drop the output level down to get about 0.6V max. This was based off a few other forum threads I saw here.
I bought a cheap S/PDIF to analog converter off Amazon in order to test the output.
Unfortunately I have had no luck getting any audio out. I did try the other two S/PDIF output modes and their respective pins, and also got absolutely nothing. I also tried substituting the WAV file for a sine block and got nothing as well.
What might I be doing wrong here?
Thanks