chipKIT® Development Platform

Inspired by Arduino™

SimpleSDAudio Library port to chipKit

Created Fri, 19 Oct 2012 16:20:03 +0000 by cobra18t


Fri, 19 Oct 2012 16:20:03 +0000

I just thought I would let any interested parties know that I am porting over Lutz Lisseck's SimpleSDAudio library over to include support for chipKit.

SimpleSDAudio uses a stripped down SD FAT library and PWM sampled at 62500Hz to read in raw audio and play it using minimal harware. See Lutz' project page for more information at [url][/url].

From my initial tests on an Arduino Pro Mini, the quality is quite good even without any sort of filtering and still powering off USB. I expect quality to improve when using battery power and a filtered amplifier in my intended application. Even without these hardware improvements, it should still be a high quality sound effects generator.



Fri, 19 Oct 2012 16:24:53 +0000

Well, I am starting to port the code over to the chipkit Uno32. First I had to port the library back to Arduino 0023, since that is what MPIDE is based on. This was mostly just changing

#include <Arduino.h>


#if ARDUINO < 100
#include <WProgram.h>
#include <Arduino.h>

as well as converting the examples from .ino back to .pde files. After this massaging, I got it to compile in 0023.

The code is not pretty at the moment since I am using a lot of "#if defined (PIC32MX)" to switch between AVR and PIC specific code. I have the SD card library working on the Uno32, so now I need to port over the PWM.

I am running the SD card at 400kHz during initialization and then at 20MHz for everything after that. It uses the DSPI library for the low-level communication. It is looking like the PWM will be sampled at 78125Hz for full rate and 39062.5Hz for half rate. These values were chosen to give perfect 8bit resolution on the PWM and still be close to the original 62500 and 31250Hz values.


Fri, 19 Oct 2012 17:42:10 +0000

Sounds great, cobra18t. As soon as you get it working, we can add it to the wiki library page.



Mon, 22 Oct 2012 16:22:31 +0000


Well, partial success. I have the library working with full rate mono output and it is sounding pretty good. It still needs to be tested with half rate and a couple more changes need to be made for stereo.

There is a slight hiss/buzz when using the minimal hardware setup (DC blocking capacitor and speaker) which I will try to put a spectrum analyzer on to see where it is coming from. This buzz is a documented issue with the original Arduino library. Possible sources are 60Hz line noise, SD card data transfer bursts, or PC noise over USB power.

Even after I get everything working, there will have to be a significant code cleanup effort to make it a bit more readable.



Fri, 26 Oct 2012 23:04:49 +0000

I have a video of the preliminary version posted on my blog here: [url][/url]


Jacob Christ

Sat, 27 Oct 2012 18:35:45 +0000

Awesome!!! I am so stoked to see this working.



Thu, 01 Nov 2012 21:52:03 +0000

Awesome! :D

Would it be possible to do realtime mixing of multiple files?


Thu, 01 Nov 2012 23:38:11 +0000

@rasmadrak: I would say that it might be possible to play multiple files at once, but the current library really is not set up for that.

I would imagine that you would have separate buffers for each input, and the worker routine would try and fill whichever one is lowest on data. I do not believe the stripped down SD card library I am using supports multiple open files. So it would depend how fast the library can open and close files as it flip-flops between the two(or more).

The actual mixing of two inputs should be a simple average of the two. Sample rate may have to be sacrificed to support higher data rates of multiple inputs.

I guess all that to say multiple file mixing is not in the scope of my current effort.



Fri, 02 Nov 2012 15:58:13 +0000

Thanks for your feedback!

I'm using raw sectors so in theory it should be able to jump between any number of files. Too bad I've already cashed up and bought three Mp3 Triggers... :/

Still - awesome work thou!


Tue, 26 Mar 2013 06:31:03 +0000

I have an alpha release of the BasicSDAudio library available on GitHub. I am also working on an amplifier board.

Check out the release at:

another demo at:

and info on the amplifier/filter at:

Please inform me of bugs and improvements.

Jacob Christ

Tue, 26 Mar 2013 21:21:47 +0000

Looking at the code it looks like it has been ported such that this lib will work on both an Aruduino as well as a chipKIT board. Is this correct?

Once again great work. I can't wait to try it on my Fubarino SD.



Mon, 06 May 2013 19:38:19 +0000

Just saw this. I really want to try it on the FubarinoSD board. Anyway to get a hold of your Amplifier board?