MMC5 audio polarity

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

Post Reply
User avatar
James
Posts: 431
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

MMC5 audio polarity

Post by James »

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: Select all

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)
get nemulator
http://nemulator.com
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: MMC5 audio polarity

Post by rainwarrior »

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.
User avatar
James
Posts: 431
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

Re: MMC5 audio polarity

Post by James »

So the MMC5 is actually outputting a negative voltage?
get nemulator
http://nemulator.com
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: MMC5 audio polarity

Post by tepples »

Yes. If your resampler can handle only unsigned signals, try subtracting the MMC5's output from 30.
User avatar
James
Posts: 431
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

Re: MMC5 audio polarity

Post by James »

Signed signals aren't a problem; I'll give it a try. Thanks, guys.
get nemulator
http://nemulator.com
User avatar
James
Posts: 431
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

Re: MMC5 audio polarity

Post by James »

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...
get nemulator
http://nemulator.com
tepples
Posts: 22705
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: MMC5 audio polarity

Post by tepples »

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.
That's inverting the signal, though, not generating a negative signal
There's no audible difference between the two.
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: MMC5 audio polarity

Post by rainwarrior »

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.
User avatar
James
Posts: 431
Joined: Sat Jan 22, 2005 8:51 am
Location: Chicago, IL
Contact:

Re: MMC5 audio polarity

Post by James »

ok -- I think I get it now. What you're saying is that, pre-highpass filter, whether the signal looks like this:

Code: Select all

      2A03
      ----
     |    |
     |    |
0v --------------------
             |    |
             |    |
              ----
              MMC5
or this:

Code: Select all

      2A03
      ----
     |    |
     |    |
   --      --      ----
             |    |
             |    |
              ----
              MMC5

0v --------------------
the output post-highpass is the same. Right?
get nemulator
http://nemulator.com
User avatar
rainwarrior
Posts: 8731
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

Re: MMC5 audio polarity

Post by rainwarrior »

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.
Post Reply