I can't play Wav files

Status
Not open for further replies.
I'm trying to play SDfiles with a TDA1543 (similar to PT8211), but nothing happen.

I successfully tried the ListFiles Sketch, so I know that Teensy 3.5 can access the SDcard and sees the 4 files as per the following serial monitore message :
Initializing SD card...initialization done.
SYSTEM~1/
INDEXE~1 76
SDTEST1.WAV 16787550
SDTEST4.WAV 17173152
SDTEST3.WAV 13617358
SDTEST2.WAV 16425698
done!


However, when I try to play those Files, nothing work.
Here is what I have as a programm

The serial monitor never write anything and I get no sound from the DAC
Code:
// Simple WAV file player example
// This example code is in the public domain.

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

File root;

AudioPlaySdWav           playWav1;
AudioOutputPT8211        pt8211_1;   
AudioConnection          patchCord1(playWav1, 0, pt8211_1, 0);
AudioConnection          patchCord2(playWav1, 1, pt8211_1, 1);

const int chipSelect = BUILTIN_SDCARD;

void setup() {
  Serial.begin(9600);
  AudioMemory(8);
  Serial.print("Initializing SD card...");

  if (!SD.begin(chipSelect)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  root = SD.open("/");
}

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()) {}
}


void loop() {
  playFile("SDTEST1.WAV");  // filenames are always uppercase 8.3 format
  delay(500);
  playFile("SDTEST2.WAV");
  delay(500);
  playFile("SDTEST3.WAV");
  delay(500);
  playFile("SDTEST4.WAV");
  delay(1500);
}

Do you have any idea of what's missing ?

Thank you all
Jean
 
Try adding "while (!Serial) ;" at the beginning of loop, so Teensy waits for the serial monitor open.

Focus on the easy problem first, just getting printing to work to the serial monitor.
 
Thank you Paul for taking care.

I can print the SD card file content, no problem.

I have added a few print status to the file, it prints the status, but I get no sound.

I checked my DAC on a Raspberry Pi => Music
I connected the DAC PSU to the Teensy while playing (with Teensy and Pi GND tied) => Music

I tried a Simpler sketch (PT8211Sine)
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioSynthWaveform       waveform1;      //xy=110,75
AudioOutputPT8211        pt8211_1;          //xy=303,78
AudioConnection          patchCord1(waveform1, 0, pt8211_1, 0);
AudioConnection          patchCord2(waveform1, 0, pt8211_1, 1);
// GUItool: end automatically generated code

void setup() {
  AudioMemory(15);
  waveform1.begin(WAVEFORM_SINE);
  waveform1.frequency(440);
  waveform1.amplitude(0.99);
}

void loop() {
}

No SOUND

My DAC is TDA1543A (Right Justified DAC like PT8211)
Hardware connection is
Hardware
Pin Signal Direction
9 BCK Output
22 DIN Output
23 FS Output
VUSB PSU 5V Output
GND GND Output

Any idea of what is wrong ?
Thank you
Jean
 
Hello all,
I spent a little time today to try to play music.

1/ Sine is working now, I swapped the TDA1543A that is supposed to be similar to PT8211 (Right Justified) to a TDA1543 (I2S) and mod the code from pt8211 to i2s : OK
2/ I tried again playing sd file and add some debugging print when I understood that the problem was the function AudioPlaySdWav that was the problem and understood what you wrote Manitou !

However, I have absolutely no clue on how to solve that issue!
I looked for AudioPlaySdWav::play() but couldn't find it :confused:
Sorry !
 
Last edited:
You need to find the teensy audio lib that was installed on your system as part of Teensyduino (hardware/teensy/avr/libraries/Audio/), and edit
play_sd_wav.h and change buffer to uint8_t buffer[512] __attribute__ ((aligned (4))); // buffer one block of data

in play_sd_wav.cpp comment out __disable_irq() before the wavfile = SD.open(filename)

https://forum.pjrc.com/threads/54711-Teensy-4-0-First-Beta-Test?p=207700&viewfull=1#post207700

EDIT: Paul's FIX 8/11/19 get latest from https://github.com/PaulStoffregen/SD
 
Last edited:
Status
Not open for further replies.
Back
Top