Introduction: Retro Sound Chip With an Arduino - the SAA1099
In this instructable, I'll be showing you how to use an Arduino Uno with a vintage sound synthesis chip, to play midi files in square wavy goodness!
If you just want a quick overview of what this project does, watch the above video. Otherwise, continue on!
Step 1: Video
If you prefer all your instructions in clear, concise videos, we've got you covered!
For the rest of us, you can continue on, for a tad more detail, and written instructions.
Step 2: Parts and Materials
For this, you'll need these things:
(The links are for eBay items)
- An Arduino (Uno, Nano, Leonardo, they should all work)
- At least a medium sized breadboard
- The SAA1099 Stereo Sound Generator chip
- Breadboard jumper wires (Alternatively, I like using dupont female to female jumpers, with 20mm header pins inserted in either end- Much sturdier)
- 8Mhz TTL Oscillator (AliExpress link as provided by zweigelt)
- Stereo (or mono) Audio Jack
- 2 x 1K resistors (Lot of 100)
- 1 x 10K resistor (Lot of 50)
- 2 x 100pF Capacitors
- (Optional) Some LEDs, at least 1 (Any color, here's 100 assorted colors for a dollar!)
Using the links provided, the total cost is $23.25, including shipping. Of course, most of it comes from halfway across the world, so shipping usually takes about a month. If you want faster shipping, you'll probably have to pay a bit more.
Step 3: Wiring - SAA1099
If schematics are your thing, here you go! The rest of us can either go through the step by step, or watch the video.
- Place the SAA1099 at the end of the breadboard, with the notch on the chip facing the end.
- Now, power. VDD (pin 18) on the SAA1099 goes to power, then pin VSS (pin 9) to ground.
- Next, put a wire between CS (pin 2) and ground, to keep it pulled low
I would also recommend taking a look at the datasheet, which I've attached.
Step 4: Wiring - TTL Oscillator
- We'll put the TTL Oscillator on the breadboard next to the breadboard, so that the clock output pin is closest to the clock input on the SAA1099 (Pin 8)
- You can go ahead and connect power and ground to the TTL oscillator. (I waited till later in my video, so I don't have a picture). The above picture shows which pins are which.
Step 5: Wiring - Iref and Chip Interface
- Connect the 10K resistor between Iref (pin 6) and 5V.
- Connect digital pin 8 to WR (pin 1) on the SAA1099.
- Connect digital pin 9 to A0 (pin 3) on the SAA1099.
Step 6: Wiring - Sound Components
- Connect a 100pF capacitor between OUTR (pin 4) and GND
- Connect a 1K resistor between OUTR (pin 4) and 5V
- We'll do the same thing for OUTL (pin 5)
- Connect a 100pF capacitor between OUTL (pin 5) and GND
- Connect a 1K resistor between OUTL (pin 5) and 5V
Note! Make sure none of the wires from the resistors/capacitors are touching, otherwise stuff won't work, and could (tentatively) potentially blow up in your face.
Step 7: Wiring - Audio Jack
- Connect a small jumper wire between 5V and an empty row on the breadboard.
- Place your audio jack, so that the jumper from 5V connects to the "Sleeve" pin on the Audio Jack
- Connect the L and R (Or Audio pin, if you have a Mono jack) to the OUTL (pin 5) and OUTR (pin 4) pins on the SAA1099, respectively.
Note! On Mono audio jacks, it really doesn't matter what goes were, as long as one pin connects to 5V, and one to OUTL or OUTR. It'll sound just fine. Unless it doesn't, in which case you might want to check your wiring again.
Step 8: Wiring - Power to Breadboard
- Connect both sides of the Breadboard power buss to each other, using jumper wires.
- Connect one side to the 5V and GND pins on the Arduino, making sure you haven't mixed the wires up anywhere. If you did, the magic smoke may escape.
Step 9: Wiring - Data Lines
- Connect D0 through D7 on the Arduino to D0 (pin 10) through D7 (pin 17) on the SAA1099, in order.
I find that DuPont female-female jumper wires, with 15-20MM header pins in either end, work much better than the male-male dupont wires. Plus you can also use them as female-female, or male-female. Both are easily found on eBay in large quantities, for small amounts of change. A good Christmas gift for the aspiring Arduino junkie!
Step 10: Optional LED(s)
I won't go over step by step how to build everything here, but there are several good places to add LEDs. First of all, I connected a 3mm red LED between WR (pin 1)and GND, to show every time it the Arduino sends a command to the SAA1099.
I've also connected LEDs to the data lines before, which allows you to see the actual binary data on each line. I used this setup in my "Arduino and SAA1099 - Fireflies" video, as well as 6 more LEDs and some extra code to light up each LED for each channel that was active.
The more LEDs, the cooler it looks!
Step 11: Code!
Now that you've built the circuit, go double check connections! You don't want to blow up your expensive arduino and Soundchip! (If you do, well. That's not my business)
Assuming you're sane and have checked everything, we can start programming it.
- The library is at https://github.com/Bobcatmodder/SAATunes
- You'll want the SAATunes.zip file, so go ahead and download that.
- Now, open the Arduino IDE.
- Under "Sketch", "Include Library", click "Add .zip library"
- Navigate to wherever you downloaded the SAATunes library. (I don't care if it was your desktop, downloads, or (insert something embarrassing) folder- Just find it)
- Select it, and click "Open"
- It should tell you it's been added to your libraries.
Step 12: Test It!
- Open the example SAATunes program, under "File", "Examples", "SAATunes", "SAATunes-Uno".
- Plug your Arduino into the Computer, and into a speaker of some sort.
- Upload the program to the Arduino.
You should hear a Chord, then Beethoven's Rage over a lost Penny. If Classical isn't your thing, have no fear, for we will shortly learn how to use MIDI files of our own choice with it.
If you don't hear anything, check a few things: First, is your speaker on? Turn it all the way up. Then, is the arduino really on? Did the program upload correctly? Check all the wiring with the scematic and datasheet, then try again.
Step 13: Using Your Own MIDI Files - Conversion Program
Ready to try something other than Beethoven? Very well, here you go.
To convert MIDI files to C++ Bytestreams, we'll need a program by Len Shustek. He's the creator of the library I based my code off, and my library uses the same bytestream format his does.
- You can find the program at https://github.com/LenShustek/miditones
- The program you want is "miditones.exe". Go ahead and download that.
Step 14: Converting MIDI Files
Warning! Here there be ascii dragons! You might find it easier to watch the video, where you can see exactly what I'm talking about. If ye dare enter, then continue on!
To use the MIDI to Bytestream conversion program, you'll need to open a command prompt window. Sorry Mac and Linux users, you may have to find a workaround.
- Open the start menu, and type "CMD", then press enter.
- We're gonna learn a little MS-DOS magic now. Using the "CD" command, navigate to wherever you downloaded the "miditones.exe" file to. For most cases, the commands will be "cd downloads".
- Run the "miditones.exe" program by typing "miditones". It should show you a help list showing the most common commands.
Now, we need a MIDI file to convert. Find one somewhere on the interwebs, preferably without percussion or any special effects besides insturments/velocity. (If you don't know what those are, don't worry, you'll be fine)
- Download your MIDI file to the same place you have the "miditones" program.
- Now, using the command prompt window, type "miditones -d -v [filename]" (Replace [filename] with whatever the name of your MIDI file is).
- miditones will generate a .C file with the C++ bytestream in the same folder, with the same name as the MIDI file.
Step 15: Using Your Converted MIDI File
Now that you've converted your MIDI file, let's feed it in little bytes to the arduino!
- Assuming you already have the SAATunes-Uno example open, let's go ahead and "save as" something else, so we can edit it.
- Once you've saved it, click the little "down arrow" icon in the top right corner.
- Click "new tab", and name it "[name].h" (Replace [name] with the name of your MIDI song, or whatever you want)
- Now, open the .C file that miditones created earlier. You can use notepad to open it.
- Use CNTRL/A to select everything, and then copy it.
- Paste it into your new "[name].h" tab in the arduino editor.
Everything's good here, so let's get back to the program.
- Find where it says "#include "RagePenny.h"", and copy/paste it onto a new line below.
- Change the "RagePenny.h" to whatever you named your new file.
- Now, comment out the "#include "RagePenny.h"", by adding two forward slashes (//) in front of it.
- Upload the program!
If all went well, it should be playing your own MIDI file. If not, recheck to make sure the names of the new tab and the name you changed in the "#include "RagePenny.h"" are the same. Check the other steps, and make sure you did everything right. Some MIDI files just don't work, but those are rare.
Step 16: Fin!
Hopefully everything has gone well with you, and you're jamming out to MIDI files on an ancient piece of technology given new life!
However, if you aren't, don't give up! Send a comment my way, and I'll be happy to help. Of course, feel free to give me suggestions in the comments.
Participated in the
Remote Control Contest 2017
Participated in the
Arduino Contest 2017
Participated in the
LED Contest 2017
1 Person Made This Project!
- bananasareyellow made it!