AGSC (File Format)
AGSC is the sound effect format for Metroid Prime and Metroid Prime 2: Echoes. Each AGSC file contains a group of sound effects. According to the debug maps in Metroid Prime, there are references to various "classes", with one of them controlling audio in the map, known as AudioGroupSet. So presumably, AGSC is an abbreviation for Audio Group Set Class.
The audio codec used in AGSC is the standard GameCube DSP ADPCM codec, as described in the GameCube SDK.
This file format needs more research The first two chunks are still unknown. |
Contents
Format
The AGSC format is split up into four distinct data chunks; two unknown chunks, one for sound metadata, and one for actual ADPCM sound data. The format is very similar between Metroid Prime 1 and 2; the main difference is the header, and some slight changes in the way the four chunks are organized. In Metroid Prime, each chunk begins with its own size value; in Metroid Prime 2, every chunk instead has its size listed at the beginning of the file, at the end of the header. In addition, in Metroid Prime, the third chunk is sound data, and the fourth is sound metadata; in Metroid Prime 2, it's the other way around.
Header
Metroid Prime
Offset | Size | Description |
---|---|---|
0x0 | D | Audio Directory. Always "Audio/." Zero-terminated. |
0x0 + D | N | Audio Group Name. Zero-terminated. |
0x0 + D + N | End of header |
Metroid Prime 2
Offset | Size | Description |
---|---|---|
0x0 | 4 | Unknown; always 1 |
0x4 | D | Audio Group Name. Zero-terminated. |
0x4 + D | 4 | Chunk 1 size |
0x8 + D | 4 | Chunk 2 size |
0xC + D | 4 | Sound metadata chunk size |
0x10 + D | 4 | ADPCM chunk size |
0x14 + D | End of header |
Sound Metadata
The sound metadata chunk (chunk 4 in Metroid Prime, chunk 3 in Metroid Prime 2) is made up of two sets of tables. The structure of both these tables is identical between both games.
Table A
The first metadata table has one entry per sound, and is terminated with 0xFFFFFFFF; since there's no known sound count anywhere in the file, the only way to read this correctly is to read until you reach the terminator value. Each entry is 0x20 bytes long.
Offset | Size | Description |
---|---|---|
0x0 | 2 | Sound ID (note: not 100% confirmed) |
0x2 | 2 | Padding. |
0x4 | 4 | Sound start offset, relative to the start of the ADPCM chunk |
0x8 | 4 | Unknown |
0xC | 2 | Unknown; appears to always be 0x3C00 |
0xE | 2 | Sample rate |
0x10 | 4 | Number of samples |
0x14 | 4 | Loop start sample |
0x18 | 4 | Loop length, in samples. To get the loop end sample, add this to the start sample and subtract 1. |
0x1C | 4 | Table B entry offset, relative to the start of the sound metadata chunk |
0x20 | End of entry |
Table B
These are accessed through the offsets in table A's entries; note that it might not match the sound count, because the same entry in this table can be used with multiple sounds. Each entry is 0x28 bytes long.
Offset | Size | Description |
---|---|---|
0x0 | 2 | Unknown |
0x2 | 2 | Unknown |
0x4 | 4 | Unknown |
0x8 | 2 × 16 | Decode coefficients |
0x28 | End of entry |
ADPCM Data
This data is formatted using the standard GameCube ADPCM codec, and can be decoded the same way as a DSP file. Each sound's size is padded to 32 bytes before the next sound's data begins.
Tools
- Prime Audio Decoder by Parax will dump all sound effects contained in a given AGSC file.