PSF Format Specification
This is a live version of the PSF Format Specification (based on v1.6), to be updated continually.
Introduction
PSF (Portable Sound Format) brings the functionality of NSF, SID, SPC, and GBS to next-generation consoles. PSF utilizes the original music driver code from each game to replay sequenced music in a perfectly authentic, and size-efficient, way.
The general idea is that a PSF file contains a zlib-compressed program which, if executed on the real console, would simply play the music.
File Structure
All PSF files share the same basic stucture.
Alignment to any data type larger than a byte is not guaranteed in the PSF file. Exercise appropriate caution.
- First 3 bytes: ASCII signature: "PSF" (case sensitive)
- Next 1 byte: Version byte
The version byte is used to determine the type of PSF file. It does NOT affect the basic structure of the file in any way.
Currently accepted version bytes are:
Depending on the version byte, the reserved and program sections are interpreted differently. Some tags may also be interpreted differently. Refer to the linked sections above for more information.
- Next 4 bytes: Size of reserved area (R), little-endian unsigned long
- Next 4 bytes: Compressed program length (N), little-endian unsigned long
This is the length of the program data _after_ compression.
- Next 4 bytes: Compressed program CRC-32, little-endian unsigned long
This is the CRC-32 of the program data _after_ compression. Filling in this value is mandatory, as a PSF file may be regarded as corrupt if it does not match.
- Next R bytes: Reserved area.
May be empty if R is 0 bytes.
- Next N bytes: Compressed program, in zlib compress() format.
May be empty if N is 0 bytes.
The following data is optional and may be omitted:
- Next 5 bytes: ASCII signature: "[TAG]" (case sensitive)
If these 5 bytes do not match, then the remainder of the file may be regarded as invalid and discarded.
- Remainder of file: Tag data.
Refer to
PSF Tag Format for information on the tag format.
Tag data may be subject to truncation, including removal of the excess data from the file itself, if it exceeds 50,000 bytes. This is by design.
Compatibility
For future compatibility, tag editors and compressors may assume that any PSF file uses this basic structure. However, the reserved area must be left intact, and no assumptions may be made about the format or contents of either the uncompressed program or reserved sections without first checking the version byte.
CategoryPSF