VRC7 audio: Difference between revisions

From NESdev Wiki
Jump to navigationJump to search
m (→‎Custom Patch: formatting)
m (→‎Registers: hierarchy)
Line 29: Line 29:
Other register values appear to be ignored.
Other register values appear to be ignored.


=== Custom Patch ===
==== Custom Patch ====


{| class="tabular"
{| class="tabular"
Line 70: Line 70:
If the sustain bit is not set in '''$00/$01 S''', release begins immediately after decay.
If the sustain bit is not set in '''$00/$01 S''', release begins immediately after decay.


If the sustain bit is set in the channel control register '''$2X S''' (see channels below), the release value in the patch
If the sustain bit is set in the channel control register '''$2X S''' (see ''Channels'' section below), the release value in the patch
is ignored and replaced with $5.
is ignored and replaced with $5.


Line 87: Line 87:
|}
|}


=== Channels ===
==== Channels ====


{| class="tabular"
{| class="tabular"

Revision as of 21:15, 13 April 2012

The Konami VRC7, in addition to being a mapper chip, also produces 6 channels of 2-operator FM Synthesis Audio. It is a derivative of the Yamaha YM2413 OPLL, implementing a subset of its features and containing a custom fixed patch set.

VRC7 audio was only used in one game, Lagrange Point. The chip also appears in Tiny Toon Adventures 2, but this cart does not use the audio, and its board lacks required additional audio mixing circuitry.

Registers

Audio Register Select ($9010)

7......0
VVVVVVVV
++++++++- The 8-bit internal register to select for use with $9030

This register is write-only.

Audio Register Write ($9030)

7......0
VVVVVVVV
++++++++- The 8-bit value to write to the internal register selected with $9010

This register is write-only.

Internal Audio Registers

The VRCVII appears to have 26 internal registers. Registers $00-$07 define a custom patch that can be played on any channel set to use instrument $0. Registers $10-$15, $20-25, and $30-35 control 6 channels for FM synthesis. Other register values appear to be ignored.

Custom Patch

Register Bitfield Description
$00 TVSK MMMM Modulator tremolo (T), vibrato (V), sustain (S), key rate scaling (K), multiplier (M)
$01 TVSK MMMM Carrier tremolo (T), vibrato (V), sustain (S), key rate scaling (K), multiplier (M)
$02 KKOO OOOO Modulator key level scaling (K), output level (O)
$03 KK-Q WFFF Carrier key level scaling (K), unused (-), carrier waveform (Q), modulator waveform (W), feedback (F)
$04 AAAA DDDD Modulator attack (A), decay (D)
$05 AAAA DDDD Carrier attack (A), decay (D)
$06 SSSS RRRR Modulator sustain (S), release (R)
$07 SSSS RRRR Carrier sustain (S), release (R)

The patch defines a 2-operator FM unit with a single modulator and carrier. The carrier produces the output tone, and the output of the modulator modulates its frequency. The patch has the following parameters:

  • $00/$01 T Tremolo applies amplitude modulation at a predefined rate.
  • $00/$01 V Vibrato applies pitch modulation at a predefined rate.
  • $00/$01 S Sustain determines whether the operator uses the sustain section of the envelope or not.
  • $00/$01 K Key rate scaling adjusts the ADSR envelope speed, faster for high frequencies, slower for low ones.
  • $00/$01 MMMM Multiplier is a multiplier on the operator's frequency according to a lookup table (see below).
  • $02/$03 KK Key level scaling attenuates the operator at higher frequencies $0 = none, $3 = most.
  • $02 OOOOOO Modulator output level, this value reduces the modulator volume in 0.75db increments.
  • $03 Q/W Operator waveform, 0 = sin, 1 = abs(sin).
  • $03 FFF Feedback applied to modulator according to a lookup table (see below).
  • $04/$05 AAAA Attack is the speed of the attack fade in after key-on. $0 = halt, $1 = slowest, $F = fastest.
  • $04/$05 DDDD Decay is the speed of the decay fade to sustain after attack. $0 = halt, $1 = slowest, $F = fastest.
  • $06/$07 SSSS Sustain is the attenuation after decay, in 3db increments. $0 = highest volume, $F = lowest.
  • $06/$07 RRRR Release is the speed of the release fade to silent after sustain. $0 = halt, $1 = slowest, $F = fastest.

If a note is released before the attack or decay finishes, release begins from the current volume level. If the sustain bit is not set in $00/$01 S, release begins immediately after decay.

If the sustain bit is set in the channel control register $2X S (see Channels section below), the release value in the patch is ignored and replaced with $5.

$00/$01 MMMM $0 $1 $2 $3 $4 $5 $6 $7 $8 $9 $A $B $C $D $E $F
Multiplier 1/2 1 2 3 4 5 6 7 8 9 10 10 12 12 15 15
$03 FFF $0 $1 $2 $3 $4 $5 $6 $7
Modulation Index 0 π/16 π/8 π/4 π/2 π

Channels

Register Bitfield Description
$10-$15 LLLL LLLL Channel low 8 bits of frequency
$20-$25 --ST OOOH Channel sustain (S), trigger (T), octave (O), high bit of frequency (H)
$30-$35 IIII VVVV Channel instrument (I), volume (V)

Each channel X is controlled by three registers at $1X, $2X, and $3X.

The 8 bits of $1X with a 9th bit from bit 0 of $2X create a 9-bit frequency value (freq). This is combined with a 3-bit octave value from $2X (octave) to define the output frequency (F):

     49722 hz * freq
F = -----------------
     2^(19 - octave)

Writing to register $2X either begins a key-on or key-off event, depending on the value in the trigger bit (T). If the trigger bit is 1, a new note begins, if it is 0 it will begin the release portion of its envelope which will eventually silence the channel (unless release is $0). If it was already 0, no new key-off will be generated. Note that the octave and high frequency bit cannot be altered between key-on and key-off, but the low 8 bits of frequency in $1X can be used to apply vibrato and pitch bends.

Using the sustain bit (S) in $2X overrides the normal release value for the patch with a value of $5.

Register $3X selects the instrument patch to use, and chooses a volume. Note that volume value is inverted: $F is the lowest volume and $0 is the highest. There is no silent volume value; its output scale is logarithmic in 3db increments.

Internal patch set

There are 16 different instrument patches available on the VRC7. With the exception of instrument $0, which can be controlled by registers $00-$07 (see above), these are hardwired into the chip and cannot be altered.

Exact values for the fixed patch set are not yet known, the following table is conjectural:

     00 01 02 03 04 05 06 07
     -----------------------
 0 | -- -- -- -- -- -- -- --
 1 | 31 22 23 07 F0 F0 E8 F7
 2 | 03 31 68 05 F2 74 79 9C
 3 | 01 51 72 04 F1 D3 9D 8B
 4 | 22 61 1B 05 C0 A1 F8 E8
 5 | 22 61 2C 03 D2 A1 A7 E8
 6 | 31 22 FA 01 F1 F1 F4 EE
 7 | 21 61 28 06 F1 F1 CE 9B
 8 | 27 61 60 00 F0 F0 FF FD
 9 | 60 21 2B 06 85 F1 79 9D
 A | 31 A1 FF 0A 53 62 5E AF
 B | 03 A1 70 0F D4 A3 94 BE
 C | 2B 61 E4 07 F6 93 BD AC
 D | 21 63 ED 07 77 F1 C7 E8
 E | 21 61 2A 03 F3 E2 B6 D9
 F | 21 63 37 03 F3 E2 B6 D9

Differences from OPLL

The synthesis core is related to the Yamaha YM2413 OPLL, which is itself a cost-reduced version of the YM3182 OPL2 chip made popular by AdLib and SoundBlaster sound cards.

  • Register layout is the same.
  • VRC7 has 6 channels, OPLL has 9.
  • VRC7 has no rhythm channels, OPLL does (the last 3 channels are either FM or Rhythm on OPLL).
  • VRC7 built-in instruments are NOT the same as OPLL instruments (except for instruments 4,5,7,8 which might be the same on both?).
  • VRC7 has no readily-accessible status register, under normal circumstances it is write-only; OPLL has an undocumented, 2-bit 'internal state' register.
  • VRC7 has an internal state output pin (may be serial version of the 2 bit internal state register) and has one output pin for audio, multiplexed for all 6 channels; OPLL has two output pins, one for FM and one for Rhythm, and has no special status pin.

References