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

Hurdles

Sunday, July 29th, 2012

The 2nd version Atari synth prototypes came back from assembly early this week, but something has them bricked.
The worst case is that there might be hardware damage (soldering too hot, static zap during handling, moisture problems), since that leaves little I can prove in a post-mortem. At $500 a run, prototypes are not cheap.

<geek notes>
The power supplies measure fine, and JTAG diagnostic tests on the FPGA pass with flying colors. The configuration pins all check out, too. Yet somehow the FPGA will not run. It is not simply a code issue, because the part won’t even run factory code from the manufacturer.
The 2.5V I/O banks appear to be driving out 0.45V intermittently, which can’t be a good sign of anything.
</geek notes>

So that is unfortunate.

To get back to something that *is* working, the 2A03 synth is coming along. It currently has voltage control of:
Pulse wave 1 pitch
Pulse wave 1 volume
Pulse wave 2 pitch
Pulse wave 2 volume
Triangle wave pitch
Noise wave volume

…and knob controls for:
Pulse wave 1 pitch
Pulse wave 1 volume
Pulse wave 1 duty cycle
Pulse wave 2 pitch
Pulse wave 2 volume
Pulse wave 2 duty cycle
Triangle wave pitch
Noise wave pitch
Noise wave volume

Click here for audio of one pulse wave modulated by a couple envelope generators

One of the downsides to using the actual NES CPU is that it has unobvious quirks. It would be far easier to make an FPGA clone of the 2A03 audio engine and just fix the quirks, but what’s the challenge in that?

The pulse wave pitch control registers are a good example. They are 11 bits wide, which isn’t anything special. On the other hand, any write command to the greatest 3 bits will cause a phase reset in the output waveform. In a videogame soundtrack where each note starts with a volume of 0, it might never be a problem. In a synthesizer where oscillators are “on” constantly, it leads to clicking as pitch changes.

I am experimenting with workarounds. One trick is to use the pitch sweep hardware built into the part to trigger an increase or decrease in the upper 3 bits without issuing a write command. That has two downsides:
1) Worst case, it takes almost 20 times longer than just letting the click happen
2) It is more difficult to keep stable

It takes so much longer because it involves writing several non-pitch registers multiple times. That ends up lowering the sample rate on pitch control voltage. The stability issue is just that I see the pulse wave pitch occasionally lock up and refuse to change for several seconds. It is probably due to some corner case I have not found yet, but it never happens in the clicky version.

I cannot take credit for the clever idea to use the sweep unit, by the way. That came from the nesdev.parodius.com forum.

I made a demo to show the difference. The following audio file alternates clicky/smooth/clicky/smooth through some pitch modulation.

Click here for audio

2A03 Triangle Arpeggios

Monday, July 9th, 2012

Volt per octave control is kinda sorta working.

Click here for audio

It really needs to be calibrated, and it also needs some filtering to get rid of noise. Soon…

First CV Audio From 2A03

Sunday, July 8th, 2012

I needed a break from working on the new Pokey.synth code, so I took this afternoon to get the DE0-Nano input board (mentioned in the previous post) working with an audio channel on the NES. Today’s wave: the triangle.

This is a Make Noise Maths plus a little knob twiddling feeding the triangle wave pitch of the 2A03. It’s not following the volt per octave standard yet, but it’s smooth and responsive like a modular synth oscillator should be.

Click here for audio.

Early Tests of Max/MSP Controlling 2A03 (NES CPU) Audio

Monday, December 12th, 2011

My last post mentioned that I had an interface working for controlling the 2A03 at a reasonably fast rate. Last week I wrote a serial data receiver (UART in this case) into the 2A03 control logic so I could send the 2A03 commands from Max/MSP. I technically could’ve used MIDI, but at 31,250 bps it is far too slow for all the data I want to send as quickly as I want to send it. I opted for 1,000,000 bps with the option to speed it up further later.

The chain looks like this:
Max/MSP -> FTDI USB-to-UART cable -> FPGA development board -> 2A03 adapter

It works just as well as I hoped. I basically have real-time control over all the NES audio registers from Max/MSP. Here’s a screenshot of the big ol’ mess in Max:

It serves as a quick idea prototyping/test platform for the NES synth module, so it changes too frequently to bother making it tidy.

This post is boring without audio, so how about a few test recordings? These are all straight from an NES CPU into the preamps on my sound card.

Click here for clip 1 – triangle wave FM

The pitch of the triangle wave is modulated by a sine wave in Max/MSP. There is a lot of jitter in the timing not only because of the serial transmission, but also because I have to convert the sine from an audio thread in Max to control data to use with the “serial” object. Control data timing is not designed for audio. It worked decently given the circumstances.

Click here for clip 2 – pulse wave delay

One of my favorite Nintendo sounds is two pulse waves configured as an echo effect. I am just playing with a few settings (delay time, second wave volume and duty cycle). The percussive nature of the voices comes from an envelope with an attack time of zero and a short decay to silence. The envelope and all other data is being completely handled by Max and dumped out over USB. The pops in the audio are from a known control issue. They will get better and go away as I tweak the control logic.

Click here for clip 3 – noise bursts

I couldn’t post audio tests without including the noise channel. This is a steady stream of short bursts (zero attack time and fast release time) with pitch and timbre being adjusted by hand then linked to the amplitude envelope in fun ways.

Sweep of the Day

Sunday, November 20th, 2011

The NES synth module pushes onward! The sound clip below is the first audio of the triangle channel successfully controlled by the newest scheme. This method gives a register update rate of the audio hardware around 200 kHz with very low timing jitter.

Click here for sweep.

200 kHz probably sounds like overkill, but realize that has to be distributed across all the registers to update. For example, the pitch of one pulse wave uses two registers. If I did nothing but update the pitch of one pulse wave, the system would update at a maximum of 100 kHz ( = 200 kHz / 2 registers). Between noise, pulse, and triangle pitch there are seven registers. On top of that there are three volume registers and one on/off flag.

200 kHz / (7 + 3 + 1) = ~18 kHz, which does not sound quite so fast anymore.

Newest 2A03 Dev Board

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