SEQFormat

From Yabause
Jump to: navigation, search

Header Format

First 6 bytes are used only when declared as a Sequence bank. Everything is in Big Endian.

Offset Description
0x00-0x01 Number of Songs in Sequence Bank
0x02-0x05 Pointer to first song
0xyy-0xzz Pointer to second song, third song, etc. etc.
0x06-0x07 Resolution. Same format and byte order as midi's.
0x08-0x09 Number of tempo events.
0x0A-0x0B Offset to first track event.
0x0C-0x0D Offset to first tempo event in loop


Track Event List and Restrictions

Here's a short list of events used by the format. Step(Delta) information is stored at the end of an event, not before it like midi:

Data Format Event Name Description
0x00-0x7F 0xww 0xxx 0xyy 0xzz Note On The high nibble of the first byte is used as the ninth bit for gate and step time, plus one more unknown item. In the high nibble, the 2nd bit is the 9th bit for step time and 3rd bit is the 9th bit for gate time. The first bit is unknown. The low nibble is the actual channel. ww is the key number(same format as midi), xx is the volume, yy is the 1st-8th bit of gate time, and zz is the 1st-8th bit of step time.
0x81 0xyyyy 0xzz Reference This is how this format is able to really pack the data. Reference basically goes to an offset starting at the beginning of the normal track and offsets it by yyyy. It reuses zz events from that offset and jumps back to the old offset afterwards.

SPECIAL NOTE: You DO NOT count Gate and Step(Delta) Extend Events(although you still handle them).

0x82 0xzz Loop There will always be two calls of these. One at the start of the loop, and one at the end. zz is the step time.
0x83 End of track This will always be at the end of the normal track.
0x88 Gate Extend 0x200 Add 0x200 onto the next Note On gate time value.
0x89 Gate Extend 0x800 Add 0x800 onto the next Note On gate time value.
0x8A Gate Extend 0x1000 Add 0x1000 onto the next Note On gate time value.
0x8B Gate Extend 0x2000 Add 0x2000 onto the next Note On gate time value.
0x8C Step(Delta) Extend 0x100 Add 0x100 onto the next Note On step time value.
0x8D Step(Delta) Extend 0x200 Add 0x200 onto the next Note On step time value.
0x8E Step(Delta) Extend 0x800 Add 0x800 onto the next Note On step time value.
0x8F Step(Delta) Extend 0x1000 Add 0x1000 onto the next Note On step time value.
0xAw 0xxx 0xyy 0xzz Polyphonic Pressure(Aftertouch) w is the channel, xx is the key, yy the value, and zz the step time.
0xBw 0xxx 0xyy 0xzz Control Change w is the channel, xx is Control Change number, yy is the value(if necessary), and zz is the step time. Control Change 32(for each change) must be at the top of the normal track and before the Program Change Event.
0xCx 0xyy 0xzz Program Change x is the channel, yy is the program, zz is the step time.
0xDx 0xyy 0xzz Channel Pressure(Aftertouch) x is the channel, yy is the value, and zz is the step time.
0xEx 0xyy 0xzz Pitch Bend Low nibble of first byte is the channel, yy is the pitch value. To convert to midi's pitch wheel, just put the value in the second pitch byte(not the first). zz is the delta time.


Tempo Events

Here's a the tempo event format:

Offset Description
0x00-0x03 Step(Delta) Time
0x04-0x07 BPM


What is Gate Time?

It's a replacement for MIDI's note off event in a sense. It's basically a step(delta) count till a note off is issued. So it cuts down on file size.