teensy 3.1 and audio shield strange wav player problem

Status
Not open for further replies.

A. Williams

Well-known member
Sorry, I tried my best not to resort to bringing this up here, but there just seems to be no solution to this problem that I can find at the moment.

I'm running a teensy 3.1 locked into the audio shield. I'm trying to play wav files off a sandisk ultra 8gb microsd card using the wavplayer example in the audio library. When I try to play the example wavs that I've downloaded onto the card directly from the audio library page, they play fine. However, if i try to play any other wav file I put onto the sd card none of those other wavs play at all. All of the wav files (the example ones that work as well as my wavs that don't) are 16 bit pcm 44.1 khz. I've even gone as far as opening up (in audacity) SDTEST1.WAV and exporting it as itself back onto the sd card. Same bitrate, same memory size, but it won't play.
does anyone have any suggestions?
 
Btw, i ran the example program SDCARDTEST and it returned no errors in my card :p

what do your filenames look like? they should be in 8.3 format

edit: so are you saying after re-exporting SDTEST1.WAV in audacity then it also won't play?
 
Last edited:
it was exported as SDTEST1.wav (lowercase wav) could the lowercase "wav" be the problem?

I have no spaces in my filesnames
 
From only what's written here, I can not tell what's wrong.

It might be a problem with the way the files are stored on the card. Or it might be something different about these files, which the WAV player code doesn't understand.
 
esdeehelp.JPG

This is the only modification I did to the wav player example file. Upon boot up, it plays SDTEST2.WAV instead of the first file (which is attached in the message previous)
 
I'm playing it here on a Teensy 3.1 and audio board. It works fine.

I did have to rename the file to ESD.WAV. The original name, "ESDEETEST1.wav" has 10 characters in the base part of the name, which is too many. Perhaps that's why it's not working for you?

Here's the exact code I used for testing. I used Teensyduino 1.21-test2.

Code:
// Simple WAV file player example
//
// Requires the audio shield:
//   http://www.pjrc.com/store/teensy3_audio.html
//
// Data files to put on your SD card can be downloaded here:
//   http://www.pjrc.com/teensy/td_libs_AudioDataFiles.html
//
// This example code is in the public domain.

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

// GUItool: begin automatically generated code
AudioPlaySdWav           playWav1;       //xy=154,78
AudioOutputI2S           i2s1;           //xy=334,89
AudioConnection          patchCord1(playWav1, 0, i2s1, 0);
AudioConnection          patchCord2(playWav1, 1, i2s1, 1);
AudioControlSGTL5000     sgtl5000_1;     //xy=240,153
// GUItool: end automatically generated code

void setup() {
  Serial.begin(9600);

  // Audio connections require memory to work.  For more
  // detailed information, see the MemoryAndCpuUsage example
  AudioMemory(5);

  sgtl5000_1.enable();
  sgtl5000_1.volume(0.5);

  SPI.setMOSI(7);
  SPI.setSCK(14);
  if (!(SD.begin(10))) {
    // stop here, but print a message repetitively
    while (1) {
      Serial.println("Unable to access the SD card");
      delay(500);
    }
  }
}

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()) {
    // uncomment these lines if you audio shield
    // has the optional volume pot soldered
    //float vol = analogRead(15);
    //vol = vol / 1024;
    // sgtl5000_1.volume(vol);
  }
}


void loop() {
  playFile("ESD.WAV");
  delay(500);
  //playFile("SDTEST2.WAV");
  delay(500);
  //playFile("SDTEST3.WAV");
  //delay(500);
  //playFile("SDTEST4.WAV");
  //delay(1500);
}
 
I downloaded your problem file, It plays OK for me, but.....
I have a problem as per an earlier forum link.....regarding the files making 2 starts to play file...link below...

https://forum.pjrc.com/threads/27408-Teensy3-1-Play-SDcard-WAVs-play-problems

I deleted the long silence at the start of your file and exported it again in Audacity and recorded the Teensy playback output and Zoomed in in Audacity and I can see that the file makes 2 attempts to start playing. I was wondering are you getting that happening......Thanks
 
thanks, Paul! shortening the filename did the trick!
To be honest i had no idea such a restriction was in effect
 
@Teenfor3 no i am not, though I had to switch the sample rate in audacity from 32bit to 16bit to get the file to work, for some reason 32 was the default.
 
Hi...A.Williams.....Yes my audio file is 16 bit OK and plays OK except for this distortion of the waveform as the file starts to play. It happens with all my audio wavs as per my previous thread. I attach a screen dump of my recording and also what your original file start looks like. I would be grateful if you could comfirm you are not getting the same and post your waveforms, please, just to see if we are talking about the same thing. Paul had said in my earlier thread he would investigate but haven't got any outcomes yet. I would be curious to see if others are getting it......maybe doesn't matter much to others if playing a silence at the start of the file, it is not heard........
 

Attachments

  • ESDtestPlayback.jpg
    ESDtestPlayback.jpg
    47 KB · Views: 161
probably not very helpful, but here's a recording i made (for a different purpose), comparing playing a wav file from SD (bottom) vs the SPI flash (topmost) (the ones in between are something else). i specifically cut away anything silence at the beginning of the wav (16 bit stereo, 44k1), because i was interested in the latency.

the resolution is about the same as in your pics, i believe (the distance from the red bar to onset of the bottom waveform is 1ms), but i don't think i can spot anything resembling a re-triggering of the waveform, nor have i noticed anything like that before.

16154121292_055883df1c_o.png
 
There are now about 3 threds running on problems relating to playing SDwavs. This thread was started by yourself.....regarding a filename problem....have you sorted put your problem now....is everything playing OK now.?????.

I only posted earlier on this thread because I was investigating a problem regarding stereo wav files opening twice at start bu otherwise play OK...Do you have that problem??

this was norrowed down to only happening with mono files. There is also an issue I have when more than 14 files on SD the 15th or later all play with a delayed glitch at 370 ms after start for mono files.......Do you have that problem.???

I have narrowed this down to only happening on the output from the Audio adaptor when output is sent to i2s1. If I send output to the teensy's own DAC output pin play is OK.

I am still investigatig why but would be grateful if some other user could simply copy 15 or more wav files on an SD and see if they get glitch at either 185 ms for stereo or 370 for mono from the Audio Adaptor Lineout or headphone sockets. I have 2 teensy's and tested both, both are fine to their own DAC. I have only one Audio adaptor and so cannot get second test at the moment
 
Status
Not open for further replies.
Back
Top