Wave file playback from internal SD card on Teensy 3.5

Status
Not open for further replies.

jeanmichelrey

New member
Hello,
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.

Code:
#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_CS_PIN BUILTIN_SDCARD
#define SDCARD_MOSI_PIN 11
#define SDCARD_SCK_PIN 13

void setup() {
[INDENT]  Serial.begin(9600);
  AudioMemory(8);

  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);

[COLOR="#FF0000"]//  if (!(SD.begin(SDCARD_CS_PIN))) {
//    while (1) {
//      Serial.println("Unable to access the SD card");
//      delay(500);
//    }
//  }[/COLOR]

  Serial.println("Playing...");
  playWav1.play("TEST.WAV");
  delay(5);
  
  while (playWav1.isPlaying()) {
  }
  
  Serial.println("Finish");[/INDENT]
}

void loop() {
}
 
Last edited by a moderator:
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 ...
 
** 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::
Code:
  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
 
Status
Not open for further replies.
Back
Top