NES Sound Format

Nintendo Entertainment System Sound Format
Filename extension .nsf
Developed by Kevin Horton
Type of format Music file

NES Sound Format (NSF or .nsf) is the filename extension of the audio file format originally designated as NESM (Nintendo Entertainment System Music) by the inventor Kevin Horton. This format was originally designed for playback in a custom hardware device named HardNES by the inventor. Over the years, the NSF format has been implemented for playback on many platforms via plugins, stand-alone players, emulators and also the NES PowerPak.

The particulars of the NSF format resemble the SID format loosely, where a header is prepended and then the original audio data follows. The original audio data commonly has been extracted from a ROM image or disk image and then modified for stand-alone playback by various players. The original audio data is also commonly referred to as an audio driver or music engine. The audio driver is then completely isolated from the rest of the code, data and graphics that have nothing to do with the audio driver. A complete NSF is considered a multiple song and sound effect container for one particular game or composition.

Platforms and chips

The following 6502 platforms with a RP2A03/RP2A07 microprocessor including some clone units are compatible with the NSF format and current NSF players. These platforms can be PAL or NTSC or dual PAL/NTSC from any region. There are exceptions to the rule where if any part of a platform that has another microprocessor such as the Zilog Z80 will not be supported.

The following chips and components are supported in the NSF specification.

NSF format supports all five normal audio channels of the APU as well as the other audio expansion chips previously listed.

NESM header specification

As said earlier, the NSF header is prepended to the original audio data and code. The header was designed to be as flexible as possible and to allow for hardware and emulation playback. The header supports three specific addresses; the first one is the beginning address of the audio data, the next two are entry points to the play and initialization code respectively.

The header supports PAL, NTSC, dual PAL/NTSC and also allows to adjust the playback speed. This playback speed is not meant to be used to adjust the speed of songs in a rip, but to account for various units with a microprocessor speed that is not considered standard, such as many clone Famicom/NES units from China. Be aware that some players do not support the playback speed.

The header also has an extra sound chip support setting for six expansion chips listed above. No commercial game ever used more than one expansion sound chip. However, many fan compositions do use up to all expansion sounds chips in the NSF format.

The header also has a total number of songs. However, this setting has a limit for 256 songs. In most cases you will never reach this limit.

There are also three slots for name of song, artist and copyright holder. Each one of these has a limit of 32 ASCII characters.

Bankswitching is also supported in the header format. The bank size select is 4KB for a total amount of FF(256) banks or a maximum limit of 1MB. There are 8 bank switching bytes, each one supports a 4KB section of the memory range used which is $6000 - $FFFF depending on if normal or FDS bankswitching is used. These bytes are the initial setting for banks to be loaded on reset.

NSF 2

Currently, NSF is at version 01h. NSF version 2 is a proposal that has been in discussion for a few years and has not been finalized yet. The reason why version 2 has been proposed is because the current NSF format does not support every possible configuration of a NES audio driver, which means that there are some NSFs that cannot be ripped without extensive hacking and it is impossible. There are also a handful that need to be reripped for this format.

The general idea is to support an initialization routine that never returns, IRQ and a proper NMI instead of a play entry point address call. Generally speaking, the initialization routine should return in 4 or less frames. If the routine does not return in time or not at all then the NSF will not play. The reason why you would need a non-returning routine is for PCM playback and a few NSFs that require a non-returning initialization.

There are some audio drivers that have a play call in the NMI as well as audio code in the IRQ. Since the NSF format currently does not support an additional IRQ address setting, those rips will not play either without extensive modification.

There are only approximately 40 games that require this function to be ripped properly in NSF format. So, it is unknown as to when this format will be finalized. Quietust has implemented some features of this proposal in his emulator Nintendulator which allows both Battletoads and Battletoads & Double Dragon to play with raw PCM drums. There may be other players that support the watch-dog timer and/or non-returning features as well.

NSFE

NSFE is a 4-character file name extension for a new Extended NSF format. This format was extended by Disch and initially for his NSF Winamp plugin called NotSo Fatso as an extension to the original NSF format invented by Kevin Horton. NSFE was also created to add additional functions to NSFs such as timers for songs, fade-out time, arrange songs in a playlist, labels per song, the person who ripped the NSF and several other features. Since NotSo Fatso supports nearly every feature of the NSF format including all expansion chips, NSFE quickly gained in popularity. In order to implement these additional features, the format is chunked based. Thus, it's not ideal or possible to implement on any type of Famicom/NES hardware or FPGA type system without extensive modification. Despite this, the NSFE format shines on modern PC emulation platforms.

NSF hardware players

HardNES is the first NSF hardware player invented by Kevin Horton that is run by a NES CPU and a FPGA. It features a LED, stereo sound and 128 KB RAM chip which contains all the RAM used by the control system and the emulated ROM space that is bank-switched. The maximum NSF size would be under 128 KB.

CopyNES NSF Cart is another invention by Kevin Horton. The NSF Cart is used in combination with a CopyNES. The NSF file is transferred to the CopyNES and then to the NSF Cart for NSF playback. The maximum sized NSF for the original cart is 128 KB. It may be possible to install a larger RAM chip to play back larger NSFs.

NES PowerPak is a NES cartridge that has a CompactFlash card port that enables the transfer of ROM images to this cart. The 512 KB RAM chip and the FPGA circuits allow this cartridge to be flexible enough to support many iNES mappers including the NSF specification. As of 3/25/2012 the PowerPak's NSF mapper emulates the expansion audio of FDS, VRC6, and N163. Also, since the NES PowerPak's smallest bank size select is 8 KB and the NSF bank size select is 4 KB, there is a trick involved that effectively doubles the 4 KB banks but also limits the maximum NSF size to 252 KB.

The TNS-HFC series is a hardware NSF player for the Famicom manufactured by Terra Network Systems, a company based in Japan. The latest model is the TNS-HFC5. It allows NSFs stored on the root directory of an SD card (Up to 32GB SDHC supported) to be played on a Famicom. When the Famicom is powered on, the TNS-HFC will load the first NSF in the SD card's root directory; pressing the "next" and "previous" buttons on the cart itself will load the next or previous NSF in the root, while pressing the B or A button will load the previous or next track within the NSF file itself. The device's design makes it possible to operate it without the need for any video output whatsoever. The TNS-HFC has its own 3.5mm audio jack to capture audio directly from the cart. This is Terra Network System's solution to the problem where the Famicom does not offer audio/video output natively, which would make audio capture difficult otherwise. The unit offers the ability to play Sunsoft5B NSFs without the need of a Gimmick! cartridge and allows the user to independently set the volume of the Famicom APU and an on-board YMZ294 which takes the place of the Sunsoft5B. NSFs up to 512 KB will usually load without any issue, though large files that use 7-bit PCM can be problematic.[1]

No expansion audio cartridges can be used with the TNS-HFC5 normally, however Terra Network Systems also manufactures the TNS-HFX4, whose riser board one would plug into the 60-pin female connector of a Famicom, and in turn connect the TNS-HFC5 to a 60-pin connector on the back. This unit has a ribbon cable running to a larger board capable of holding up to 4 additional cartridges, including the Famicom Disk System RAM Adapter (although an external 5v DC source is required), along with an on-board YMZ294 and YM2413. Its predecessor is the now discontinued TNS-HFE4.[2]

NSF music composition

The NSF format is popular among composers of chiptune music. There is international interest in new NSF composition, and there are competitions such as the annual FamiCompo series of competitions. The number of original compositions is beginning to rival the number of current commercial NSF game extractions.

There are several trackers available for the composition of NSF music:

There are also options to compose in standard trackers to output NSF music:

Additionally there is an MML variant known as ppMCK MML for composing NSF music as a text file that is compiled. Since January 2011, there is an online community called MMLShare dedicated to composing and sharing such files directly within the website.

See also

References

This article is issued from Wikipedia - version of the Thursday, July 02, 2015. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.