# Varvara tracker format This is a very early, informal draft of a varvara tracker format, intended to be integrated into demos and games to provide a soundtrack. It is inspired by the .xm format used for PC demos. ## General Layout A file is overall structured into these parts: ``` ... (for all pattern data) ... (for all instrument data) ``` ## File Header The header is 3 bytes. The high nibble of the first byte is used for flags (detailed below). The low nibble is used for the default speed, measured in how many screen vector cycles it takes to advance 1 line in a pattern. The second byte stores the number of patterns in the file and the third byte stores the number of instruments in the file. ``` first header byte | Field | Loop | [padding] | Speed | | Bits | 1 | 3 | 4 | ``` The loop flag is 0 if the song should not loop and 1 if it should. The other flags are currently unused. ## Song Table The Song Table is a table that contains what order patterns will play in in the module. It has the following format: ``` size [short] - the size, in bytes, of the song table ... (until the end of the song) ``` ### Song Rows a song row is 4 bytes. Each byte is a pattern number, with the first byte being the pattern on channel 0, second being channel 1 etc. a byte ff means no pattern. ## Patterns Patterns contain 0x10 lines of note data. Patterns are ordered sequentially in the file and there can be up to 255 patterns in a file. A pattern line consists of 3 bytes. The first byte contains a note ( up to 0x7f ) and the next two bytes contain a command and a parameter for that effect. No note is represented by the byte 00. 0xff represents a note off/note stop. No effect is also represented by 00. ### Commands (what an command should be drawn as in an editor is in parenthesis) More soon probably * 0x01 (V) - set volume to argument * 0x02 (I) - set instrument to argument * 0x03 (A) - set attack to argument (1-0f) * 0x04 (D) - set decay to argument (1-0f) * 0x05 (S) - set sustain to argument (1-0f) * 0x06 (R) - set release to argument (1-0f) * 0x07 (T) - set song speed to argument (1-0f) ## Instruments Instruments contain a sample and some default parameters for that sample. Everything is in the same format expected by the audio device. ``` Sample Length [Short] Volume [Byte] Flags [Byte] ADSR [Short] Sample ``` The flags byte has the format: ``` 0 | 0000000 | Sample Loop | unused ```