NES APU DAC nonlinearity tests

Discuss hardware-related topics, such as development cartridges, CopyNES, PowerPak, EPROMs, or whatever.

Moderator: Moderators

Post Reply
User avatar
rainwarrior
Posts: 8732
Joined: Sun Jan 22, 2012 12:03 pm
Location: Canada
Contact:

NES APU DAC nonlinearity tests

Post by rainwarrior »

So, a few years ago I was trying to measure the APU mixer and compare it with Blargg's magic formula that everybody copy-pastes.

Basically I was hoping to come up with a validation of Blargg's result, or re-derive it somehow, or find something better. I worked on the problem for a while, but it didn't really have very satisfying improvement or conclusion. It think it was was also during the forum blackout, so I neglected to post about this stuff back then.

The short version is that Blargg's curves are reasonably good, and I haven't come up with anything better. There's a lot of hardware variance involved that make it hard to come up with something more accurate, and as a model it does fit close to the observed ranges.

.

So, all the code is at nes-audio-tests on github. It's the dac_* tests, combined with a python analysis program at misc/dac.py. That's everything that I produced, except for the audio recordings themselves.

At the time I measured my NES and my Famicom. I tried a bunch of different tests, and not all of the results were very interesting. Here's a collection of some of the graphs that I thought were worth sharing:
  • Blue - Blargg's curve.
  • Cyan - NSFPlay's implementation of Blargg's curve (demonstrates inherent noise in the generation/measuring process).
  • Green - My famicom, modded for composite output.
  • Red - My front-loader NES.
squares_comparison_NESred_FCgreen_BLARGGcyan.png
Square wave DAC comparison, showing amplitudes of all 30 combinations of square volumes (with matched phase), divided by the expected linear volume (i.e. amplitude directly relative to the register volume value), and normalized with a single channel at volume 15 as "1".
  • My Famicom is slightly closer to linear, being flatter at both ends.
  • Blargg matched my NES very well at higher volumes. At lower volumes, my NES was slightly higher.
squares_comparison_separated.png
Just the data for each square channel in isolation (pardon the x-axis numbers on the right, just subtract 16).
  • We can see some noticeable discontinuity in my NES' two square channels especially.
  • Even within the same chip we can't expect too much consistency between the 2 squares.
noise_relative_to_DMC.png
Measuring the 15 volume settings of the noise channel, divided by linear volume, and normalized relative to the DMC channel producing the same noise at its full volume 127 as "1".
  • My Famicom's noise was slightly quieter relative to the DMC.
  • My NES' noise again has a noticeable discontinuity.
triangle_left_noise_right_both_vs_dmc.png
Triangle (left) and Noise 15 (right) volumes as the DMC counter increases from 0 to 127, relative to volume at DMC 0.
  • The two graphs pretty similar, in isolation, the DMC seems to have almost the same effect on both.
  • Here we see more discontinuity, this time in the DMC DAC, both in the NES and Famicom, but again my NES has it more strongly.
  • The Famicom again is slightly closer to linear.
.

Anyway, that's as far as I got before I guess I got disappointed and lost interest. There are some issues I kinda swept under the rug, noise floor, etc. but with the amount of non-uniformity that was already made clear already in these tests, I didn't see much point in trying to refine them further. There's probably a better way to visualize the results of the tests I did than the graphs above, and there's certainly other tests that could be tried, but eventually I was out of ideas that I felt had any useful promise.

Ultimately I concluded that Blargg's model is good enough, and I didn't have anything better to contribute.
Post Reply