Music Module stutter

Hello everyone. I am currently messing with my new cobra II board and the music module. I am trying to find ways to optimize the code so that when the screen updates it doesnt cause the audio to stutter.

When the screen updates the audio slightly stutters, I am using the CP7 and might look at changing the code so that a refresh only a small portion of the screen but I was wondering if anyone knows of any other bottlenecks that I can look into :o)

I have the audio stream running in a different thread and reading 50kb of data from the file at a time to reduce file access reads

Any other suggestions?



Reduce sample rate.
Don’t do any other work while it plays.

I would suggest a caching scheme.

Have a thread that reads blocks of music into memory and adds them to a cache object which you build. The reading thread monitors the number of blocks in the cache, and when it gets below a threshold it fills the cache.

Register for the musicFinished event.

Start the music playing with a block from the cache.

In the musicFinished event handler, grab a block from the cache and play it.
Signal the reading thread that you have taken a block.

You have to play with the block size and number of blocks to get the best performance.

Go to Codeshare section of forum and seach for “streaming music”.

I have actually written one that used to cache in one thread and play in another, maybe I need to return to that one and try it again. Do you recon creating my own mp3 player module using a different chip will work or do you think its a limitation of the processor. Its a shame you cant cache more to the chip, would eliminate the need for a constant flawless stream.

I want to create a product that allows your to change settings etc while the music is running, I hope to create a radio module that allows FM/am receiving including RDS which means I need to update the display as the audio plays and it gets new track information :o)

Will keep you all upto date on how I get on :o)


If you decide to go with another mp3 player solution, I’ve used this device in the past.

It handles reading the mp3 files from storage. All you do is give the start/stop etc. commands over a uart or spi port. And it’s about the same price as the gageteer music module.

ooo looks very good. I was hoping to develop a second solution that would allow online updates, this wouldnt allow me to upload files to the usb but still possibly a good idea for the car stereo :o)



I’ve built an FM reception module, with RDS/RDBS. Done some of the programming but not all of it. Having some problems making enough time to get the module up and running… :slight_smile:

But my module outputs analog audio…

1 Like

Yeah I am having the same problem. Need the time to sit down and work out how to do a module for the non gadgeteer ports on the Cobra II. Done gadgeteer socket modules before but couldnt work out how to setup the SPI correctly via pins. Sure I will work it out and then I should be ok.

You wouldnt happen to be using this chip/breakout would you?

Once I have done this I need to wire it up so that I can switch audio outputs to my amp, got a free sample chip coming that will hopfully do it on a simple pin select…its all a learning curve though lol.


Same family, but I made my own board with the SI4703-C19-GM chip. I didn’t want to have issues with AM/SW/LW reception and antennas… :slight_smile: