what is the cut off freq of the nes ?

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

mattmatteh
Posts: 345
Joined: Fri Jul 29, 2005 3:40 pm
Location: near chicago

what is the cut off freq of the nes ?

Post by mattmatteh »

is the cut off frequency for the high pass and low pass of the nes known ? if so, is the gain or frequency response known ?

i am familiar with digital signal processing from school, had an intro to it, but have not looked at it in a while.

i am still working on getting sound working in my emu. i know blargg wrote blip but wanted to see how much i could do on my own to learn. might infact do what that does, but would like to learn it :)

matt
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Post by lidnariq »

Image
http://nesdev.com/NESAudio.gif

Although we have to model it in discrete time in our computers, the NES generates the audio at ~1.8MHz and goes through a mostly-but-not-completely linear output stage as you can see in that image.
mattmatteh
Posts: 345
Joined: Fri Jul 29, 2005 3:40 pm
Location: near chicago

Post by mattmatteh »

i have seen that. i guess i wasnt sure what exactly come out of pin1 and pin2. i didnt know if anyone had the numbers. my electronics skills are not that good and not sure i would be able to determine the cut frequencies of that or the gains. i know there is a non linear mixing equation on the wiki and other sound docs, i assume that includes the internal and external mixing on the nes.

thanks
matt
User avatar
kyuusaku
Posts: 1665
Joined: Mon Sep 27, 2004 2:13 pm

Post by kyuusaku »

I see a bunch of low pass filters, there's:

-one made by the 220pF cap before the inverting amp and the audio output Z
-same cap making a low pass filter with the interting amp's feedback resistor (47K & 220pF)
-capacitor feedback on the inverting amp making an integrator/active LPF?
-one made by the series inductor and the following cap (39uH & .01uF)
-one made on the output (150R & 47pF)
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

The raw internal output from the 2A03 on the two pins is very likely unfiltered. The non-linear mixing doesn't do any filtering either. So it's all after that, as kyuusaku detailed above.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

I've made recordings of 1 kHz square waves and noise played through the NTSC frontloader's RCA audio jack, if those help any.
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

The problem is that this also includes your sampler's low-pass (and high-pass) filtering. Making recordings of the raw 2A03 output pins AND the RCA output would allow them to be compared to find out the filtering done, though I never could figure out how to quantify it well. I think one uses an impulse to determine this, i.e. a pulse as short as possible, that still results in significant amplitude. An impulse contains all frequencies of equal amplitude, so running it through a spectrum analyzer (Fourier Transform) shows any filtering that was done to it, as well as any phase shifts.
mattmatteh
Posts: 345
Joined: Fri Jul 29, 2005 3:40 pm
Location: near chicago

Post by mattmatteh »

is there a high pass filter in there too ?

right now i am dumping audio to a file and looking at it in audacity. its unfiltered at the moment and have been filtering in audacity. i was just wondering what the low and high frequency is, and rolloff.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

mattmatteh wrote:is there a high pass filter in there too ?
I'm pretty sure the NES has a high-pass filter of some sort on its RCA audio output. I saw a high-pass characteristic in the recordings I mentioned, and it's probably not entirely the PC because the sound card (an SB Ensoniq AudioPCI) has picked up rumble as low as 5 Hz from my desk mic.
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

The 1 uF capacitor just after the mixer and the 10 uF capacitor just before the audio output should do some high-pass filtering.
User avatar
kyuusaku
Posts: 1665
Joined: Mon Sep 27, 2004 2:13 pm

Post by kyuusaku »

Perhaps instead of using the APU's output, it would be easier to lift the mixing resistors and use a computer's line out?
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

Then you get the filtering the computer's line out has. :)

I think the NES can generate good impulses with frequency content well above 20 kHz, we just need to be able to do something useful with the result. I had tried this a while back but never got anything useful. I think another issue is that the more into the PC's low-pass rolloff you go, the less you can determine the rolloff of the NES filter; when you reach the PC's cutoff, you obviously can't determine anything about the NES. Here's a recording of the raw output from the 2A03 (left channel), and the RCA (right channel):, with levels adjusted so the second wider pulses have the same initial delta

nes_raw_rca.wav

I don't have very good analysis tools, so perhaps someone else can compare the two to determine the filtering occurring between them, which would be what the NES output amplifier circuit does.
frantik
Posts: 377
Joined: Tue Mar 03, 2009 3:56 pm

Post by frantik »

blargg I can analyze the sound but it would be useful if the recordings of each type were a bit longer.. like a second or more of white noise coming from each output?

also if you could record at a high sample rate it will show how high up the response goes


I checked out tepples recordings and the white noise appears to be pretty flat all the way up and past 20kHz in the NES-001.ogg file (which i assume is an acutal nes)
User avatar
blargg
Posts: 3715
Joined: Mon Sep 27, 2004 8:33 am
Location: Central Texas, USA
Contact:

Post by blargg »

I'm not sure I can get white noise. I do now see that an impulse isn't that great for determining high-pass, but for low-pass it's good; perhaps the step response will be best for determining high-pass. I re-recorded some that were in like phase (where the impulse falls relative to the sampler affects things). Black is the raw output from the 2A03 (and thus shows the low-pass of my PC's sampler), red is the RCA, and blue is with a one-pole filter with coefficient ~0.816 applied to the raw, which closely approximates the RCA. The frequency scale is linear from 0 to 22050 Hz (my sampler won't do any higher, sorry).

Image

The filter that seems to approximate low-pass characteristics is just out=(in-out[i-1])*0.815686.

EDIT: And for high-pass, using out=out[i-1]*k+in-in[i-1] twice, with k=0.996039 and k=0.999835 seems to approximate it well (step response, red is NES RCA, blue is raw run through above filter):

Image

Perhaps someone can confirm that these two constants match the R-C high-pass filters in the schematic.

EDIT: And of course the above iterative filter equations are run at a 44100 Hz sampling rate; other rates would use different coefficients.
Last edited by blargg on Sun Mar 15, 2009 11:38 am, edited 1 time in total.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Post by lidnariq »

blargg wrote:Perhaps someone can confirm that these two constants match the R-C high-pass filters in the schematic.
The k=.999835 HP is a time constant of 1700us, and it corresponds to the very last output stage -- the 150ohm resistor and 10uF cap (corner freq=90Hz).

The k=.996039 HP is a time constant of 360us, I haven't yet found what it corresponds to. (corner freq=442Hz)
(edit: This might correspond to the 47k on the resistor through the inductor and the .011uF of capacitors, or the .011uF of capacitors and the 270ohm resistor after the BJT with its resistance amplified by the BJT (appx a factor of 200).)

The k=.815686 LP is a time constant of 11us, the 47kohm and 220pF lowpass around the inverter-used-as-an-amplifier (corner freq=14kHz).

(The time constant for the LC seems to be faaaaar above audible frequencies, time constant=654ns -> corner freq=243kHz)
Post Reply