This is a simple .wav player that I wrote. It reads wave files from the SDCard and plays them back over the AnalogOut. Core components are a Ticker and an AnalogOut, although it also uses LEDs and a DigitalOut. It is attached to this page as a .zip file that you should be able to import directly into the mbed compile environment (right click "My Programs" and select Import Program...

You can't play back over the USB LocalFileSystem, it doesn't have sufficient throughput. The SDFileSystem.cpp included in this bundle is already hotrodded as described in my SDBenchmark article. Without the hotrodding SD also doesn't have throughput to play .wav files. At 10 MHz there should be plenty of bandwidth to play back 44.1 KHz, but they're distorted. The fastest I've tried successfully is 16 KHz, there may be other bottlenecks besides the filesystem.

Also, it currently only plays 16 bit wave files. There is a case statement where support for 8 and 32 bit files could be added with appropriate entries, but they aren't there currently. Also the program attempts to average together all of the tracks it finds in the file but that part is also not right and I haven't bothered to try to fix it yet. Maybe those'll get fixed after GEC.

I have also attached the two wave files the program expects to be able to run. Copy them to SD and have at it.

--steve

Attachments