AMOS Music Bank format

AMOS music banks are one of the standard AMOS file formats.

All multi-byte integers are in big-endian format.

The format is divided into sections. The format typically starts with a Standard AMOS bank header, which may be truncated or damaged depending on how it was ripped:

Whatever the format of the standard AMOS bank header, it is immediately followed by the music bank's main header:

These offsets point to other sections of the file, which might not be consecutive or even in the order given.

Instrument data section
WARNING: samples lengths can often be incorrect. Do not rely on the "sample length" field here. To find the true length of a sample, it is necessary to take all sample offsets and sort them into order. Each sample's length is that of its offset subtracted from the offset of the next sample. For the final sample, its offset should be subtracted from the overall length of the instruments data block (which will be the offset of the instruments block subtracted from the offset of the section following it, or the overall length of the file if no other section follows it).

Song data section
The song data section starts with a list of offsets to songs:

Each song has this format:

A playlist is a stream of 2-byte words, giving the list of patterns to play in order for that channel.

Valid pattern numbers start from 0 and go up to however many patterns there are. The list is terminated with 0xFFFE, sometimes 0xFFFF.

Each channel has its own set of patterns, so pattern 0 on channel 0 is not the same as pattern 0 on channel 1.

Pattern data section
The pattern data section starts with a list of patterns

A pattern is a stream of 2-byte word commands and notes.

Commands have bit 15 set ($8000-$FFFF). Notes do not have bit 15 set ($0000-$7FFF).

Commands come before notes and are executed immediately. When a note appears, processing the pattern finishes for that vertical blank, and processing will re-commence once the delay counter elapses (see the delay command below).

Unlike SoundTracker, which allows one command per note, there can be any number of commands per note, although generally it's not useful, as repeating the same command again and again would simply overwrite its value.

Commands
Each command has a parameter, although many commands don't need and therefore ignore their parameter. The command value is the bits 14 to 8 of each word, the parameter value is bits 7 to 0.

All "effect" commands which have a lasting effect, between notes are assumed to continue running forever until they are changed to another effect, or stopped with the "stop effect" command. A channel can only run one effect. So if AMOS did a "shift down" command, a "delay" of 14 and then a "stop effect", the equivalent in SoundTracker would be to repeat the portamento down command 14 times, once in each position, and positions after that would simply have the empty command (000).

There is no implicit delay of one position between commands or notes, as there is in SoundTracker. Instead, a "delay" (0x10) command must be executed.

Other than the "set tempo" and "low pass filter on/off" commands, the effect of every command is limited to the channel it runs on.

The commands are as follows: