Retro Sound Chip With an Arduino - the SAA1099

8,618

18

15

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

LED Contest 2017

Participated in the
LED Contest 2017

Arduino Contest 2017

Participated in the
Arduino Contest 2017

1 Person Made This Project!

Recommendations

  • Make It Bridge

    Make It Bridge
  • Game Design: Student Design Challenge

    Game Design: Student Design Challenge
  • Big and Small Contest

    Big and Small Contest

15 Comments

0
EnthusiastGuy
EnthusiastGuy

2 months ago

Very nice work! I was really excited and happy to find this. I plan on using the SAA1099P chip this with my Continuum 93 emulator that I've developed https://enthusiastguy.itch.io/continuum93 and that misses the sound on it. Your project, with a bit of adaptation, would really make that shine.

Here's also a photo of my attempt at a 4 channel dual-chip "sound card". I am really a noob at electronics so this took 3 hours to build, but I got it working and I plan to port it in hopes to use it with the D1 Mini Pro from Wemos. Plan is to set it up as a wifi or bluetooth connected sound board that I can send instructions to.

Got a bit of a challenge, since C++ and the whole Arduino API is rather obscure to me. Wil attempt to replace PORTD, SIGNAL, OCR0A and all that other stuff to make it work on this D1 mini, otherwise, I think I may target some ESP32 directly. A bit more expensive, but hey, they also have a bit more memory.

Before I saddle up to this, what's your advice? Should I try for the D1 Mini Pro or go straight for some small factor ESP32, such as S2 Mini? I'll also do the exploratory work myself, but since you've got the experience on it, thought it's a good idea to ask. :)

Cheers!

IMG20230101040158.jpgDiagram.png
1
Jfieldcap
Jfieldcap

Reply 2 months ago

Glad it was helpful! That perfboard circuit is way nicer than any I've managed to build!

I'd just go with whatever you plan to use in the end product probably. If you're using the Arduino API for it, then you can adapt my code, although I'm not sure if your implementation for sound will be able to use much of my code - what my code does is essentially takes a reformatted MIDI file and uses that to control the SAA1099. But regardless, it should be a good starting point for figuring out how to control the SAA1099 with a stream of "this note on, this note off, at this volume" style commands.

I'd also definitely recommend reading the datasheet if you're going to be making your own implementation for the code - it's essentially where I got all the information I needed to interface with it via Arduino.

Good luck!

0
EnthusiastGuy
EnthusiastGuy

Reply 2 months ago

Alright, good points! I'll need to park this for a month or so, since I'm writing the actual debugger part of my emulator now, but when I'll have that out of the way I'll start crunching documentation and hopefully make something work for the ESP S2 Mini. That has a good price for the consumer, plenty of pins to work with two 1099's if I decide to make a 4 chanel 6 voices or a 2 chanel 12 voices, and the memory is good if I want to actually store some audio data on it, similar to what a video card does with textures.

Thanks a lot for this project and your advice!

0
dominikpoignee
dominikpoignee

Question 2 years 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 2 years 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 2 years 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 2 years 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.

1
rui.bernardino
rui.bernardino

2 years 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 2 years 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 2 years 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

2 years 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

3 years ago

Works really well - thanks :)

0
Jfieldcap
Jfieldcap

Reply 3 years ago

Glad to hear! :D

0
Jfieldcap
Jfieldcap

Reply 5 years ago

You're welcome! Tell me how it goes!

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

Best of luck!