Cleaning up NES audio output

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

Moderator: Moderators

m00dawg
Posts: 22
Joined: Wed Jan 12, 2011 8:53 pm

Post by m00dawg »

Jeroen wrote:that mod linked seems to get the audio from the rf modulator...which will have interference. I would not recommend "rebuilding" the audio path either since it might not sound exactly the same :P (altough yes you could move it out of the way of the ppu)
No it's definitely off the chip itself - that's at least what the video shows. Sound is likely going to be changed because that hex inverter must be doing something there. But beyond that, the audio path juts has some resistors and things on it so it's not terribly complex (or something that can't be duplicated if all else fails).

Re: Turn of TV: I didn't have a TV plugged in while it was on battery power. Same problem with the buzz when using the standard audio out. I could try a laptop, though - I have an Audio4 DJ I use for, well, DJing, that might work so I could use a laptop for that (it's a fantastic USB audio box, by the way, in terms of sound quality - not so great for super low latency recording but it's great for Traktor). I think the PPU theory is probably what's going on there.

Thanks for the help everyone! This is going to be a bit involved I suspect so I'll report back once I have tried a few things :)
User avatar
TmEE
Posts: 960
Joined: Wed Feb 13, 2008 9:10 am
Location: Norway (50 and 60Hz compatible :P)
Contact:

Post by TmEE »

NES audio paths are quite bad, the signal travels between digital sources and right next to PPU and other video circuits, and picks up a ton of noise.

To overcome it you will want to take the sound from CPU, mix it together, amp it a bit (you will have to bypass the CMOS inverter chip which is normally used for amping) and presto. I need to build a NES to FC adaptor and do some photos and recordings...
m00dawg
Posts: 22
Joined: Wed Jan 12, 2011 8:53 pm

Post by m00dawg »

Do you have any information on how the hex inverter is doing it's thing? I thought all it did was invert input (so it would output 1 if it saw a on input 0, 0 if it saw a 1). How does that amplify things? :)

I was wondering if it might be helping to correct any DC offset but I didn't see anything like that in my tests when going off the chip directly. To be fair, I wasn't totally looking for that, either.

The link WhatULive4 is almost perfect. I don't really have to do much of any work there :) But I really wanted an audio out for the PowerPak too. I suppose I can just do that on my own by adding a simple resistor and cap but it's nice to have an all in one package. I am going to contact the developer to see what options they might be able to offer there as well.

Otherwise, yeah, I will build something on my own depending on how much doing the screen blank trick works for the PPU. I decided I don't want to lift any pins off of it on this NES (it's my only one right now) just yet so if that doesn't cut noise down enough, jumping off the chip sounds like the best bet (and is probably a good idea anyway).
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Post by lidnariq »

m00dawg wrote:Do you have any information on how the hex inverter is doing it's thing? I thought all it did was invert input (so it would output 1 if it saw a on input 0, 0 if it saw a 1). How does that amplify things? :)
The inverter's been biased (by the 47K resistor in parallel with it) to act as a high-gain amplifier. The 0.1uF electrolytic capacitor before allows the inverter to self-bias to the right voltage there for maximal gain.

I don't know what kind of voltages come out of it there, but as long as it's not clipping it should be fairly linear.
m00dawg
Posts: 22
Joined: Wed Jan 12, 2011 8:53 pm

Post by m00dawg »

lidnariq wrote:The inverter's been biased (by the 47K resistor in parallel with it) to act as a high-gain amplifier. The 0.1uF electrolytic capacitor before allows the inverter to self-bias to the right voltage there for maximal gain.

I don't know what kind of voltages come out of it there, but as long as it's not clipping it should be fairly linear.
Ah ok. I was able to get sort of an idea of how that works from what you said and Wikipedia. I don't suppose you might have any links or docs to share that might better explain what's going on there? Sounds like I was, more or less, right though.

It seems like it's probably not needed or really should not be involved at all if I wanted to make my own output? I thought the output from the pins was actually pretty good and not in need of much amplification. That was using a mixer before going into my computer though - I haven't tried recording directly in yet. Seems like I did not have to really bump up the volume on the mixer though.

I'm guessing if I wanted to amplify it I can use similar designs, say, from the MidiBox stuff and from the CMoy amplifier? It would be nice if I could cram all that into the NES case but I'm not sure that is totally ideal :) I may just wire up what I need for RCA outs and put the rest on a break-out board or something.

That is if I didn't want to buy the kit mentioned above. I e-mailed the LSDJ folks to see if they had suggestions on the cart-out so we'll see how that goes. Going to wait on making any hardware until I figure that out. And I still need to try the screen blanking trick :)
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Post by lidnariq »

m00dawg wrote:Ah ok. I was able to get sort of an idea of how that works from what you said and Wikipedia. I don't suppose you might have any links or docs to share that might better explain what's going on there? Sounds like I was, more or less, right though.
Don't know of any off the top of my head -- googling for "self-bias" gives me probably all the links you just found.
It seems like it's probably not needed or really should not be involved at all if I wanted to make my own output? I thought the output from the pins was actually pretty good and not in need of much amplification. That was using a mixer before going into my computer though - I haven't tried recording directly in yet. Seems like I did not have to really bump up the volume on the mixer though.
I built the audio path in a sim and I only see a net gain of 2x to 4x, depending on the input impedence (1k, infinite) of your amplifier. (For the inverter I used the equivalent schematic specified by the 74HCU04 datasheet -- a 270 ohm resistor leading to a NFET+PFET pair)

This post is probably the most useful info we have. It's not clear to me how much you'll care about the filtering on the NES output — a highpass at 90Hz and a 2nd-order lowpass at 14kHz.
m00dawg
Posts: 22
Joined: Wed Jan 12, 2011 8:53 pm

Post by m00dawg »

*slaps forehead* I keep forgetting about that simulator :P That thing is super useful, thanks for the reminder! The MidiBox folks also mentioned it so shame on me for not using it as a good resource.

In playing with the sim, I saw about 2x as well, though I am a bit confused as to why the first 2 resistors are there? They squeeze the output (in the sim) down to mV and then it gets amplified again? I assume it has to do with mixing of the two audio pins? For me, I was going to grab the audio from each pin separately anyway.

Either way, it seems like instead of a hex inverter I could just do amplification using some specs from the Cmoy or copy the output specs for the MidiBox SID project and probably be ok? Since I am not going to be mixing, I need 3x of everything to grab all the audio (2 pins of the 2A03 plus cart in) but that's not a big deal to me really.

Doing some filtering might not be a bad idea. It would be nice to approximate the sound of the NES (other than the noise) before I go to record it. But I adjust the EQ and things anyway when mastering so it is not as much of a deal. To me, I did not hear much different between the NES audio path versus the CPU pins in terms of filtering but didn't really spend a lot of time listening to it either (I was mostly just looking for noise).

The biggest issue is making sure I protect the chip from damage when wiring my own solution. Second goal is to eliminate buzzy noise and the third is to, after that, make it as true to the original sound as possible.

Thanks again for all the help everyone! I have visited these forums for a few years now and have been able to get some amazing information! It is nice to see everyone being so helpful to a newbie poster! :)
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Post by lidnariq »

m00dawg wrote:In playing with the sim, I saw about 2x as well, though I am a bit confused as to why the first 2 resistors are there? They squeeze the output (in the sim) down to mV and then it gets amplified again? I assume it has to do with mixing of the two audio pins? For me, I was going to grab the audio from each pin separately anyway.
The outputs are the two audio pins are a little weird, as you might guess from the 100 ohm resistors to ground. IIRC, the pins there are pull-up-only DACs and the resistors are cheap "current sources", so there's some nonlinearity there. The use of resistors two orders of magnitude larger is probably to allow them to pretend no current goes through them in comparison to the 100 ohm pull-down.
Either way, it seems like instead of a hex inverter I could just do amplification using some specs from the Cmoy or copy the output specs for the MidiBox SID project and probably be ok? Since I am not going to be mixing, I need 3x of everything to grab all the audio (2 pins of the 2A03 plus cart in) but that's not a big deal to me really.
Are you actually using any carts with audio in? The only carts released in the US that even could have supported it were the MMC5 ones, and because the audio path wasn't connected on the NES mainboard no-one wrote games using those extra channels.

Using something like the Cmoy circuit would be ok, but getting bipolar 9V will be a little silly. You probably could just use the right opamp (single-sided rail-to-rail?) and be done with it. Depending on what you're plugging into and what your input impedence is, you might even just use protection diodes and a current limiting resistor on the pins and directly hook those into your sampler.
Doing some filtering might not be a bad idea. It would be nice to approximate the sound of the NES (other than the noise) before I go to record it. But I adjust the EQ and things anyway when mastering so it is not as much of a deal. To me, I did not hear much different between the NES audio path versus the CPU pins in terms of filtering but didn't really spend a lot of time listening to it either (I was mostly just looking for noise).
If you'll be remastering it anyway, you may as well bypass the original filtering on the NES anyway and do it in post.
m00dawg
Posts: 22
Joined: Wed Jan 12, 2011 8:53 pm

Post by m00dawg »

The cart in is mostly for the PowerPak though if it sounds a lot better I could use the same mod for my Castlevania 3 (JP) cart. The reason I wanted to record the PowerPak is that, even though the PowerPak does not use the original chips, it seems to do a better job of emulating them than FamiTracker.

I suspect it's all in my head or the result of the lower 8-bit output of the NES or something like that. FamiTracker sounds too clean and not as dynamic as the PowerPak.

As far as mastering, I tapped the pins directly I think last week and, yeah, it sounded pretty good. I read online that using an electrolytic helps add protection but I'm not sure if a diode is better or not, or how that works to be honest :) I do know that pin 1 at least sounded as clean as silk. pin 2 was more noisy (slight buzz) but not bad.

So yes, the goal is really to protect the chip and provide clean audio. If the levels are not quite right that's fine as long as, individually, the audio is correct. I can (and have to) balance the audio when I go to master it anyway. The filtering caps I don't mind if I could get them close to what the NES filters are doing.

The thought had crossed my mind to buy two of those audio amp kits mentioned earlier - one would be for the 2A03 and one for the single cart out. Expensive but if they work well, probably easier to do since I have other hardware projects on my plate as well :)
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Post by lidnariq »

m00dawg wrote:As far as mastering, I tapped the pins directly I think last week and, yeah, it sounded pretty good. I read online that using an electrolytic helps add protection but I'm not sure if a diode is better or not, or how that works to be honest :) I do know that pin 1 at least sounded as clean as silk. pin 2 was more noisy (slight buzz) but not bad.

So yes, the goal is really to protect the chip and provide clean audio. If the levels are not quite right that's fine as long as, individually, the audio is correct. I can (and have to) balance the audio when I go to master it anyway. The filtering caps I don't mind if I could get them close to what the NES filters are doing.
Try this circuit-

Code: Select all

            pin      
             |    
gnd ---|>|---+---|>|--- vcc
             |
             R ~1k
             |
          sampler
This a standard CMOS-protecting voltage clamp. The schottky diodes (faster and leakier than ordinary diodes) will dump over/under- voltage onto the rails in case of static (or plugging something bad in). The output impedence of 1k will limit current into the diodes and shouldn't cause attenuation for most typical sampler input impedances. Replacing the diodes with a 5V zener from ground would also be okay. I don't know anything about using electrolytic capcitors for transient suppression; briefly googling implies ceramics are better for that.
m00dawg
Posts: 22
Joined: Wed Jan 12, 2011 8:53 pm

Post by m00dawg »

I put that in the simulator and it seems to work, but why would I not use a diode off the pin? Wouldn't reverse voltage from the output still end up flowing back into the pin? I thought that was basically what I was protecting against there (as well as shorts to ground and stuff). Went to Wikipedia and didn't find much I actually understood about what's going on :)

The electrolytic cap was mentioned on one of the PowerPak mod sites. I can try to go hunt it down if need be. I noticed the MB-SID output (available here) uses an electrolytic but also has a few smaller ceramic caps. That output pipeline uses a transistor (I guess similar to the original NES there) which I am guessing is some sort of op-amp type of thing?
User avatar
Super-Hampster
Posts: 185
Joined: Fri May 12, 2006 4:40 pm

Post by Super-Hampster »

You can't pass audio through a diode. It's a rectifier and only allows DC current to flow. And since audio signals consist of an AC current with varying frequency A diode only allows current to flow in one direction. So since AC requires the ability to flow in both directions you would get no audio output.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

NES audio is unsigned. This means the negative and positive rails are on the same side of ground.
User avatar
Super-Hampster
Posts: 185
Joined: Fri May 12, 2006 4:40 pm

Post by Super-Hampster »

To test that I just tried it. It didn't work. Touched the wire minus the diode to the NES sound output and heard NSF playing on powerpak. Put diode in between in either direction and no audio. I tried it once before to with VRC6 output from aukamujo densetsu and it didn't work either. I learned it the hard way although I should have remember from school that it wouldn't work. I was testing ways to include extra audio in the stereo mod so I could mix it in with both channels without it causing the channels to remix. Diodes proved to be impossible way to keep the channels separate because they wouldn't pass the audio.

I haven't tried it straight from the CPU however. I've only tried it from the audio out pin.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Post by lidnariq »

m00dawg wrote:I put that in the simulator and it seems to work, but why would I not use a diode off the pin?
The point of the circuit above is to protect against static discharge, which can be thousands of volts in either sign. A single diode into or out of the pin would only potentially protect against one or the other charge, not both simultaneously.
Wouldn't reverse voltage from the output still end up flowing back into the pin? I thought that was basically what I was protecting against there (as well as shorts to ground and stuff). Went to Wikipedia and didn't find much I actually understood about what's going on :)
By having two diodes there, one from ground, one to +5v, we guarantee that a voltage that is too high or too low can go somewhere rather than through the NES CPU itself. The idea is "+large volts goes through resistor, through diode, to +5V; -large volts goes through resistor, through other diode, to 0V". Also "resistor guarantees that shorting out output doesn't damage NES CPU either."
The electrolytic cap was mentioned on one of the PowerPak mod sites. I can try to go hunt it down if need be. I noticed the MB-SID output (available here) uses an electrolytic but also has a few smaller ceramic caps. That output pipeline uses a transistor (I guess similar to the original NES there) which I am guessing is some sort of op-amp type of thing?
For the SID audio stage there, the 10uF capacitor C5 and 1uF capacitor C6 are DC blockers so that the sampler and SID get a 0VDC-centered signal. But they're not protecting anything.
Super-Hampster wrote:You can't pass audio through a diode. It's a rectifier and only allows DC current to flow. And since audio signals consist of an AC current with varying frequency A diode only allows current to flow in one direction. So since AC requires the ability to flow in both directions you would get no audio output.
One, you're assuming a circuit topology different than I specified above — I never wanted the audio to go through the diodes. Two, audio can flow through a diode — how do you think a crystal radio works? The audio signal out of the NES has both a DC and AC component, it's not centered on 0VDC; while -3V doesn't** flow through a diode, both 1V and 5V flow through a diode, and a signal that's 3V+2V*sin(t) will pass just fine. (And probably come out looking like 2V+2V*sin(t))
Super-Hampster wrote:To test that I just tried it. It didn't work. Touched the wire minus the diode to the NES sound output and heard NSF playing on powerpak. Put diode in between in either direction and no audio.
Of course that didn't work, the diode wasn't forward biased.
Diodes proved to be impossible way to keep the channels separate because they wouldn't pass the audio.
But a bunch of sufficiently large resistors should have worked fine.
I haven't tried it straight from the CPU however. I've only tried it from the audio out pin.
Yes, looking at the audio path the DC component is removed by the NES audio filter — that's the point of the 10uF capacitor in the image I posted at the top. This won't work on the white jack out the back. Two, putting a diode in series likely won't work even out of the NES CPU itself, because most diodes have a minimum forward voltage of 0.6V and the NES audio is probably less than that.

** actually, negative voltages do flow a little bit.
Post Reply