Stereo Audio on a PIC32

The PIC microcontrollers are powerful little devices, and [Tahmid] is certainly pushing the envelope of what these integrated circuits can do. He has built (for educational purposes, he notes) an audio player based on a PIC32 and a microSD card. Oh, and this microcontroller-based audio player can play in stereo, too.

The core of the project is a PIC32MX250F128B microcontroller. 16-bit 44.1kHz WAV files are stored on the microSD card and playback is an impressive 12-bit stereo audio. It can also play back 8-bit files (with some difficulty). [Tahmid] programmed the interface to work through the serial port and it is very minimalistic, mostly because this was a project for him to explore audio on a microcontroller and wasn’t to build an actual stand-alone audio player that he would use from day to day.

Still, even though the project isn’t ready to replace your iPod, the core audio-processing parts are already done if you want to try to build on [Tahmid]’s extensive work. You could even build a standalone audio player like this but have it play high-quality 12-bit stereo audio!

13 thoughts on “Stereo Audio on a PIC32

  1. Hey man, awesome job.This thing is really neat, and you have the documentation to boot. You did what youset out do, for sure! Congrats.

    Do you think the uC has enough power to decode encoded files? (I wouldn’t know the first thing about MP3 decoding on a uC) Is the SD card data rate the bottleneck for 16/24 bit playback (wav files are massive!)? You have any idea how much power consumption you have going on there?

    Impressive!

    1. I dont think mp3 decoding on a PIC32 would be possible in real-time because it involves some pretty heavy math and lot of memory. Even if you use fixed-point calculations, it would still need lot of multiplications for doing the IDCT (which is a variant of FFT). Memory is the other bottleneck. Just the header and huffman tables on an mp3 would be 10’s of kB. Its better done on a DSP than a general purpose processor.

    2. As a sanity-check, processor-power-wise… I tried to turn my 486 into a dedicated MP3-player, back in the day… it could handle low bitrates, but 128k was *just barely* too much for it. We’re talking 32bit, DOS, 66MHz. Besides the FPU, spec-wise a (MIPS-based) PIC32 might not be too far off, especially being RISC vs. CISC… a highly-optimized and *dedicated* system, maybe a newer/more-optimized encoding-scheme… especially if there exists one that doesn’t require floating-point… (I dunno my encodings, maybe OGG?). It’s *plausible*. Dunno about the RAM necessities, though. Spose this isn’t *that* much new-information over Vikas’s comment, just a different way of looking at it.

  2. If you would like to improve upon the 12 Bit/sample thing without buying a new DAC, you can! Simply interpolate the signal properly to a higher sampling rate and do a proper word length reduction via dither + noise shaping. The noise shaping algorithm is magical in that it can push most of the noise into frequency regions we don’t care about: ultrasonics.

    I already implemented interpolation + noise shaping for a similar project: https://code.google.com/p/audio-pwm/
    With this code you can make your audio thingy have a dynamic range in the audible band that is equivalent to 16 Bits/sample at 44 kHz! :-)

    1. And you haven’t heard captured binaural, either. Granted you may not like the typical tri-phonic crap that still dominates what comes out of studios. Look up the newer Dolby mode meant to solve this problem, and make headphone sound less multi-mono.
      Is the point of this post to play good audio with low overhead? Wave files may be “massive” so is the capacity of a flash chip now. It would be nice to use flac but again that overhead cost. Is the cost of rendering wave’s high as well, or is this just a case of Mp3 bias?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s