AST file

From Pikmin Technical Knowledge Base
Jump to navigation Jump to search

AST files contain streamed audio data, and are used in Pikmin 2. To simply play audio files, you can use vgmstream, an audio playback library for multiple video game specific audio formats.

To convert .wav to .ast, you can use JATAST. This defaults to ADPCM encoding, as the GameCube's disc reading (whether on real hardware or emulated with dolphin) will not be able to keep up with large streamed music otherwise.

File Format[edit]

Header[edit]

The file starts with a 0x40 bytes long header as follows:

Offset Type Name Description
0x00 int32 magic 'STRM' 0x5354524D
0x04 int32 size (File Size - 0x40)
0x08 u16 Format 0 = ADPCM, 1 = PCM16.
0x0A u16 BitsPerFrame Usually 16.
0x0C u16 channelCount Number of channels.
0x0E bool (u16) loop 0xFFFF = true, 0x0000 = false
0x10 int32 sampleRate Sample Rate.
0x14 int32 sampleCount Sample Count
0x18 int32 loopStart Start of loop in samples (Aligned to nearest 16 samples)
0x1C int32 loopEnd End of loop, aligned to nearest 16 samples. SampleCount if no loop.
0x20 int32 blockSize Block size. Generally 0x00002760.

NOTE: This is the size of ONE CHANNEL. If you have 2 channels, the block will be 4EC0 in length, but this should still say 0x2760

0x24 int32 unknown 0
0x28 u8 volume Volume modifier, byte. 0x7F = 100%
0x29 Byte[0x17] padding Padding to align header to 0x40
0x40 BLCK[] ... ...

Block / BLCK[edit]

Offset Type Name Description
+0x00 int32 magic 'BLCK' 0x424C434B
+0x04 int32 size Block size, 0x2760 if full block.

NOTE: See the above comment regarding block size. This will be the length of one channel. The last BLCK's size might differ, but the rest will generally remain 0x2760

+0x08 u16[2][6] sampleHist Historical samples for ADPCM4 only.
+0x20 u8[size][channelCount] sampleData Sample data. Each channel will be packed directly following the previous channel.
+(size + 0x20) Next BLCK

Trivia[edit]

When encoding the sampleHist part of the block in ADPCM, this will be the historical values (last = l, p = penultimate)

Each set of two u16's represents one channel in the AST. If there aren't that many channels, the value will be set to 0.

The value of these will be the last evaluated (decoded) samples from the previous block (matching channel). Without these, the predictor for the current block will overscale, resulting in "crunchy" Audio.