Retro Sound Chip With an Arduino - the SAA1099

6,346

17

12

Introduction: Retro Sound Chip With an Arduino - the SAA1099

About: I love creating value, and discovering new things! I take things apart to see how they work, spend too much time learning about irrelevant things, and love making cool stuff, like Robots, electronic projects i…

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)

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.

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.

Happy chiptunes!

Remote Control Contest 2017

Participated in the
Remote Control Contest 2017

Arduino Contest 2017

Participated in the
Arduino Contest 2017

LED Contest 2017

Participated in the
LED Contest 2017

1 Person Made This Project!

Recommendations

  • Retro Tech Challenge

    Retro Tech Challenge
  • Organization Contest

    Organization Contest
  • Tinkercad Student Design Contest

    Tinkercad Student Design Contest

12 Comments

0
dominikpoignee
dominikpoignee

Question 8 months ago

Shouldn't the sleeve of the audio socket be connected to ground? In step 7 it says jumper to 5V...unfortunately I can't get the circuit to do anything 😭

0
Jfieldcap
Jfieldcap

Answer 8 months ago

All a speaker needs to create sound is a voltage difference across it, it doesn't matter which end goes to power or ground (to the speaker). If I recall correctly the datasheet specifies that the audio should go to 5V. But I feel like I remember that it worked for me with both ground and 5V... I might be wrong though.

Send a picture of your circuit if you can--it's possible also that you have a defective chip, but most likely it's a wiring issue.

0
dominikpoignee
dominikpoignee

Reply 8 months ago

Thanks. A lot went on since my post 😂 first thing I did was to change the function writing to the output pins to write individually, not the Port register. Then it worked! Problem is that it just stopped working and I'm not sure what blew or if it's just my breadboard.

0
Jfieldcap
Jfieldcap

Reply 8 months ago

That's strange that it helped to use writing to the pins individually. The port register is much faster, but speed doesn't really matter for this...

There's not a lot I can do with how much I know about your circuit--you could use a multimeter to check continuity between each of the pins on the chip and the connections on the Arduino if you think it might be your breadboard. Other than that, just check every connection one by one again. However, the fact that it was working seems to indicate an intermittent connection or some instability with something--the Arduino, your speakers, some of the wires. It's hard to tell--but usually with some fiddling you'll figure out what it was.

0
rui.bernardino
rui.bernardino

8 months ago

Instead of using the TTL oscillator, replace setup() with the following and connect pin 11 to the SAA1099 clock input:

const int freqOutputPin = 11; // OC2A output pin for ATmega328 boards, others look it up.
const int prescale = 1;
const int ocr2aval = 3;
const float period = 5.0 * prescale * (ocr2aval+1) / (F_CPU/1.0e6);
const float freq = 8.0e6 / period;
void setup() {
// 8Mhz TTL out on pin 11

pinMode(freqOutputPin, OUTPUT);
TCCR2A = ((1 << WGM21) | (1 << COM2A0));
TCCR2B = (1 << CS20);
TIMSK2 = 0;
OCR2A = ocr2aval;
// end of code for 8Mhz TTL out on pin 11

//Initalize the WE and A0 pins, on digital pins 9, and 8. (Change to whatever)
st.init_pins(9, 8);
}

0
dominikpoignee
dominikpoignee

Reply 8 months ago

The internal clock worked for me until my chip died 😢 not sure why or what I did wrong yet...

0
rui.bernardino
rui.bernardino

Reply 8 months ago

Sorry to hear that :(
But I don't think it to be related to using the Arduino clock, this is common practice for clocking external chips, including the SAA1099 (https://forum.arduino.cc/index.php?topic=727692.0)...
Chances are you connected or touched the wrong wire at some point...

0
dominikpoignee
dominikpoignee

8 months ago

Anybody can help me with this? I can't get a single noise/sound out of my headphones, other than a crackling when the Arduino uploads a sketch.

0
jay_lewis
jay_lewis

2 years ago

Works really well - thanks :)

0
Jfieldcap
Jfieldcap

Reply 2 years ago

Glad to hear! :D

0
Jfieldcap
Jfieldcap

Reply 3 years ago

You're welcome! Tell me how it goes!

Those look great, I'll add them to the 'ible.

Best of luck!