[Oryx] grew up with the bleeps and bloops of an Atari ST, so it comes as no surprise he would want to relish in his nostalgia by playing with the YM2149 sound generator he recently picked up on eBay. Like most of us, [Oryx] went to his old standby, the Arduino, when it came to connect this bare chip to his computer. The first circuit didn’t work, so after a lot of poking around the firmware, [Oryx] discovered the benefits of hand-optimizing software.
There are a lot of sound files available for the YM2149 floating around on the Internet. These files are just dumps of the 16 registers at 50Hz, so it’s very easy to send these from a computer to an Arduino over a serial connection. Unfortunately, when [Oryx] got his breadboard set up nothing happened. After breaking out the ‘scope, he discovered the Arduino was switching pins 100 times slower than the YM2149 data sheet called for.
[Oryx] remembered seeing a great blog post going over the speed at which the digitalWrite() function changes pin states. We’ve seen this before, and the fastest way to change pin states on the Arduino is with the ugly bitwise manipulation. After changing a few lines of code, [Oryx] was switching two pins nearly simultaneously.
Now that the YM2149 chip is working correctly, [Oryx] is planning to make a MIDI synth out of his project. You can get an idea of how that will sound with the demo video he put up after the break.