problem - Playing SD files

Status
Not open for further replies.

kkokddu

New member
Hello, I am just beginning Teensy 4.0+audio shield for 4.0.

I am trying to play audio files in my SD card, but

when I write "SDTEST1.WAV" ~ "SDTEST4.WAV" which I downloaded, all the files are played back without any problem.

but, other files are not played. Teensy cannot read other files, which I dragged in as '44.1khz/16bit' wave file format.

How can I fix this problem? Probably, naming the files? I just named my tune as 'ELECSWING.WAV'.

Any advice would be appreciated.

P.S mp3 or other sampling rated files can't be read by teeny 4.0?

The source code is as below:
Code:
// Advanced Microcontroller-based Audio Workshop
//
// [URL]http://www.pjrc.com/store/audio_tutorial_kit.html[/URL]
// [URL]https://hackaday.io/project/8292-microcontroller-audio-workshop-had-supercon-2015[/URL]
// 
// Part 1-3: First "Hello World" program, play a music file
//
// WAV files for this and other Tutorials are here:
// [URL]http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html[/URL]

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

AudioPlaySdWav           playSdWav1;
AudioOutputI2S           i2s1;
AudioConnection          patchCord1(playSdWav1, 0, i2s1, 0);
AudioConnection          patchCord2(playSdWav1, 1, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;

// Use these with the Teensy Audio Shield
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  11
#define SDCARD_SCK_PIN   13

// Use these with the Teensy 3.5 & 3.6 SD card
//#define SDCARD_CS_PIN    BUILTIN_SDCARD
//#define SDCARD_MOSI_PIN  11  // not actually used
//#define SDCARD_SCK_PIN   13  // not actually used

// Use these for the SD+Wiz820 or other adaptors
//#define SDCARD_CS_PIN    4
//#define SDCARD_MOSI_PIN  11
//#define SDCARD_SCK_PIN   13


void setup() {
  Serial.begin(9600);
  AudioMemory(8);
  sgtl5000_1.enable();
  sgtl5000_1.volume(0.25);
  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);
    }
  }
  delay(1000);
}

void loop() {
  if (playSdWav1.isPlaying() == false) {
    Serial.println("Start playing");
    playSdWav1.play("ELECSWING.WAV");
    delay(10); // wait for library to parse WAV info
  }
  // do nothing while playing...
}
 
Last edited by a moderator:
Unless you're using 1.53 or earlier, the Arduino SD library only supports 8.3 filenames. So "ELECSWING.WAV" is 1 char too long!

Either rename the file, or use 1.54-beta, where long filenames work.
 
Unless you're using 1.53 or earlier, the Arduino SD library only supports 8.3 filenames. So "ELECSWING.WAV" is 1 char too long!

Either rename the file, or use 1.54-beta, where long filenames work.

Thanks for your reply. 8.3 filenames -> what does this mean?
 
Status
Not open for further replies.
Back
Top