APU Envelope: Difference between revisions
m (Minor clarifications (iiutc the envelope is always ticking, even in constant volume mode)) |
(Clarify that the constant volume flag only selects the volume source (verified in Visual 2A03)) |
||
Line 33: | Line 33: | ||
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. | 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. | 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. The constant volume flag has no effect besides selecting the volume source; the envelope counter will still be updated when constant volume is selected. |
Revision as of 07:16, 4 May 2013
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/envelope loop flag |
bit 4 | ---C ---- | Constant volume flag (0: use volume from envelope; 1: use constant volume) |
bits 3-0 | ---- NNNN | The reload value for the envelope's divider (the period becomes N + 1). Used as the volume in constant volume (C set) mode. |
$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. The constant volume flag has no effect besides selecting the volume source; the envelope counter will still be updated when constant volume is selected.