Audioflynt

Background

About once or twice a year, my friends and I stay in a small bach in the mountains. Obviously the peaceful nature of such an idyllic setting cannot be tolerated, which lead to the development of the "Rowdz Box". The inspiration for the Rowdz Box came from a Youtube video called "10 Things that aren't Skrillex", in which there is a device that plays an excerpt of a Skrillex song. It was quickly decided that we needed a version of this device for our holidays, so I set about building one.

The first iteration of the Rowdz Box consisted of a ATmega168 microcontroller pushing PCM audio data from a Flash storage chip into a Digital to Analog Converter (DAC) chip, the output of which was amplified using an amplifier module and fed into a tiny speaker. An 18650 battery was used as a power source, and a push button was used to control the audio playback. In reality the button was the power switch for the whole system, when it was pressed the microcontroller would power on and immediately start playing audio. Intensive testing by users revealed some fun side effects of this system. After rapidly powering the microcontroller on and off, sometimes the box would generate interesting prolonged audio glitches. A small Sistema snack box was used as a chassis, with a layer of duct tape added for good measure.

The first iteration of the device, with button, speaker, and duct tape visible

This combination proved very durable, which was important during moments when the Rowdz Box needed to survive physical expressions of emotion. A later iteration of this Rowdz Box included a latching power system using a MOSFET, and would remain powered up until the audio finished. There were many instances of this version being activated and thrown near those who were sleeping peacefully, such that they could be seranaded with "Waltzing Matilda".

New Hardware

Over the years, the Rowdz Box grew to be a staple of our mountain retreats, and it became obvious that an upgraded version was required. This led to the development of Audioflynt, a repurposible electronic and software system for audio playback. The electronics of the system mirror the previous iteration, however they are upgraded and placed onto a single printed circuit board rather than a ratsnest of modules. At the centre of the system is an ATxmega 16A4U, which packs a bit more punch than the ATmega168 of the previous design. The 16A4U has a Full Speed USB module, which is used for pushing data to the 128MBit of Flash storage on the Audioflynt board, and a 12-bit DAC which is used to produce the audio signal. The audio signal is amplified using a TI TPA3111D1PWP 10W Class-D amplifier, which is more than capable of making a racket. Other on-board facilities include a switch-mode power supply, and space for MOSFETs for controlling accessories on future projects.

For the most, part surface mount components were used, and the circuit was baked in a mini-oven that had been modified with the addition of a PID Controller. The cooking process went a bit far, resulting in a gentle toasting of the board and components. Everything worked however, so the baking was considered a success.

The Audioflynt printed circuit board, lightly toasted A toaster oven modified to lightly toast printed circuit boards

New Rowdz

Audioflynt was used to make the next-gen version of the Rowdz Box. The control system this time around would be more complex, with a toggling power switch and six buttons for controlling playback. The function of the buttons was entirely up to the software, some iterations supported the playback of 10 different audio files, using the bottom-right button as a modifier key to select the set of audio items that the other buttons would play. Another version supported a larger amount of audio files, using a keying mechanism to enter in a code to choose the audio. Subsequent key presses would play the audio at various pitches depending on the button pressed.

The new Rowdz Box was housed in a wooden enclosure, built from scratch with the aim of protecting the delicate and temperamental Lithium Polymer battery within. The enclosure was painted black, which along with the metallic buttons resulted in a fairly malicious appearance.

The chassis of the New Rowdz Box, featuring chrome buttons and a black paint finish

The TPA3111D1PWP amplifier chip proved to be very able at driving the speaker, so a key switch was added to the design to control one of its gain bits. While off, the volume of the Rowdz box was unoffensive yet assertive, and while on it was invasively loud. The key was kept in my possession most of the time, to prevent complete anarchy.

Software

The use of the ATxmega 16A4U microcontroller provided substantially more computation capability than the ATmega168 of the first design. This allowed the use of basic audio codecs such as MS-ADPCM, which is essentially a form of Delta Encoding with a bit of flair. With a few bytes for initialization, this variant of ADPCM encodes four 16bit samples into four 4bit nibbles. As can be seen in the decoding code, it is fairly computationally simple. Combined with the 128MBits of Flash storage, up to 50 minutes of audio could be stored for playback at a 22kHz sampling rate.

To increase the flexibility of content creation for the Rowdz Box, a basic implementation of the FAT16 filesystem was used. This allows the sounds for each button to be specified with a filename, rather than a byte offset to a position in the flash image as in the first design. To curate the content, a 128MBit file was formatted as FAT16 and mounted to a directory, offering the benefit of using standard tools to tell how much space was being used, and how much was left.

Data Loading

One particular pain point of the first Rowdz box design was the method of programming the flash chip. Each time the audio content was changed, the flash chip was removed from its socket and placed in a breadboard. Then the datasheet of the flash chip was researched (because taking pictures of the programming method the last time it was done would be have been too useful), and a janky programming setup put together using an Bus Pirate. Significant design effort was placed into Audioflynt to make this process easier.

There are two different sets of firmware for the Audioflynt board. The first is the player firmware, which takes care of the usual Rowdz Box audio playback. The second is a Serial Debug firmware, which exposes a debugging shell on a USB virtual serial interface. To program an image to the Audioflynt board, the serial debug firmware is programmed to the ATxmega microcontroller, and the USB interface is plugged into the development computer. The upload script then sends the necessary programming commands and data.

Ideally there would only be one firmware image incorporating both the player and data loading functions. Further, a USB Mass Storage interface to the filesystem on the Flash storage would have simplified both content creation and uploading. Unfortunately for both of these improvements, a size limit on the ATxmega firmware size was reached, and the dreaded "good enough" was achieved.

In Conclusion

Making elaborately annoying things to reduce the quality of life of your friends is very important.