Pages

Friday, October 26, 2012

BasicSDAudio ChipKit Library


I have been working on a few Arduino and Chipkit projects that could use some decent audio generation. Many people have used Adafruit's Wave Shield in the past, but I dislike the idea of having to bit-bang the second SPI port, it requires additional hardware, and there was no simple way to port the library over to ChipKit.

SimpleSDAudio minimal setup

Enter Lutz Lisseck's SimpleSDAudio library for Arduino. It uses a stripped down SD card library and hardware PWM to output 8 or 16 bit audio in mono or stereo. I tried it out on my Arduino Pro Mini and was pleased with the results. Since it is interrupt driven, you are free to do other things in your sketch during audio playback, so long as you call the "worker" routine--which updates the audio buffer--often enough.

The library code is pretty straightforward so it was easy to go in an change ATMEGA specific code for the Arduino to PIC32 specific code for the ChipKit. I have an preliminary version working, so check it out:


The audio in the video is 8 bit stereo, sampled at 78.125kHz. Without using any more pins, the ChipKit will be capable of 10bit output at this sample rate, and 11bit output at 39.062kHz. The Arduino is only capable of 8 bit stereo when using only two PWM pins.

For more information about the SimpleSDAudio library for Arduino, visit:
http://www.hackerspace-ffm.de/wiki/index.php?title=SimpleSDAudio


-Thomas