====== NSPC File Format ====== NSPC is a file format used by Herringway's [[https://github.com/Herringway/nspcplay|nspcplay]] designed to contain all the data necessary to play music from Nintendo's Kankichi-kun/N-SPC music format. ===== Structure ===== An NSPC file contains a simple header, followed by a number of variable-length audio packs, followed by optional FIR coefficient tables and [[https://mutagen-specs.readthedocs.io/en/latest/apev2/apev2.html|APEv2 tags]]. At minimum, an NSPC file is expected to contain a single sequence, instruments, BRR sample data and a sample directory. ===== Header ===== The header is 32 bytes long. ^ Offset ^ Size ^ Purpose ^ Description ^ | 0 | 4 | Variant | Identifies the variant of NSPC. See valid identifiers below. | | 4 | 2 | Sequence address | The SPC700 address that the song's sequence data is loaded to. | | 6 | 2 | Instrument table | The SPC700 address that the song's instrument table is loaded to. | | 8 | 2 | Sample directory | The SPC700 address where the BRR samples are expected to be found.| | 10 | 1 | Release table | The id of the release table to use. | | 11 | 1 | Volume table | The id of the volume table to use. | | 12 | 19 | Variant-specific | Variant-specific data. See variant information for details. | | 31 | 1 | FIR coefficients | Number of FIR coefficients embedded in file. If 0, use defaults. | ===== Audio Pack Format ===== An audio pack is a chunk of binary data, prefixed with two 16-bit unsigned integers. Size, followed by length, followed by length bytes of binary data. The last pack MUST have a 16-bit null terminator immediately following it. ===== FIR Coefficient Table ===== This is a chunk of binary data, with a byte length equal to the FIR coefficient table length times eight. ===== Variants ===== ==== 0 - Standard ==== This is the most common variant. The unmodified Kankichi-kun supplied to game developers uses this format. ==== 1 - Prototype ==== This is an early version of variant 0, used in early SNES games like Super Mario World. ==== 2 - Konami ==== This is a heavily modified variant 0, with several changed commands. Details are largely unknown. ==== 3 - AddMusicK ==== This is an upgraded version of variant 0, with many new commands. Designed for use in Super Mario World ROM hacks. ===== TODO ===== * Find out if any link exists between Metroid II's music driver and NSPC. They are suspiciously similar. * Document the commands unique to each variant