Updated: May 9, 2022
As I've been making some good progress on my sound card for my 65816 system (see /audio), I thought it would be good to start building some sound effects. Looking for a way to rapidly experiment, I decided to leverage an Arduino Nano to control a programmable sound generator (PSG). This would allow me to easily control the old-school 8-bit PSG and hear true output, yet give me an easy way to control it (e.g., Nano, C++, user interface).This seemed easier than 65816 assembly code. The result is a small, simple circuit with the Nano managing the bus control signals of the PSG and feeding it data to modify its registers.
These registers control the three analog output channels on the PSG. The image to the right lists the 16 registers (note, the graphic uses octal).
Of course, the first step in all of this was to select which components I would use for a simple PSG test circuit. Then I would need to design the circuit and physically connect the small number of components. I figured a Nano would be plenty adequate to control the PSG. Since I'm using YM2149 PSGs in my sound card, I wanted to use it here. As the AY-3-8910 is very similar, it can be used in place of the YM2149. Below is a schematic of the simple circuit.
I am running the entire circuit off of the USB power fed to the Nano. To the right is a snapshot of power usage during playback.
With the hardware out of the way, I then put together a bit of code for the Nano. The code manages the RESET, BDIR, and BC1 signals of the PSG. It also supplies data for selecting a register and changing the value of the register. I expose the functionality through a simple terminal interface.
Then I layered a Winforms application on top.
The application allows me to change all registers of the PSG. In the following video, I play around with some of these settings. This is where I need to spend some time to experiment and hopefully build a small library of decent effects for my 65816 system to use.
What I have shown above is for controlling a single PSG. My sound card has six PSGs, so I'll have more flexibility in what I can play back. Below is where I am currently at with playback using twelve simultaneous channels (i.e., four PSGs). My goal is to use four PSGs for "music" and two PSGs for effects (all simultaneously, if I want). The playback in the below video is using the same concepts as those above; it's just switching a lot of registers quickly to play back the song (in all of its 8-bit glory, lol).
I think this is going to greatly speed up my creation of sound effects. More to come on that later...
I've been finding the single-PSG controller above to be quite handy already. So, I built out an XL version (six PSGs). I used one of my sound card PCBs to save me a bunch of wiring.