Sound Output

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems. See the NESdev wiki for more information.

Moderator: Moderators

Post Reply
SkyRender
Posts: 4
Joined: Thu May 05, 2005 12:08 am

Sound Output

Post by SkyRender »

Is anyone familiar with a simple way of doing sound output on the NES? What I'd like is a way to implement music or sound effects. All the docs I've found on the 'net are in japanese, so I'm kind of in the dark here.
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers »

If you don't want to write your own music code, you can use NT2 (http://nesdev.com/nt2/). To get sound effects you can modify the player code to write to RAM instead of the sound registers, that way you can pre-empt the channels with your own sound effect code.

Most of the Japanese docs are probably about MCK, it's another simple way to make music. But the player code uses a lot of memory when I checked last, it might be tougher to use it inside another program.
SkyRender
Posts: 4
Joined: Thu May 05, 2005 12:08 am

Post by SkyRender »

I guess what I'm trying to ask is "how do I play music?", or "how do I play a sound effect?" I'm not trying to do anything overly complicated here. Thanks for you help so far.
User avatar
Memblers
Site Admin
Posts: 4044
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers »

You have to make your own data format (or use an existing one, but there isn't one specifically for sound effects), then have a player program that decodes it and outputs it to the NES sound registers. The player code would be ran every frame (60 times a second). Normally there's a second subroutine to be called for initializing a particular song/effect before playing.

Here's a reference on the registers.
http://nesdev.com/wiki/?page=NES+APU

This is pretty much how the NSF format works too. If you have memory free in the areas the NSF code uses, you can include it in a program and JSR to the play and init routines, and it works. I did that a lot myself with NT2 before I changed the player code to work with the assembler I normally use.
Post Reply