Teensy3.1 Play SDcard WAVs play problems

Status
Not open for further replies.

Teenfor3

Well-known member
I have been having problems playing SD wav files. I know there is alot of discussion on this forum about using recomended SDcard and formatting etc and copying all the files on together so as to be contigious. I was getting a double "bump" at the start of some files. I recorded the sound from Teensy lineout using Audacity and found a glitch at approx 180 - 185 ms after the file started to play and this gave me the double "bump" at the start of some files. It wasn't happening with all of the files. I formatted the SD and copied the files back on and found the glitch moved to some other files and some of the others were OK now. I kept formatting a few times using SDformatter and eventually all play OK now regards having no glitch. As part of my investigating and looking at the recorded waveform in Audacity I noticed that when a file is starting to play (using for example wav.play("B.WAV")) the file seems to attempt to open and play the start of the file twice with the "tail" bit that was the last bit playing in between and sometimes there is a gap, sometimes no gap. I am playing the next files before waiting for the previous file to end. It doesn't seem to matter whether I use wav.stop or whether I use AudioNoInterupts or not. I always get a double start to the file. This happens so fast that it is not heard as a double "bump" like the 180 ms glitch was but gives an audible "click" between the sounds. Formatting etc doesn't seem to cure the problem??. I have attached my test sketch together with the audio files and recordings and some screen dumps. The other test files used were the SDTEST files from this forum Audio library. Hopefully maybe someone can give me some advice as to what is happening.....Thanks........
 

Attachments

  • SquareWithGlitch1.jpg
    SquareWithGlitch1.jpg
    106.8 KB · Views: 183
  • PlaySDtestGlitch.ino
    2 KB · Views: 132
  • ScreenDumpsAudacity TestWavs30Dec.jpg
    ScreenDumpsAudacity TestWavs30Dec.jpg
    46.2 KB · Views: 191
  • TestFile30thDecPlaySD200ms.zip
    1.5 MB · Views: 98
  • PlaySDtestGlitch.zip
    930.6 KB · Views: 113
Last edited:
Just to let you know I am using a Sandisk Ultra 16 GB SDcard plugged into the Audio Adaptor. The same as the one recommended on the Audio Adaptor web page.
 
OK, Thanks Paul

Just noticed....I am using the i2c_t3.h instead of wire.h because I wanted more touch pins and i2c on pins 29 & 30.......I don't think that has any bearing on the problem, it all "works" and no compiling errors.

I do have another teensy3.1 and SDcard adapter for the teensy but don't have another Audio Adapter to wire it up standard.
I can connect up the other teensy to the SDcard Adapter and compile it with wire.h if you think its a problem but maybe you have an easy way of proving it on your systems first............
 
I commented out the I2S output lines and anything else for the Audio adapter control and added the following....

// GUItool: begin automatically generated code
AudioPlaySdWav wav; //xy=217,210
AudioOutputAnalog dac1; //xy=489,248
AudioConnection patchCord2(wav, 0, dac1, 0);
// GUItool: end automatically generated code

This sends the output to the teensy dac port so it compiled and ran with wire.h.....OK.
The double start when playing SDcard files is still there........
So not problem due to changing i2c pins etc.......
 
This problem seems to have come back again.....I thought the 185 ms delayed glitch was sorted by formatting SD and copying files again. And the 2 attempt start to playing files seems to only be with playing stereo WAV files......so I started using mono. The play at the start is now OK with mono.....actually very good and initially no delayed glitch. But now a glitch at 370ms has started to happen. I have reformatted several times and still happens not with all files and not at all times..????
I attach a recording and JPG.
 

Attachments

  • Recording2sounds370msgap.zip
    392.3 KB · Views: 111
I have now found out a bit more due to more testing.....
Formatting didn't seem to do any good....no matter how many times.
So I just deleted all the files off the SDcard, didnt format and copies only 12 files back on.
And the 12 files worked OK, good play start, good waveform and no glitch at 370 ms.
Then copies 1 more file on...still all 13 OK no glitch
Then copied 1 more file on ....still all 14 OK no glitches.
Then copied 1 more files on....and the 15th file had glitch gap at 370 ms all the previous 14 still OK no glitch.
Then copied 1 more file on ....and the 15th and 16th files had a glitch gap at 370 ms all previous 14 still OK no glitch.
Then copied 5 more files on ...and these 5 and the 15th and 16th had glitch at 370 all the previous 14 still OK no glitch.
I didn't do any formatting, I just copied them on in sequence as described.

So is it anything to do with the length of the list of files on the SD, OR because if list longer more searching etc.
But before I thought it was random files affected, but that was because the files were in no sequence so appeared to me to be random.

Now that I have them on in sequence, It is always the 15th upwards that has glitch, but not all the time but most times.....
All of the files play clearly at the start......its just the glitch causes a "bump" in my continuous sounds, and the sound continues to play correctly after the bump.

Maybe this will help clarify the problem, and may someone can pinpoint what may be happening
 
Again, there's no "official" way to elimnate the gaps, if they are shorter than 3ms. But, can you hear the gap ??

For "Play from serial flash", i could add a function "loop" wich loops the sound without this gap until you stop it. Would that be of any help ? If yes, i can add this function.
Edit: or is a kind of "miniplaylist" (one entry) more useful ? It could "gapless" play the next file after the first is at the end, or stopped.
Need Stereo from flash ?
 
Last edited:
Frank,
The gaps are not the issue. If there are gaps then fair enough, I accept that. What I was finding and it is in the recordings I made, was that most of the time the next file started without a gap, so my query was why sometimes a gap?. And this is with SD WAV files. Your MP3 player is a different issue it has 60 ms gap, fair enough. At the moment for this thread I am not using serial flash. I just want to read from SDcard. And mono seems to work very well.

So as not to mix up all the problems together.....the issue with this thread was the double starts when playing a Stereo WAV from SD. We narrowed this down on another thread to Stereo files only. And I now play mono and that works and most of the time not even gaps between the files.
The other issue on this thread started 30/12/2014 was the issue I found of a gap or glitch at 185 ms after the file started to play even though the file may have started correctly. And after the glitch at 185 ms the file played normally. I thought I had resolved this a few weeks ago by formatting the SD and copying on the files but I had to do it several time before it cleared.......
The problem hasn't cleared....it is back again......I am now playing mono files and find this glitch or gap is happening at 370 ms. ......maybe because of some relation between mono and stereo......one channel or 2 channels. I also find that formatting and copying did not clear the problem.....but it seems to depend on the number of files on the SDcard. I detailed what cleared the problem in Post #7 above......Does anyone else find this problem....Please
 
Silly question.. could it be.contact problems?
With your card ? Can you try another one ? Or clean the contacts ?

This sounds like a mechanical or electrical problem.
The compiler and arduio do ever time the same, if there's no change in the software... they don't produce problems that come and go..if nothing changes..

Hm. Or, what happens if you delete some files from your card ?
Still problems?
Can you check if this really depends on the number of files ? Or is it more randomly ?
If it's not repoducable and every time the same, it tend to say that its not a software problem..
 
Last edited:
Another Question:

I was a bit surprised when you said starting mp3 needs 60ms.
I now measured it.
Its 12+0..2 ms for me (128 kbps) (96MHz).

Thats a huge difference. How does it come ?
 
Frank wrote "Silly question.. could it be.contact problems? "
I don't think so......It works continuously without error
Only problem is this glitch........and only when 15 or more files on SD

The SDcard I am using is Sandisk 16GB same as shown on the PJRC Audio Adaptor web pages....

Frank wrote "no change in the software... they don't produce problems that come and go..if nothing changes.."
The problem does not come and go......it is there always when there is 15 or more files on the SD. I can re-produce it every time
I thought it was random because I formatted and copied all files together to the SD so as not to be fragmented....So that meant the were actually saved to the SD in the order of my select all, copy and paste works which to me seemed random. I have now found I can copy 14 alltogether and they work OK every time. When I copy any more either single or in batches the ones I copy after the first 14 ALL have glitch at 370 for mono.WAV....And the first 14 still remain OK. If I put a different batch including one that gave glitch on as first 14 then these 14 will all be OK.
Frank wrote "Hm. Or, what happens if you delete some files from your card ?"..........As you will see in Post #7 above I have detailled what I have done. I have deleted some and copied some, it doesn't matter........the first 14 will be OK....any after that will have glitch at 370 ms for mono.WAVs.

Frank wrote "Can you check if this really depends on the number of files ? Or is it more randomly ?".....Yes have checked.......14 files are OK...any more not.

Frank wrote "If it's not repoducable and every time the same, it tend to say that its not a software problem.." .....Yes it is reproducable.....I get it to happen every time. It initially seemed to me to be random because I was copying more than 14 on as a batch......and didn't know what order the PC was actually copying them.

Regards the MP3 .....I will check again, but the time I am talking about is the time from one file stops sounding until the next file starts sounding with 2 successive play commands.... I think I posted some recordings on the other thread yesterday......I will update on it if I find anything
 
Re mp3: its not important.
but everything over , let's say 30 ms, with a bitrate around 128kbps is a bit strange. EDIT: It should stop within 3 ms
but it's not intended to start as fast as possible. it is not optimized for this kind of usage.

i give up. i don't have more ideas. maybe next weekend.

let's wait what paul says.
 
Last edited:
Dis some more detective work and testing. I had another Teensy and a PJRC SD Adaptor (not the Audio Adaptor).....so I hooked that together on a breadboard and connected SPI pins 7 MOSI, 12 MISO, 14 SCLK, 10 SDCS and analog out via teensy DAC Pin A14. All works fine using the same SDcard and files (21off) as I was previously using. No glitch at 370 ms, only tested mono files.

Put SDcard back in audio adaptor that was showing problem sent output to teensy DAC and all worked fine. Then sent output to I2S and could hear glitch again. I disconnected Pin 13 (LED and also RX for I2S to adaptor) didn't make any difference still heard glitch but no LED (dont really want LED anyway). What does RX do??. Is it only Receive for recording......Does it not do anything in controlling the high speed data on the I2s data port.??
But that maybe proves that teensy is reading SD card OK when outputting to its own DAC. I checked this before but don't know what I did different this time.
So there is still a problem sending to I2S and still seems to be related to the number of files on the SD. I have 21 files on, all play OK to Teensy DAC, but only first 14 play OK to I2S, the rest give a glitch at 370 ms. And if I mix them up and copy on again it is always the first 14 copies that works OK.
I haven't tested stereo again, yet, but it had the proble, of the double starts and the glitch at 180 ms.

Does anyone else has more that 20 files on a SD and playing WAVs without a glitch. Surely someone must have a project with more than 20 sound files. Can you please post if you have any system working.....
 
Last edited:
Status
Not open for further replies.
Back
Top