2
\$\begingroup\$

First, I'm not asking about details regarding the layout and format of an NSF file. The original spec (see here) covers most of the information that I need regarding finding the data associated with each track.

My question is that once I've loaded an NSF and consumed the header, how can I meaningfully interpret the data for audio playback? I've found multiple sites that talk about the NSF format, but I've yet to find a site that explains how the data can be used once the file has been dissected into all of it's components. How do I read and prepare this audio information for playback?

I'm not looking to emulate an NES device but I would like to pull out the raw audio information (or calculate/convert the information to raw audio data.)

For those who are interested, this is for a personal fun project. I'd like to dissect some of these sound-bytes and convert them to audio that I can manipulate within my own application. I'm completely new to audio processing but I've done my share of low-level work. This seemed like a fun project where I'd be jumping in way over my head but I'd have fun trying to figure out all that I want to accomplish.

To start, though, I need to get audio data that I can manipulate from sources that I am interested. in this case it's NES carts. Since the cartridge data is already available in NSF files, I figured I'd dissect the NSFs rather than the ROM files for audio content.

Apologies if this questions is to big for a simple specification of data layout. Any answer that can point me in the right direction is what I'm looking for.

\$\endgroup\$
  • 1
    \$\begingroup\$ Try to look at the FamiTracker's source code. \$\endgroup\$ – Ocelot Jul 10 '15 at 12:56
  • \$\begingroup\$ That could work. It is written in Assembler though. If I have to look at source for a spec, I was hoping to use something a little more high-level than that. (But I can work with ASM if I has too.) \$\endgroup\$ – RLH Jul 10 '15 at 17:11
  • \$\begingroup\$ @RLH Erm, you DON'T want to work with ASM, really... \$\endgroup\$ – Alexandre Desbiens Jul 10 '15 at 17:12
  • \$\begingroup\$ Meh, I'm nerd enough. When I get bored I dig into ILDASM simply because my day job has me writing C#. If I have to use a runtime, might as well learn as much about it as I can. I know that assembler is much different but I'm not "skeered". Now, I'm not saying I want to write in it, but I'm not afraid to decompose it. It's just to time consuming. :P \$\endgroup\$ – RLH Jul 10 '15 at 17:15
2
\$\begingroup\$

Looking at the spec you linked it seems like you'd need to write an emulator for the NES's sound systems at the very least. The NES uses a highly documented 6502 which should be easy to get some info on.

https://en.wikipedia.org/wiki/MOS_Technology_6502

There are many many articles and guides surrounding NES development. I suggest pulling a find on the phrase "6502 instruction decoding & execution techniques" on this document: http://nesdev.com/NES%20emulator%20development%20guide.txt

To playback sound from .NSF formatted files you'll need to emulate the 6502 to synthesize the squarewaves to send to your sound card.

This may not be the best place to start with audio manipulation but it's certainly a cool project. You should be able to find more info on the subject by searching for more info related to the 6502 and NES emulation in general.

As @Ocelot mentioned Famitracker might be a good project to check out. Maybe ask around for some resources in the famitracker irc: http://irc.lc/esper/famitracker/irctc@@@

\$\endgroup\$
  • \$\begingroup\$ Yes, I guess I could dig into the emulator documentation. I'm familiar enough with WAV/RIFF format. My hope was that track data had minimal information regarding looping/fading and was a basic form of sound byte streams. Guess it's probably not. \$\endgroup\$ – RLH Jul 10 '15 at 17:26
  • \$\begingroup\$ The spec you linked mentioned that the sound data is data that you fill in the 6502's memory. The 6502 then reads that data and synthesizes square waves. \$\endgroup\$ – Honeybunch Jul 10 '15 at 17:32
  • \$\begingroup\$ The size of a NES game is measured in kilobytes, sampled audio was very rare and only used for special special effects that couldn't be produced by synthesis. In many games, you'll see particular channels of the music dropping out to provide a channel in which sound effects are made on the fly. \$\endgroup\$ – Lars Viklund Aug 10 '15 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.