-
Notifications
You must be signed in to change notification settings - Fork 2
Song data format
The following table describes each instruction in the song data table, along with its opcode and operands (if appropriate).
Instruction | Length | Opcode | Op 1 | Range | Op 2 | Range |
---|---|---|---|---|---|---|
End | 1 | $00 | ||||
Note: C | 1 | $01 | ||||
Note: C# / Db | 1 | $02 | ||||
Note: D | 1 | $03 | ||||
Note: D# / Eb | 1 | $04 | ||||
Note: E | 1 | $05 | ||||
Note: F | 1 | $06 | ||||
Note: F# / Gb | 1 | $07 | ||||
Note: G | 1 | $08 | ||||
Note: G# / Ab | 1 | $09 | ||||
Note: A | 1 | $0a | ||||
Note: A# / Bb | 1 | $0b | ||||
Note: B | 1 | $0c | ||||
Note: Rest | 1 | $0d | ||||
Notes (len) | 2 | $11-$1d | len | 0..255 | ||
Notes (q) | 2 | $21-$2d | q | 0..255 | ||
Notes (len+q) | 3 | $31-$3d | len | 0..255 | q | 0..255 |
Notes (wlen) | 3 | $51-$5d | wlen | 0..65535 | ||
Notes (wq) | 3 | $61-$6d | wq | 0..65535 | ||
Notes (wlen+wq) | 5 | $71-$7d | wlen | 0..65535 | wq | 0..65535 |
Track Loop | 1 | $80 | ||||
Loop Start Marker | 2 | $81 | times | 0..255 | ||
Loop End Marker | 1 | $82 | ||||
Note Length | 2 | $83 | len | 0..255 | ||
Note Length (word) | 3 | $84 | wlen | 0..65535 | ||
Quantization Length | 2 | $85 | q | 0..255 | ||
Quant. Length (word) | 3 | $86 | wq | 0..65535 | ||
Octave | 2 | $87 | v | 0..7 | ||
Increase Octave | 1 | $88 | ||||
Decrease Octave | 1 | $89 | ||||
Transpose | 2 | $8a | v | -127..128 | ||
Detune | 2 | $8b | v | -127..128 | ||
Timbre | 2 | $8c | type | 0..7 | ||
Volume | 2 | $8d | v | 0..15 | ||
Increase Volume | 1 | $8e | ||||
Decrease Volume | 1 | $8f | ||||
Pitch Sweep | 2 | $90 | v | 0..255 | ||
Volume Envelope | 2 | $91 | seq | 0..255 | ||
Note Envelope | 2 | $92 | seq | 0..255 | ||
Timbre Envelope | 2 | $93 | seq | 0..255 | ||
Pitch Envelope | 2 | $94 | seq | 0..255 |
-
len
operand represents the note lengths and is expressed in frames. -
wlen
is the same aslen
but operand is a word instead of a byte. -
q
andwq
operands represents quantization length, in byte and word sizes. Quantization length is expressed in frames. -
seq
operands are indexes to the corresponding sequence table (see below).
Sequence are implemented as byte arrays, with values in the range of 0 and 252. These sequences are currently being used for envelopes whose values are not bigger than 16, so it's good enough. Values are specified with bytes 0x1
to 0xfd
(i.e substract 1 to byte to get real value). 0x00
, 0xfe
and 0xff
are reserved for commands:
-
End
(0x00
): Marks the end of a sequence (same as in Song sequences) -
LoopMarker
(0xfe
): When used, player will loop between loop marker and release marker (or end of sequence, if not available), until note is released. -
ReleaseMarker
(0xff
): When used, player will stop at release marker while note is on (or loop between loop marker, if available), and continue playing when note is released.
Instruction | Length | Opcode |
---|---|---|
End | 1 | $00 |
Value | 1 | $01-$fd |
LoopMarker | 1 | $fe |
ReleaseMarker | 1 | $ff |