$0.00 0

YOUR CART
Checkout

SUBTOTAL
DISCOUNT
TOTAL
Checkout
In this tutorial, I'll continue the work from last week, building an NES emulator in...

Reaktor Tutorials

Building an NES Emulator in Reaktor, Part II

In this tutorial, I’ll continue the work from last week, building an NES emulator in Reaktor from scratch (well, the audio parts anyway!). In the previous tutorial, I explained many of the difficulties around the emulation process, and designed a simple device to calculate the number of NES clock cycles to process for each tick of the sample clock in Reaktor.

THE APU CLOCK

In my work last week, I forgot that there are actually a couple different clocks used for the oscillators in the NES. The triangle oscillator uses the CPU Clock which we made last week, the pulse and noise oscillators use the APU clock, which runs at half the speed of the CPU clock. It is easy enough to add this:

Building an NES Emulator in Reaktor, Part II - ADSR

Now we are ready to get on with making the oscillators, beginning with some common elements.

CREATING A TIMER

A timer, or divider, is a component used by all of the sound generators in the NES. It has a fairly simple operation: it outputs a single clock event for every T+1 events received. The value, T, is given by a simple equation:

T = CPU/(16*F) – 1

Where CPU is the clock speed in Hz, and F is the frequency of the oscillator. In Reaktor, this looks like so:

Building an NES Emulator in Reaktor, Part II - ADSR

You may have noticed that T is an integer. This leads to a rounding error in regards to frequency, usually small enough to pass unnoticed.

With a T value of 8 or less, the oscillator shuts off entirely. Since this translates to a frequency of over 12KHz, which is rarely used in synthesis, so I have omitted this detail for the time being, however this would be easy to implement if desired.

Let’s talk for a moment about the exact operation of the timer. It stores a value called the counter, that is initialized to the value of T. For each incoming clock, the counter is checked. If it is greater than zero, the value is decreased by one. If it is equal to zero, it is reset to T, and a clock is sent to the output.

Depending on the value of T, the Timer might send out several triggers per Reaktor sample. We are receing either 20 or 21 APU clocks per sample. With a mininum T value of 8, this means that there could be as many as three outputs from the Timer that we need to calculate at once.

With this in mind, I developed the following timer device:

Building an NES Emulator in Reaktor, Part II - ADSR

Here, we are receiving three pieces of information: the current value of the timer (Cnt), the number of APU clocks left to process (Clk), and our previously calculated value of T.

If the counter is higher than the number of events, we simply pass the number of clock values to the ‘Events’ output, subtract it from the counter, and send zero clock events to the next Timer macro.

Otherwise, the ‘Events’ output get the number held by the counter, the counter is reset to T, and whatever clock events remain are sent to the next Timer macro.

Three of these macros connected together will give us the all of the information we need to continue:

Building an NES Emulator in Reaktor, Part II - ADSR

Okay, so the values Clk and Cnt are being passed from macro to macro, as they are changing each time. The output ‘Events’ is the number of events to calculate at a given position.

This whole setup can be pretty confusing. The numbers coming out the ‘Zero’ output are events that occured before anything changed with the oscillator, IE before it received any events from the timer. The outputs ‘One’ and ‘Two’ require that the oscillator be clocked.

CONCLUSION

Next week, I’ll show how these Timers can be used to control NES oscillators. If you have any questions, suggestions, or comments, please leave them below!

Waveform Loaded
Waveform Played
×
PLAYLIST
Clear all
WISHLISTS
Create an account to use wishlists
×
SAVE TUTORIALS
Create an account to save tutorials
×
FOLLOW YOUR FAVORITES
Follow your favourite labels, formats and genre's and ADSR will show what's new in those on your next visit.
×
  • Create product wishlist
  • Save your favorite tutorials
  • Regular discounts and exclusives
  • Never miss a sound! Follow your favorite labels.
Sign up to My ADSR to ensure you're ahead of the pack. Save your favorite content and be notified of new content. You'll never miss a thing!
Create your account now!
CREATE ACCOUNT
Sign up to My ADSR to ensure you're ahead of the pack. Save your favorite content and be notified of new content. You'll never miss a thing!
  • Get 7 days all ADSR courses free
  • Create product wishlist
  • Save your favorite tutorials
  • Regular discounts and exclusives
Create your account now!
SIGN IN
adsrsounds.com login Video streaming login
Remember me
Forgot your password?
DON'T HAVE AN ADSR ACCOUNT?
Create your account
FORGOT PASSWORD

Send info
  1. Enter your email address
  2. Click "Send info"
  3. Check your inbox for an activation link
  4. Visit activation link and enter set new password
Sign in
DON'T HAVE AN ADSR ACCOUNT?
Create your account