Archive for the ‘2A03 (Nintendo NES)’ Category

Where the Projects Are

Monday, September 7th, 2009

Things have grown a little convoluted because of all the projects I’ve mentioned up until now. I’d like to narrow it down to just a few until I can make enough money from selling finished devices to fund further designs. Prototyping is not cheap, so I need to be more realistic.

Pokey synth(s)

The Pokey module for use in Frac and Euro modular synthesizers will be the first thing I release. Right now I have the first prototype up and running, but there are still some circuit changes to make. The good news is that these are all minor. The overall design is working how I envisioned it, including the speed-sensitive tuning controls.

Along with that, I am checking out local manufacturing houses for stuffing the circuit boards. I am trying to have this done locally. There is also the metal work, which got a little more complicated with the addition of the Euro form factor.

I’ve mentioned a Pokey MIDI synthesizer a few times. That, however, is being put on hold. It still needs a considerable amount of DSP written, and I still do not have MIDI working 100%.  It works about 99.99% of data transfers, but there is still an occasional glitch every thousand commands or so that needs to be fixed.

2A03 synth(s)

The 2A03 MIDI synth is on hold until I get a lot more time or some outside help. The 2A03 module (also in Euro and Frac) is the second module I plan to release. On the upside, it should take about 1/4th the development time of the Pokey module. On the downside, it’s been more than a year and a half since the Pokey design was started.

ODB

This is a module I’m making as a break from soundchip modules. Without giving too much away, it is based around concepts of high-fidelity 1-bit audio.

Since every post needs a picture, here’s one from the digital sketchbook:

Still needs a lot of work

Still needs a lot of work

2A03 Horizons

Thursday, August 27th, 2009

I made an Octave script to simulate and graph all the 2A03 sweep unit settings as they change pitch over time. It is based entirely on my understanding of some documentation I found online… no measurements have actually been done. Each staircase represents one iterated combination of bit shifting and clock dividing. Something about the various quantizations weaving in and out of each other is strangely hypnotic.

Sweeeeeeeep

Sweeeeeeeep

Droppin Logs

Droppin' Logs

Open them in a new window for the full glory.

2A03 Triangle Wave Volume

Sunday, July 26th, 2009

As many developers have found, the 2A03 triangle wave registers are missing a relatively important feature: volume control. The noise channel gets 16 steps, the square channels get 16 steps, and the PCM channel gets 128 or so.  As for the triangle channel, it’s either “on” or “off.”

Limitations lead to creativity. The triangle, noise, and PCM channels all share the same output pin on the 2A03. The actual NES audio output design leads to some messy non-linearity. The result is a triangle wave that can be modulated by the PCM channel. I cannot name any games that use this effect, but it is relatively well-known.

So what does it mean?

As the signal on the PCM channel increases, the triangle wave gets quieter. If the PCM channel isn’t being used, it can provide crude volume control.

Under Control

Under Control

That picture shows the result of a test program that I made. It is a looped series of 128 triangle wave bursts. With each burst, the value on the PCM channel is increased by one. Over 128 bursts the volume drop is noticeable. It can be seen and heard.

Click here to hear the whole thing*

The two large pops (and all the small spikes in the picture) are related to DC offset issues. That is a story for another day.

*+1000 bonus points if you pictured the title screen to Uninvited after the first 2 seconds of this

Quick 2A03 Audio Test

Sunday, July 26th, 2009

Wave file here

Most of the 2A03 control tests have been on scopes and logic analyzers, so I did a quick test for actual audio. It does a small frequency sweep for two duty cycles of each pulse channel, some noise bursts, and a small triangle wave frequency sweep.

2A03 “Sound Chip” Progress

Friday, July 24th, 2009

As has been well-documented all across the Internet, the NES 2A03 is not a sound chip. Though it contains all the Nintendo sound hardware, it is very much a processor that needs properly-formatted program data to run.

For making a real-time synthesizer module that can fit into an analog synth, I want to make the 2A03 behave and interface just like a sound chip. My goal is a register update rate of 200 kHz. According to my calculations, the fastest theoretically possible is around 270 kHz.

To say it a little more clearly, my requirement is that the chip must be able to update the sound hardware 200,000 times per second. The second goal is to have this be as close to real-time as possible. Third, there is no program EEPROM or esoteric dual-port RAM. Lastly, the control system cannot burden the processor that connects to it. Pokey chips, SID chips, et al are able to take simple data and address commands as input. This should behave similarly.

This past week, I finally tested my first draft control system. The test was to write directly to the PCM register as quickly as possible. I used a sawtooth wave to exercise the full range of PCM values, and a square wave to test speed. The result: success at 126 kHz! The theoretical performance should’ve been 128 kHz, which is less than 2% off. The next goal is to get the control system handling 200 kHz. In the meantime, scope shots:

Check that delicious linearity

Delicious Linearity

The Usual

The Usual

Probing a 2A03

Saturday, May 23rd, 2009

Even my probes have probes!

Innocence Lost

I’ve been doing tests on a 2A03 to figure the best way to trick it into taking a program generated in real-time. You may wonder why there are so many probes, why some probes seem to probe other probes, or why at least one probe is missing a wire. The reason is simple: for science.

…Oops

Saturday, May 9th, 2009

It turns out that 9 mils (that’s 9 thousands of an inch) between solder pads and ground plane copper is too small for me to *not* accidentally bridge while soldering components. The 2A03 dev boards came in, and I made it this far before realizing I was fighting a losing battle:

The Power and Reset Buttons... of Shame

The Power and Reset Buttons... of Shame

Half the pins soldered are unintentionally shorted to the ground plane, which does not get much done electrically. I cannot even see the bridges with my bare eyes. My “2A03 dev board” budget for the month is shot, so I’ll have to breadboard it.

In the meantime, does anyone know what a resonable pour spacing is for soldering by hand with magnification? I’m going to try at least 12 mils next time, but that kills the ability of the ground plane to squeeze between DIP pins.

2A03 Audio Dev Board

Sunday, May 3rd, 2009

I put this together to tweak the 2A03 sound control system. It is essentially several processors and some buffering. Some parts are interconnected, and others are broken out into pin headers. It is powered by a standard 9-12V DC walwart, has two 1/4″ output jacks (one for each set of channels), and includes MIDI input circuitry. It’s a little big at 6″ by 6″, but the point is to make everything easily accessible by hand. I sent in the order last night, so expect to see more on it in a few weeks.

Next up is a revision of the Pokey Euro/Frac module main board.

RANT:

I finally bought circuit board design software. I had been using the free version of Eagle for several months, but after about a week with DipTrace it was clear I could work much faster. Eagle feels like it’s stuck in the 80s, while DipTrace is at least stuck in the 90s.

Someone should tell Cadsoft that requiring $1000 to get more than 6.3 by 3.9 inches of board space is quite silly. Who is more likely to need more board space:

a) A guy who can’t afford the tools and time to do surface-mount work, so instead relies on much larger through-hole parts

b) A guy who has the tools, time, and equipment to get surface-mount work done and is able to use very small parts

Now, who is more likely to have the bigger budget?

Most professional circuit board design software licenses use a system of paying more for increased complexity (more pins/nets = more $), regardless of physical size. I’m not sure who thought a size penalty made economic sense.

Just Some Chips

Saturday, March 21st, 2009
I had a pretty big breakthrough on the analog module side of things this week, but it is too boring and technical to write a post about until I get some audio going. Instead, here is a picture of a bunch of chips.

Its always good to have spares

It's always good to have spares

You might wonder, “Why so many chips? Are those all going into one single 1000-voice ultimate chip synth? Is mortality really a limitation, or is it a freedom from this ‘mortal’ coil?”

The answer to all of those is that I do plan to sell finished versions of these designs. I wanted to do kits for a while, but it is too time-consuming to make DIY solutions to all the digital work involved here. On the other hand, if I can get a streamlined manufacturing process then I can sell finished modules for less than what I would’ve been able to sell kits for. I can also fit more into less space using surface mount parts.

The definite designs are:

Pokey.synth analog module

Pokey MIDI

Nintendo analog module

Nintendo MIDI

YM2413 analog module

I have some plans together for a monster SID synth module with ridiculous features, but I don’t think anyone would be willing to pay what it would cost. Also, it would take up two full rack spaces.

Variations on a Theme: Bit Crushing

Saturday, January 24th, 2009

Disclaimer: For any sticklers out there, there are some discrepancies between this article and exactly how the NES handles audio. There are also some details neglected (sample rates, resulting bit depths). This is intended as a basic overview.

Original Clip

Crushing 1

Crushing 2

Crushing 3

Crushing 4

Crushing 5

The sound of simple bit crushing exploded in popularity several years ago when “lo-fi” became all the rage. It’s almost always done the same way: a control changes the “step” size of a blocky mess to vary the amount of quantization distortion. The fewer bits used, the bigger, steppier, and noisier the result gets.

Modern digital audio signals are almost always PCM data. Each chunk of data is essentially a sound pressure level at an exact point in time.

..but that’s only one way to store and represent audio in the digital realm. What about an entirely different method?

The Nintendo NES designers didn’t care much about audio fidelity, but did want some type of digital audio playback. You’ve probably played a Nintendo game at some point that warned you, through a wall of half-intelligible fuzz, to “skate or die die die die*” or “double dibl.” It took special audio encoding to sound so terrible.

Instead of encoding the volume of each point in time, many NES games stored a sequence of volume differences. It’s a handy format known as Differential PCM. If you have audio data that looks like, in PCM form:

1, 2, 4, 6, 3, 2

in DPCM form it becomes

+1, +1, +2, +2, -3,-1

To get the original data back you must add each term in the DPCM. As a breakdown:

n[0] = 1

n[1] = n[0] + 1 = 2

n[2] = n[1] + 2 = 4

n[3] = n[2] + 2 = 6…

We get our original data back. The advantage here is that instead of caring about the largest value (6), the largest *difference* (3) is what matters. Most audio signals have relatively small differences compared to their highest and lowest values, so a high compression ratio is possible. Instead of needing a whole byte per sample, you could likely get away with a nibble. Of course, the Nintendo didn’t have that many bits to waste! It used 1-bit DPCM. That same PCM stream of numbers, converted to 1-bit DPCM and back, goes like this:

DPCM: +1, +1, +1, +1, -1, -1

PCM: 1, 2, 3, 4, 3, 2

That’s not what we started with! This creates a distortion different from traditional bit-crushing. It has the effect of increasing noise and filtering the signal at the same time. Essentially the 1-bit DPCM format “chases” the incoming audio. High frequencies end up distorted into triangle waves.

Hopefully we’ve all seen a sine wave at some point. Here is a low frequency sine wave that’s been run through 1-bit DPCM and reconstructed:

Tasty

The Lowest Distortion Case

The wave is slow enough that the 1-bit +/- signal can track it pretty well. Notice the flat regions of the sine wave switch back and forth between two values very quickly:

Flat Part Close Up

Flat Part Close Up

Each new value can only be the previous value plus one or the previous value minus one. There is no such thing as a constant value. Isn’t 1-bit great?

What happens when the sine wave is faster and gets harder to “chase”? The original wave is shown in red, and the 1-bit de/reconstruction is shown in blue.

Triangles!

Triangles!

Graphs are pretty hard to hear, so I included some audio demos of a drum loop. Each file uses 1-bit DPCM, but in each case the size of the steps decreases.

*After listening some more, the Skate or Die 2 intro vocal sounds too clear to be using DPCM. It was possible to use actual 7-bit PCM data on the NES, but was somewhat rare because of the overhead required both to play it back smoothly and also store it. For the highest quality recorded audio I’ve heard in an NES game, check out Big Bird’s Hide and Speak.