APU Envelope: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
m (Created page with 'The NES APU volume envelope unit generates a constant volume or a decreasing saw envelope with optional looping. Each volume envelope unit contains the following: start ...')
 
(tokumaru was confused about the use of the word "envelope" in http://nesdev.parodius.com/bbs/viewtopic.php?p=65066#65066 so I sprinkled the word "decay" to draw analogies to ADSR)
Line 1: Line 1:
The [[APU|NES APU]] volume envelope unit generates a constant volume or a decreasing saw envelope with optional looping.
In a synthesizer, an [[wikipedia:ADSR_envelope|envelope]] is the way a sound's parameter changes over time.
The NES [[APU]] has an envelope generator that controls the volume in one of two ways: it can generate a decreasing saw envelope (like a decay phase of an ADSR) with optional looping, or it can generate a constant volume that a more sophisticated software envelope generator can manipulate.


Each volume envelope unit contains the following: start flag, [[APU Misc|divider]], counter.
Each volume envelope unit contains the following: start flag, [[APU Misc|divider]], and counter.


{| border=1
{| border=1
Line 10: Line 11:
| '''$400C''' || <tt>--LC.NNNN</tt> || '''[[APU Noise|Noise channel]]''' envelope (write)
| '''$400C''' || <tt>--LC.NNNN</tt> || '''[[APU Noise|Noise channel]]''' envelope (write)
|-
|-
| bit 5 || <tt>--L- ----</tt> || Loop flag (this bit is also the [[APU Length Counter|length counter's halt flag]])
| bit 5 || <tt>--L- ----</tt> || [[APU Length Counter]] halt flag (a decaying volume envelope will loop if the length counter is halted)
|-
|-
| bit 4 || <tt>---C ----</tt> || Constant volume flag
| bit 4 || <tt>---C ----</tt> || Constant volume flag (0: decay; 1: constant volume)
|-
|-
| bits 3-0 || <tt>---- NNNN</tt> || Envelope parameter. The divider's period is set to N + 1.
| bits 3-0 || <tt>---- NNNN</tt> || Decay mode: Decay time (the divider's period is set to N + 1)<br>Constant volume mode: Volume
|-
|-
|colspan=3| &nbsp;
|colspan=3| &nbsp;

Revision as of 12:41, 29 July 2010

In a synthesizer, an envelope is the way a sound's parameter changes over time. The NES APU has an envelope generator that controls the volume in one of two ways: it can generate a decreasing saw envelope (like a decay phase of an ADSR) with optional looping, or it can generate a constant volume that a more sophisticated software envelope generator can manipulate.

Each volume envelope unit contains the following: start flag, divider, and counter.

$4000 ddLC.NNNN Pulse channel 1 duty and envelope (write)
$4004 ddLC.NNNN Pulse channel 2 duty and envelope (write)
$400C --LC.NNNN Noise channel envelope (write)
bit 5 --L- ---- APU Length Counter halt flag (a decaying volume envelope will loop if the length counter is halted)
bit 4 ---C ---- Constant volume flag (0: decay; 1: constant volume)
bits 3-0 ---- NNNN Decay mode: Decay time (the divider's period is set to N + 1)
Constant volume mode: Volume
 
$4003 LLLL.Lttt Pulse channel 1 length counter load and timer (write)
$4007 LLLL.Lttt Pulse channel 2 length counter load and timer (write)
$400F LLLL.L--- Noise channel length counter load (write)
Side effects Sets start flag

When clocked by the frame counter, one of two actions occurs: if the start flag is clear, the divider is clocked, otherwise the start flag is cleared, the counter is loaded with 15, and the divider's period is immediately reloaded.

When the divider outputs a clock, one of two actions occurs: If the counter is non-zero, it is decremented, otherwise if the loop flag is set, the counter is loaded with 15.

The envelope unit's volume output depends on the constant volume flag: if set, the envelope parameter directly sets the volume, otherwise the counter's value is the current volume.