BGM,SEデータフォーマット(Format of BGM and SE)

ポインターと記載された場合は、現アドレスからの相対アドレスを意味します。

ヘッダー(Header)

Address SizeContents
0x0000 BYTE Number of track (BGM:max=5, SE:max=2)
0x0001 BYTE 下位2bit : 優先度(効果音のみ)
0x0002 WORD[n]曲データの先頭を基点としたオフセットアドレス。
- - Datas.

シーケンス(sequence)

op-code value Contents
0x00 End of Track / End of Subroutine
0x01 n1 n2 Jump (End of Track with loop)
n1::n2 = jumping pointer.
0x02 n1 n2 Sub-routine call
n1::n2 = Pointer of sub-routine.
0x03 n1 Repeat(A) Start point.
n1 = repeat times
0x04 n1 n2 Repeat(A) Branch point
n1::n2 = Pointer of exit.
0x05 n1 n2 Repeat(A) End point.
n1::n2 = Pointer of start.
0x06 n1 n2 効果音呼び出し
n1::n2 = Pointer of SE.
0x07 n1 n2 n3 Write data to memory.
n1::n2 = Address. / n3 = Writing data
0x08 n1 Tempo [BPM]
0x09 n1 Note length of 省略時 [Ticks]
0x0A n1 Gate time (key-off timing from last)
0x0B n1 Gate time (length of 発音)
0x0C n1 Relative Tempo [BPM]
0x0D Gate mode (no release. volume = 0)
0x0E Gate mode (release of command value)
0x0F Gate mode (release of envelop pattern)
0x10 n1 n2 Voice envelop.
n1::n2 = Pointer.
0x11 n1 n2 Volume envelop.
n1::n2 = Pointer.
0x12 n1 n2 Frequency envelop.
n1::n2 = Pointer.
0x13 n1 n2 Note envelop.
n1::n2 = Pointer.
0x14 n1 Detune (16 = 100 cent)
0x15 n1 Detune (Resister base)
0x16 n1 APU : Sweep (Resister base)
FDS : Sweep (Modulator) bias
VRC6: -
VRC7: Sustain Switch
MMC5: -
N163: Sample length
Sunsoft 5B: Envelop Switch & Type
0x17 n1 n2 n3 n4Portamento
n1 = Decay (1 = 1 VBlank)
n2 = Rate (1 = 1 VBlank)
n3 = Depth (16 = 100 [cent])
n4 = Target (1 = 100 [cent])
0x18 Repeat(B) Start point
0x19 Repeat(B) Branch point
0x1A n1 n2 Repeat(B) End point
n1::n2 = Pointer of start.
0x1B n1 Voice (Voice Envelop Off)
0x1C n1 n2 VRC6: Set user instrument
n1::n2 = Pointer.
0x1D n1 n2 VRC6: Set resister
n1 : Resister
n2 : Data
0x1E n1 n2 n3 N163: Set wave table
n1 = Addres
n1::n2 = Pointer.
0x1F n1 N163: Set Channel number
n1 = number of channel
0x20 Volume down (-1)
0x21 Volume up (+1)
0x22 n1 n2 FDS : Set career wave table
n1::n2 = Pointer.
0x23 n1 n2 FDS : Set modulator wave table
n1::n2 = Pointer.
0x24 n1 n2 FDS : Modulator frequency
n1::n2 = Frequency
0x25 n1 FDS : Master volume
n1 = master volume
0x26 n1 n2 Sunsoft 5B: Envelope frequency
n1::n2 = Frequency
0x27 reserve
0x28 Octave down (-1)
0x29 Octave up (+1)
0x2A n1 Transpose (an absolute value)
0x2B n1 Transpose (a relative value)
0x2C Octave down (only next note)
0x2D Octave up (only next note)
0x2E n1 One time transpose (a relative value)
0x2F n1 ... Expansion (2 byte) op-code. 今後の拡張用(未実装)
n1 = Sub op-code. all reserved
0x30-0x37 n1 Voice of release (after key-off)
0x38-0x3F Octave (op-code lower 4bit is value)
0x40-0x4F Note length of 省略時 (op-code lower 4bit is value)
0x00 : 96 tick (l1)
0x01 : 72 tick (l2.)
0x02 : 48 tick (l2)
0x03 : 36 tick (l4.)
0x04 : 32 tick (l3)
0x05 : 24 tick (l4)
0x06 : 18 tick (l8.)
0x07 : 16 tick (l6)
0x08 : 12 tick (l8)
0x09 : 9 tick (l16.)
0x0A : 8 tick (l12)
0x0B : 6 tick (l16)
0x0C : 4 tick (l24)
0x0D : 3 tick (l32)
0x0E : 2 tick (l48)
0x0F : 1 tick (l96)
0x50-0x5F Gate time (op-code lower 4bit is value)
0x60-0x6F Volume (op-code lower 4bit is value)
0x70-0x7F Volume of release (op-code lower 4bit is value)
0x80-0xFF (n1) (n2) Note and Rest
op-code bit 7 = `H'
op-code bit 6 = flag of Gate Time (n2 [tick])
op-code bit 5 = flag of Length (n1 [tick])
op-code bit 4 = flag of Thai & Slur
op-code bit 3-0 = note
0x00 : C
0x01 : Cis / Des
0x02 : D
0x03 : Dis / Es
0x04 : E
0x05 : F
0x06 : Fis / Ges
0x07 : G
0x08 : Gis / As
0x09 : A
0x0A : Ais / Bs (B)
0x0B : B (H)
0x0C : undefined
0x0D : r (no release. volume = 0)
0x0E : r (release of command value)
0x0F : r (release of envelop pattern)

エンベロープ(Envelop)

データ構造(Struct)

Address Contents
0x00 Pointer of release (after key-off)
If setting `0', no release pattern.
0x01 - Envelop pattern

パターン(Pattern)

op-code Contents
0xxx xxxx <2> xxx xxxx (7bit) = Envelop value
1000 xxxx <2> xxxx (4bit) = Hold length (0=1Vblank, 1=2Vblank, ...)
11xx xxxx <2> xx xxxx (6bit) = Address of jump