Combining snd 1 and snd2

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
Combining snd 1 and snd2
by on (#76408)
How does the NES combine both of these pins into one output? I am building a small homebrew computer out of the NES 2A03, and would like to use the ALU for sound.

If I try to tie both to one line, the other cuts out. Currently I have SND 1 connected to a LM386 amplifier. If I can do it with only one amp that would be great.

Edit: Just looked at the schematic, so it just two resistors to ground and two that connect into each other?

by on (#76410)
Here's the audio path schematic, if you haven't seen it.
http://nesdev.com/NESAudio.gif

A homebrew computer with the 2A03 would be cool. I'm curious, what speed are you running it at? That will affect the audio frequencies, of course. And I wonder if you mapped something into the $2004 address, if you could do a sprite-DMA to it.

by on (#76417)
It is running at 20mhz (couldn't find a ossilator at the 21.----mhz speed). I am a amateur when it comes to circuitry, doing it for fun as a side project for one of my CompSci courses.

Anyway, since I didn't have the right resistors on hand (and I am a huge noob with analog circuits) I did some trial and error, and got it working, though it's kinda fuzzy. I found a sample music program on nesdev, and it's currently playing music :D!!!

The SND2 pin seems to really lower the total signal, but a 10k ohm resistor seems to lower SND2 enough. The audio quality is really fuzzy, but it's probably the amp circuit.

I haven't done much sound programming with the nes (played around with the PPU and other hardware though), so I am not sure how the timers work. Currently I run the play sound routine in a infinite loop, with a billion nops to slow down the cpu. What is the proper way to time it? Is it a IRQ call or something?

by on (#76420)
Ioncannon wrote:
I haven't done much sound programming with the nes (played around with the PPU and other hardware though), so I am not sure how the timers work. Currently I run the play sound routine in a infinite loop, with a billion nops to slow down the cpu. What is the proper way to time it? Is it a IRQ call or something?

Most of the games use the NMI (PPU vblank) for that. I guess you could use the APU's frame IRQ since you don't have a PPU, but the frequency wouldn't be 100% correct.

More info here: http://wiki.nesdev.com/w/index.php/APU_Frame_Counter

by on (#76433)
20.000 vs. 21.477 will produce differences not unlike the difference between PAL and NTSC pitches. But a 21.477 MHz crystal is six times the NTSC color subcarrier frequency. Don't they still make crystals for that, or perhaps half that? Or are all the color burst crystals 4*Fsc = 14.318 MHz instead?

I guess in a system without a PPU, VDP, or whatever the kiddies are calling it now, the APU Frame Counter is as good as any.

by on (#76438)
tepples wrote:
Don't they still make crystals for that, or perhaps half that? Or are all the color burst crystals 4*Fsc = 14.318 MHz instead?
Digikey nominally has a few at 6x, but none are currently stocked. In fact, they only have 1x, 2x, 4x, and 8x crystals purchasable in small quantity. (They also have 25MHz crystals, which are 0.2% slow of 7x)