Lola's Boombox


This is an 8-bit digital audio player. My 2 year old loved her CD player, pressing buttons turning the volume up but then not too long after purchase it decided to die a horrible factory manufactured style fatality. I spotted an opportunity to build something useful. And hey, if it breaks I can fix it right? I dusted of some old note books of research I've done for previous projects using Arduino and audio. Turns out it's not that easy to integrate audio at a reasonable cost. You could just buy an MP3 player or an MP3 shield and off you go but it is expensive and where is the learning in that. I wanted to build her a player which she can enjoy and also one which worked from an SD card so it's easy to update any tracks over time. I wasn't looking at audiophile quality which is why having experience with 8-bit microcontrollers seemed a good fit. 8-bit audio is often associated with a Tetris or Super Mario Bros. themed audio. But it doesn't have to be. One can get proper sounding audio from 8-bit samples as well. It's just not going to win any awards or sell massive quantities as the standard 16-bit is available everywhere.

Design process

It should be obvious that I am no product designer. The entire process was a massive learning curve and it sparked a new found interest in woodworking for me. My guess is woodworking because this is the material that was available to me, i.e. scraps lying around the house. I have a tremendous amount of respect for product designers as simple things took ages to figure out. In my case I had it easy, there was more than enough space to fit everything and my time was mostly spent on trying to figure out where to best mount my circuit board and why my spray job was looking so shoddy.

For the design I had an idea in my head of how I wanted this to look. I guess I must have seen it somewhere or it is a common look to have these slats in radios. It's not far off but as you can see in my sketch I wanted the speaker sides to have a 120 degree angle. Since I'm no product designer or have any experience with materials and tools to make something like this. I decided to settle for a square corner.

The build process

Digital audio has been on my radar for some time and I have a few future projects that will make use of digital audio. So I started with an Instructable I read about how to do this with an Arduino. Using the Instructable I mocked up a resistor ladder and played sine waves. The next step was to replace the sine waves with digital audio samples. Before we move on to this lets have a quick overview of digital audio.

What is digital audio?
Digital audio in essence are bytes of data arranged to be read in a specific way. These bytes are grouped together in what is known as a sample. Digital audio samples are described with size and frequency of samples carried. In other words, a 16-bit Stereo 44100hz digital audio track means that each sample is 16-bits in size and the frequency at which each sample must be carried is 44100 samples per second.

Arduino or something else?
If I wanted to use an Arduino to simply playback audio data the simplest approach would be to not play 16-bit audio. Since the Arduino is an 8-bit micro-controller (MCU), we simply want to match that and therefore our digital samples must be 8-bit in size. There is a way around this but it involves some advanced coding which I decided was not a good venture if I ever wanted to finish this. A tutorial by Bitluni on how to playback audio samples with Arduino helped tremendously as he simplifies it quite nicely. He also starts out with a simple 8-bit R2R (resistor ladder) as Amanda did in her Instructable.

Arduino with R-2R ladder
So now I am able to play back 8-bit audio from an Arduino using an R2R type DAC (Digital to Analog Converter). However there is a problem still. I can't play anything longer than 1 second as there simply isn't enough storage space. The Arduino has a limited amount of memory and program space, much smaller than your average computer or phone. Another disadvantage of the R2R DAC is the amount of pins it consumes on your micro-controller if this is a concern for you.

Arduino with SD lib
The next step was to expand on the length of audio data being played. So we need to bring in extra storage. Enter the micro SD breakout board. A neat little board that is not too expensive. I tried to alter Bitluni's last tutorial (CTC mode) to work with the SD card but didn't have good results. It worked but the audio wasn't clear enough for my liking. He also used an Arduino Mega which is the opposite what I wanted from the start. Initially my investigation in digital audio was to use the Attiny85 MCU. I use the Attiny85 frequently as it works well for low powered projects.

Arduino Custom Shield
What followed was working through the SD card library for Arduino and getting a custom shield with LM386 amp built. Now I have a working prototype reading from a micro SD Card. My excitement died quickly when I hooked everything up and played an 8-bit 22Khz audio track. The sound was quite noisy and gurgling. That is the best way I can describe it. It is as if something is singing why keeping some water at the back of their throat. And this was a big downer for me. After spending so much time it just wasn't working.

It is often necessary to step away from a project when you've been stuck in it for months. I had to do this due to work commitments. And this was the best thing ever. Cause when I picked at it again. I decided to try the AtTiny85 approach. This was code written by El Chan which uses the Timer/Counters on the ATtiny85 to produce a PWM signal of the digital audio samples. But he also uses a different SD Card library which after some further reading let me to believe that the gurgling sound I was having was due to the SD Card lib not reading fast enough.

El Chan Wav Player Code
I flashed the code using my Arduino ISP and it worked beautifully. I even got really clear sound just by using a transistor to amplify the output signal. I decided to stick with this.