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

Thread: Wave file playback from internal SD card on Teensy 3.5

  1. #1

    Wave file playback from internal SD card on Teensy 3.5

    I am on a project which needs to read a wav file from the internal SD reader of a Teensy 3.5, without the audio shield, directly on the DAC of the card, connected to a small amplifier PAM8403.
    Everything works fine if I use a waveform for example or any synth module.
    However, I cannot read a wav file from the sd card.
    I managed to read and write a text file, so I have no hardware problem.
    In the code, if I uncomment the part which tests if the card is ready (if(!(SD.begin(SDCARD_CS_PIN))...) , I have the error "BUILTIN_SDCARD was not declared in this scope".
    And of course, if I leave it in a comment, the code runs but the test file is not played.
    Any help would be welcome.
    Thanks in advance.

    #include <Audio.h>
    #include <Wire.h>
    #include <SPI.h>
    #include <SD.h>
    #include <SerialFlash.h>
    AudioPlaySdWav playWav1;
    AudioOutputAnalogStereo  dacs1;
    AudioConnection patchCord1(playWav1, 0, dacs1, 0);
    AudioConnection patchCord2(playWav1, 1, dacs1, 1);
    #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))) { // while (1) { // Serial.println("Unable to access the SD card"); // delay(500); // } // } Serial.println("Playing...");"TEST.WAV"); delay(5); while (playWav1.isPlaying()) { } Serial.println("Finish");
    } void loop() { }
    Last edited by defragster; 03-22-2020 at 10:57 AM. Reason: add # CODE tag

  2. #2
    I finally forced the use of the SD library located in "hardware \ teensy \ avr \ libraries \ SD" (I deleted the one located in "Arduino \ libraries")
    I no longer have an error but unfortunately the wav file is still not playing ...

  3. #3
    Ok, that was definitely a library problem. I re-download the SD library from GitHub and finally everything works as I want.

  4. #4
    Senior Member+ defragster's Avatar
    Join Date
    Feb 2015
    ** cross posted while I played ... indeed the Teensy SD.h should work without error or having to delete any Arduino library

    I just altered and tested with Audio card and it won't play until this works :: if (!(SD.begin(SDCARD_CS_PIN))) {

    And with :: #define SDCARD_CS_PIN BUILTIN_SDCARD
    these lines are not needed as BUILTIN uses other dedicated SDIO pins::

  5. #5
    Thanks defragster, I modified my code as you suggest...
    Every thing works fine now, I can continue my project...

Posting Permissions

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