Home › Forums › Sparkfun MP3 Shield Library Support Forum › Very slow starting mp3 files…
Tagged: refill slow start
- This topic has 3 replies, 2 voices, and was last updated 10 years, 2 months ago by Anonymous.
-
AuthorPosts
-
September 9, 2014 at 6:02 am #3218AnonymousInactive
I have been playing around the the SFEMP3Shield library.
I have a particular set of MP3’s (these are created by a friend) as part of an art project. They are taking incredibly long to start from the time I call playMP3 until the music actually starts streaming is is about 30 seconds.
I have tracked it down to a couple of things… First I think I found a bug in the playMP3 routine…
it does the following at line 1088 in SFEMP3Shield.cpp SFEMP3Shield::playMP3
playing_state = playback;
Mp3WriteRegister(SCI_DECODE_TIME, 0); // Reset the Decode and bit-rate from previous play back.
After this it calls the refill() routine,
I think the bug is that if you set playing_state = playback before you call MP2WriteRegister, it will then prematurely turn on the interrupt driven refill routine at the end of that call, before it returns and tries to run the inline refill, before enabling interrupts yet again. Thus you are running refill via interrupt and inline at the same time.
I have moved the
playing_state = playback;
line below the writeRegister call and it seems to be working well so far in my testing.
Now on to my other problem.
I have an MP3 file that takes 30 seconds to refill and start playing. I added some debug code to the refill routine to print how many bytes of data it was reading before the loop below was satisfied.
while (digitalRead(MP3_DREQ)) {…}
I have tested this with an MP3 version of the file (7.3M) and an AAC version (8.7M) of the same file, converted to AAC using iTunes…
The refill routine loads a total of 3904 bytes of data in the main fill loop from the MP3 before enabling the interrupt driven routine. We still have to wait another 30 ish seconds before music is emitted from the card.
The AAC file loads 3M of data before it completes the primary fill loop. This takes about 30 seconds and music is emitted almost immediately after exiting the refill loop.
So MP3 and AAC behave slightly differently in the fill loop, but both take a very long time to start producing music. The AAC may be slightly faster, but I have not timed it that precisely.
After it starts playing, they both play normally to completion.
I took the basic player and cut it down to make it easy to test this, plus added some new debug code to the MP3 library to track down the issue.
Here is a link to both the mp3 and aac files. And the cut down version of the MP3 player I was using to test with.
https://app.box.com/s/dpy8ob8l2ssnfa7n0e3x
I have gone about as far as I can go with this and I just can’t tell if there is something wrong with the music files or if there is something wrong with the library.
Also, I am using the sparkfun red board UNO R3 but I was able to reproduce the slow starting problem w/o all the debugging code a few days ago on a regular UNO R3 board.
Sorry for the long message, I have just been at this for a while and wanted to include most of what I already have found.
September 9, 2014 at 7:11 am #3220Michael P. FlagaMemberabout the later; is any of the beginning of the audio file skipped? (are the first expected notes heard?)
September 9, 2014 at 9:04 pm #3222AnonymousInactiveYes there should be music immediately. There is a nicely audible gong immediately and then some popping/bubbling type noises. It gets progressively dynamic sounding as the piece progresses.
When played with iTunes it starts playing immediately.
September 9, 2014 at 9:08 pm #3223AnonymousInactiveWell, maybe I was not answering your question exactly. The music that starts playing 30 seconds into the ‘wait time’ is the beginning of the piece. There does not seem to be any missed or skipped section of the song. It is all abstract so maybe I could be skipping something. The piece is exactly exactly 3 minutes of music when played. I will check to make sure that it does play 3 minutes of music from the start of the piece.
-
AuthorPosts
- You must be logged in to reply to this topic.