MMC5 audio polarity

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
MMC5 audio polarity
by on (#131121)
The MMC5 audio page on the wiki states that "the polarity of all MMC5 channels is reversed compared to the APU."

What does that mean, exactly? Should the 0s and 1s in the APU's duty cycle sequences be swapped?

Code:
Duty    Waveform sequence
0   0 1 0 0 0 0 0 0 (12.5%)
1   0 1 1 0 0 0 0 0 (25%)
2   0 1 1 1 1 0 0 0 (50%)
3   1 0 0 1 1 1 1 1 (25% negated)
Re: MMC5 audio polarity
by on (#131123)
It means that if the NES squares produce a positive voltage on a "1", the MMC5 squares doing the equivalent thing will produce a negative voltage.

I would suggest inverting the output. Don't make changes to the internal digital logic before output. Simply exchanging 1 and 0 is not the right idea, as remember this squares also have a volume control. 0 should still output 0, and this makes a difference especially if you are simulating an analog filter on the output. If you could replace 1 with -1, that would be conceptually more like what you want, but it would only be the correct implementation if you are multiplying it with the volume and not using some boolean logic on the volume.
Re: MMC5 audio polarity
by on (#131124)
So the MMC5 is actually outputting a negative voltage?
Re: MMC5 audio polarity
by on (#131127)
Yes. If your resampler can handle only unsigned signals, try subtracting the MMC5's output from 30.
Re: MMC5 audio polarity
by on (#131131)
Signed signals aren't a problem; I'll give it a try. Thanks, guys.
Re: MMC5 audio polarity
by on (#131158)
This seems to work fine, but I have a couple of (maybe dumb) questions:
- Where is the MMC5's negative voltage source?
- Why doesn't this cause issues? For example, wouldn't similarly setup square waves on the APU and MMC5 cancel each other out?

tepples wrote:
try subtracting the MMC5's output from 30.

That's inverting the signal, though, not generating a negative signal...
Re: MMC5 audio polarity
by on (#131159)
James wrote:
- Why doesn't [MMC3's inverted waveform] cause issues? For example, wouldn't similarly setup square waves on the APU and MMC5 cancel each other out?

They might cancel if they're exactly in phase, just as a 2A03 pulse wave with duty cycle $40 (1/4) and one with duty cycle $C0 (3/4) cancel. But in practice, such waves are rarely exactly in phase because they're playing different notes in the first place.

Quote:
That's inverting the signal, though, not generating a negative signal

There's no audible difference between the two.
Re: MMC5 audio polarity
by on (#131160)
James wrote:
- Where is the MMC5's negative voltage source?
That's inverting the signal, though, not generating a negative signal...


Voltage isn't absolute, it's a relative difference. Whatever the baseline output of the 2A03 or MMC5 is, there is a highpass filter which shifts that baseline to ground (0). It doesn't need a negative voltage source, it only needs to go negative relative to its baseline output. Inverting and negating are the same thing in this situation.
Re: MMC5 audio polarity
by on (#131161)
ok -- I think I get it now. What you're saying is that, pre-highpass filter, whether the signal looks like this:
Code:
      2A03
      ----
     |    |
     |    |
0v --------------------
             |    |
             |    |
              ----
              MMC5

or this:
Code:
      2A03
      ----
     |    |
     |    |
   --      --      ----
             |    |
             |    |
              ----
              MMC5

0v --------------------


the output post-highpass is the same. Right?
Re: MMC5 audio polarity
by on (#131163)
Yes, that is correct.

It's standard for a lot of audio devices to include a mild highpass filter to get rid of DC offset, because it can reduce amplifier headroom, cause inefficient use of power, or cause other problems for an audio system. You also can't hear a DC offset.