Emulator settings for most accurate sound emulation?

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Post Reply
The End
Posts: 2
Joined: Sun Sep 05, 2010 10:07 am

Emulator settings for most accurate sound emulation?

Post by The End »

Pardon my n00bishness...
I've searched google, emulator forums, read through tech docs and NESSOUND.txt, etc...but I'm still not 100% sure on this. You guys are ultimately THE council of wisemen when it comes to this stuff, so I figured that if anyone would have the answer it would be you.

I'm trying to get as accurate sound as possible out of Nestopia, and I'm using an X-Fi sound card with "bit-matched playback". This playback mode supposedly matches the sample rate of the source without any upsampling or sketchy conversion; the idea is to output the most accurate sound. Unfortunately, I don't know what the sample rate or bit depth should be set to in the emulator in the first place.

Like I said, I'm using Nestopia, and Nestopia's archived forums don't offer much in the way of a definitive answer on this AFAIK.

The X-Fi's max sample rate is 96000 hz, 16-24 bit (would 8-bit sound simply be converted to 16 bit anyway?).

Nestopia's default is 44100 and 16 bit, but considering my hardware is this really the most accurate solution? I've been trying 96000 and 8-bit, but I'm not sure it's the way to go... So what should the settings be for the most "accurate" emulation?
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

The exact sample rate of the NES audio DAC itself is 39375000/22 Hz = 1.7898 MHz. It goes through an analog band-pass filter to reject DC and ultrasonic frequencies, and the emulator has to simulate this filter. I doubt that even an X-Fi can bit-match 1.7898 MHz. So let's pretend an emulator uses blargg's band-limited downsampler to downsample the APU output by a factor of exactly 32 to 1. Then the output becomes 55930.4 Hz.
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

We must also pretend that the output rate even matters (as long as it's 44 kHz or higher), if one is using an emulator with a decent resampler. I don't know what Nestopia uses though. One thing's for sure, you don't want to set your sound card to 8-bit output.
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Nestopia uses linear interpolation.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
User avatar
Bregalad
Posts: 8036
Joined: Fri Nov 12, 2004 2:49 pm
Location: Caen, France

Post by Bregalad »

Haha, this remembers that back when I was a total noob, I trought it was better to put the output to "8-bit" because the NES was a 8-bit system. That was ridiculous at best.

I don't think the ear can do much difference above 48 kHz in fact most (if not all ?) soundcards use this as the output sample rate anyway, and trying anything else will be down-sampled. I might be wrong though.
Useless, lumbering half-wits don't scare us.
User avatar
cpow
NESICIDE developer
Posts: 1097
Joined: Mon Oct 13, 2008 7:55 pm
Location: Minneapolis, MN
Contact:

Post by cpow »

Dwedit wrote:Nestopia uses linear interpolation.
This statement confuses me. Linear interpolation? Maybe I'm just having a math-idiot moment, but...linear interpolation between what and what?

If the APU in question is cycle-accurate, you will generate 1,789,772 DAC samples for each of the five channels per second. Linear interpolation implies finding the value between, say, DAC sample 983,345 and 983,346...a meaningless value unless you want to *up*sample?

To generate an output audio sample, the method I use I guess I would call downsample-averaging [just plain downsampling?]. I create 16 DAC bins for each of the four 4-bit DAC channels and 128 DAC bins for the DMC. There are approximately 40.58... DAC samples per required output audio sample. Each time the emulated APU runs a cycle [and thus generates a DAC sample] I increment the DAC sampling bin corresponding to the DAC value and channel. When it comes time to generate the appropriate channel DAC values for generating an output audio sample, I do:

Code: Select all

avg = 0; tot = 0; dac = 0;
for ( i = 0; i < 16 or 128; i++ )
{ avg += dacbins[i]*i; tot += dacbins[i]; }
dac = avg/tot;
for each channel. Then I clear the bins.

Am I being too picky or are there other interpretations of lerp?
tepples
Posts: 22345
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

What you're doing appears to be equivalent to a low-pass box filter.
The End
Posts: 2
Joined: Sun Sep 05, 2010 10:07 am

Post by The End »

Bregalad wrote: most (if not all ?) soundcards use this as the output sample rate anyway, and trying anything else will be down-sampled. I might be wrong though.
X-Fi (real) sample rate is 96khz, and it's been around for several years now.

Thanks for the feedback guys, I was a dolt for choosing 8-bit sound. Right now I'm waffling between 48khz and 96khz...I'm just not sure....damn I'm anal when it comes to emulation.....
User avatar
blargg
Posts: 3717
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

If your goal is settings that produce meaningful results, then put them to the test. See whether you can hear a difference between the two. If they're close, you might need a way to do a blind test, otherwise your knowledge of which rate is selected might affect your perception of quality. If you hear no difference, then you don't need to spend any time bothering with the rate.
ReaperSMS
Posts: 174
Joined: Sun Sep 19, 2004 11:07 pm

Post by ReaperSMS »

Using a 96KHz sample rate isn't about getting more audible data in (you can't hear anything past 20KHz or so, 22KHz if you're a freak of nature) it's about getting more headroom for filtering.

If the sampler is running at 96KHz, the transition band for the lowpass filter on the input gets to range from 20KHz to about 76KHz. Sampling at 44KHz means your transition band only goes from 20KHz to 24KHz.
User avatar
Dwedit
Posts: 4470
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Nestopia uses linear interpolation, so the more samples, the merrier. But if you can do a good lowpass to remove what humans can't hear (like what Blargg's library does), that could be saved at any sampling rate above 44100 with no loss.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
Post Reply