chipKIT® Development Platform

Inspired by Arduino™

SimpleSDAudio Library port to chipKit

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


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]http://hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio[/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.

-Thomas


cobra18t

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>

to

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

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.


guymc

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.

Cheers


cobra18t

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

Success!

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.

-Thomas


cobra18t

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

I have a video of the preliminary version posted on my blog here: [url]http://cobrainnovations.blogspot.com/2012/10/basicsdaudio-chipkit-library.html[/url]

-Thomas


Jacob Christ

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

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

Jacob


rasmadrak

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

Awesome! :D

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


cobra18t

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.

-Thomas


rasmadrak

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!


cobra18t

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: http://github.com/cobra18t/BasicSDAudio

another demo at: http://cobrainnovations.blogspot.com/2013/03/basicsdaudio-alpha-release-and-demo.html

and info on the amplifier/filter at: http://cobrainnovations.blogspot.com/2013/02/babyboomer-audio-amplifier-and-filter.html

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.

Jacob


ricklon

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? http://cobrainnovations.blogspot.com/2013/02/babyboomer-audio-amplifier-and-filter.html

--Rick