I really love the Teensy series of Arduino compatibles – they’re essentially Arduinos but with all the right choices!
There are two main types of Teensy, the 2 series and the 3 series. The 2 series are 8bit Atmel AVR – very much like regular Arduinos but with native USB and much better library implementation. The 3 series are Freescale 32bit ARM CPUs – this is the series I particularly enjoy. I decided to buy two Teensy++ 2.o and two Teensy 3.2 along with a few audio adapter add-ons for the Teensy 3.2.
What project to begin with?
What better way to test the audio adapter then to emulate the SN76489, a.k.a. Sega Master System PSG / Genesis PSG.
The SN76489 programmable sound generator consists of 4 channels: 3 square wave generators and 1 noise generator. A very detailed explanation of the PSG’s inner workings can be found here.
I set out to write a Teensy 3.2 library which can read VGM files and 0utput the corresponding emulated audio out to the Teensy 3.2 audio adapter.
VGM files found online are usually compressed. You can easily check with a standard HEX editor to see if the first 3 characters of VGM file are ‘VGM’. If so, your file is not compressed. If you see something else, you’ll need to uncompress your VGM file first.
Linux users can do the following to extract the archive and generate a C compatible header with the data:
7za -e %vgmfile% xxd --include %extractedvgmfile% &> %file%
Windows users can ask Google :p
Teensy Audio Library
Luckily, Paul at PJRC (creator of the Teensy) provides very excellent software support to create custom audio objects. In fact, it was pretty much as simple as declaring a class which inherits from Paul’s Audiostream and implementing an update() function to provide 128 audio samples of data to the Teensy – everything else is handled by the provided Audio Library!
I’ve thus far managed to make my product play an included .h file of VGM data. I’d like to take it a bit further and have my SN76489 library be able to read uncompressed VGM files from an SD card and play them at will. Finally, it would be great to add YM2413 support.
Here is a link to the Github repository containing this project: