Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: I can't play Wav files

  1. #1
    Junior Member
    Join Date
    Jul 2019
    Posts
    7

    I can't play Wav files

    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

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    20,591
    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.

  3. #3
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,201
    There's a known problem with WavFilePlayer (AudioPlaySdWav) and BUILTIN_SDCARD since Teensyduino 1.46, see
    https://forum.pjrc.com/threads/56355...ignment-issues
    Last edited by manitou; 07-28-2019 at 04:48 PM.

  4. #4
    Junior Member
    Join Date
    Jul 2019
    Posts
    7
    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

  5. #5
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,201
    Quote Originally Posted by bricolodu13 View Post
    Any idea of what is wrong ?
    Thank you
    Jean
    see post #3, though if your sine wave isn't making sound, then you have other problems ...

  6. #6
    Junior Member
    Join Date
    Jul 2019
    Posts
    7
    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:lay() but couldn't find it
    Sorry !
    Last edited by bricolodu13; 07-30-2019 at 04:07 PM.

  7. #7
    Senior Member+ manitou's Avatar
    Join Date
    Jan 2013
    Posts
    2,201
    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...l=1#post207700

    EDIT: Paul's FIX 8/11/19 get latest from https://github.com/PaulStoffregen/SD
    Last edited by manitou; 08-11-2019 at 10:41 PM.

  8. #8
    Junior Member
    Join Date
    Jul 2019
    Posts
    7
    Hello Manitou, Now it is playing music thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •