VRC6 Audio Mixing

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

VRC6 Audio Mixing

Post by zeroone »

From the wiki:
At maximum volume, the pulse channels of the VRC6 are roughly equivalent to the pulse channels of the 2A03 (except inverted). The DAC of the VRC6, unlike the 2A03, appears to be linear.

The final mix is a 6-bit DAC summing the two 4-bit pulse outputs and the high 5 bits of the saw accumulator.
I'm confused how to mix the 5-bit output with the other channels. Should I be doing something like this:

Code: Select all

                                                    95.88
pulse_out = --------------------------------------------------------------------------------------
             (8128 / (apu_pulse1 + apu_pulse2 + vrc6_pulse1 + vrc6_pulse2 + vrc6_sawtooth)) + 100
User avatar
rainwarrior
Posts: 8758
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: VRC6 Audio Mixing

Post by rainwarrior »

No. The VRC6 is mixed independently of the APU and it is linear. Don't include it in the APU's nonlinear mix.

Linear mix = addition.

The overall level of the VRC6 is roughly so that its pulse at full strength is equivalent in volume to an APU pulse at full strength.

Code: Select all

apu_mix = ... ; // you've got some formula for this already

const VRC6_SCALE = APU_PULSE_STRENGTH / 15;
vrc6_mix = (vrc6_pulse1 + vrc6_pulse2 + vrc6_sawtooth) * VRC6_SCALE;

output = apu_mix + vrc6_mix;
You can calculate APU_PULSE_STRENGTH by plugging a full-on pulse into your APU mixing formula.
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: VRC6 Audio Mixing

Post by zeroone »

The wiki mentions that the signal is inverted? What does that mean?
tepples
Posts: 22853
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: VRC6 Audio Mixing

Post by tepples »

A lot of synthesizers in Famicom mappers are configured with opposite polarity compared to the 2A03's APU. For example, a tone on the 2A03 might produce levels 0, 8, 0, 8, 0, ... while an equivalent tone on a mapper synth might produce 0, -8, 0, -8, 0. Normally this 180 degree phase difference is inaudible unless you try to play the same tone on the 2A03 and the mapper synth at the same time.
User avatar
rainwarrior
Posts: 8758
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: VRC6 Audio Mixing

Post by rainwarrior »

In your code, though, you can invert the output just by putting a - in front of the scale constant.

Inverted relative to the APU means that if the APU outputs a pulse as a short positive voltage then a long negative one (relatively), the equivalent thing on VRC6's pulse would be a short negative voltage then a long positive one.

As tepples pointed out, it doesn't make a difference in what you hear, but it is a technical difference in the signal that can be measured.


Calling it a 180 degree phase difference may seem kind of strange, depending on how you think of it, but it's technically correct in the frequency domain. An inversion of a periodic signal in the frequency domain is a 180 degree phase difference. In the signal domain, though, it's not except in the case of a symmetrical signal like a 50% square or triangle.
User avatar
zeroone
Posts: 939
Joined: Mon Dec 29, 2014 1:46 pm
Location: New York, NY
Contact:

Re: VRC6 Audio Mixing

Post by zeroone »

Thanks rainwarrior and tepples. Those suggestions worked quite well.
Post Reply