removed .gitignore
[k8opentitus.git] / doc / audio.txt
blobe28c12bfb32c36e751e4a76e0d53e7e77c53c792
1 Audio file format
3 An excellent adlib documentation is available at
4 http://web.archive.org/web/20100425014332/http://www.shipbrook.com/jeff/sb.html
6 All multibyte values have little endian byte order.
10 [header] (offset 0)
12 0-13:   magic string 14B ("OPENTITUSAUDIO")
13 14:     version 1B (0x01 = version 1)
14 15:     type 1B (0x01 = original adlib audio)
15 16:     global metadata offset 2B (titus/moktar = 37 = 0x0025)
17 [type 0x01 (original adlib audio)]
18 18:     data offset 2B unsigned integer (titus/moktar = 1576 = 0x0628)
19 20:     data size 2B unsigned integer (titus = 18749 = 0x493D, moktar = 18184 = 0x4708)
20 22:     identification 1B (0x01 = original TTF, 0x02 = original moktar, 0x03 = new)
21 23:     pointer difference 2B signed (titus = -1301 = 0xFAEB, moktar = -1345 = 0xFABF)
22 25:     music offset 2B unsigned (titus/moktar = 0 = 0x0000), disable adlib with 0xFFFF
23 27:     instrument offset 2B unsigned (titus/moktar = 352 = 0x0160)
24 29:     sound effects offset 2B unsigned (titus/moktar = 1950 = 0x079E)
25 31:     pc speaker offset 2B unsigned (titus/moktar = 1133 = 0x046D), disable pc speaker with 0xFFFF
26 33:     song count 1B unsigned (titus/moktar = 16)
27 34:     sound effects count 1B unsigned (titus/moktar = 14)
28 35:     sub metadata offset 2B (titus/moktar = 113 = 0x0071)
30 (hardcoded settings: 10 music channels for each song, (max) 19 instruments for each song)
31 (original songs have the last 4 instruments reserved for percussion instruments)
40 [global metadata] (offset 37)
41 37:     metadata type 1B (0x01 = one line zero terminated ascii comment, 0x02 = MFL-style meta tags)
43 [metadata type 0x01 (one line zero terminated ascii comment)]
44 38:     comment size 2B unsigned integer
45 40:     comment
47 [metadata type 0x02 (MFL-style meta tags)]
48 38:     metadata size 2B unsigned integer (titus = 73 = 0x0049, moktar = 66 = 0x0042)
49 40:     metadata (see below)
52 Metadata for original data files:
55 comment (ttf): Original audio extracted from Titus the Fox.
56 comment (moktar): Original audio extracted from Moktar.
58 writeprotection: 1
60 TTF:
61 comment\0\0Original audio extracted from Titus the Fox.\0writeprotection\0\01\0
63 Moktar:
64 comment\0\0Original audio extracted from Moktar.\0writeprotection\0\01\0
73 [sub metadata] (offset 113)
74 113:    metadata type 1B (0x02 = MFL-style meta tags)
76 [metadata type 0x02 (MFL-style meta tags)]
77 114:    metadata size 2B unsigned integer (titus/moktar = 1460 = 0x05B4)
78 116:    metadata (see below)
83 Metadata for original data files:
87 songdata:
88 Pre-level;prelevel
89 Death;death
90 Game over;gameover
91 Level music 1;levelmusic1
92 Finish a level;finish
93 Bonus: Padlock;padlock
94 Bonus: Life;life
95 Bonus: Password;password
96 Flying carpet (not in use);carpet
97 Credits;credits
98 Level music 2;levelmusic2
99 Level music 3;levelmusic3
100 Level music 4;levelmusic4
101 Level music 5;levelmusic5
102 The end;theend
103 Intro;intro
105 sfxdata:
106 Sfx 0 (not in use);sfx_0
107 Sfx 1: Hit enemy;sfx_hitenemy
108 Sfx 2 (not in use);sfx_2
109 Sfx 3: Throw;sfx_throw
110 Sfx 4: Enemy hits player;sfx_enemyhitsplayer
111 Sfx 5: Object hits player;sfx_objecthitsplayer
112 Sfx 6 (not in use);sfx_6
113 Sfx 7 (not in use);sfx_7
114 Sfx 8 (not in use);sfx_8
115 Sfx 9: Pick up an object;sfx_pickup
116 Sfx 10 (not in use);sfx_10
117 Sfx 11 (not in use);sfx_11
118 Sfx 12: Bounce;sfx_bounce
119 Sfx 13 (not in use);sfx_13
121 firstins: 1573
123 (insdata: type (1: melodic (11 bytes), 2: percussion (6 bytes)) ; description ; short description
125 insdata:
126 1;MYBIZAR2;MYBIZAR2
127 1;MYEFF3;MYEFF3
128 1;MYSNTH11;MYSNTH11
129 1;MYSNTH13;MYSNTH13
130 2;HHOPEN2;HHOPEN2
131 2;CHARL1;CHARL1
132 1;MYBASS1;MYBASS1
133 1;MYSYNT5;MYSYNT5
134 1;ORGAN4;ORGAN4
135 2;RKSNARE1;RKSNARE1
136 2;LOGDRUM2;LOGDRUM2
137 2;SFX_STOP;SFX_STOP
138 1;MARIMBA1;MARIMBA1
139 1;PIANO1;PIANO1
140 1;PIANO3;PIANO3
141 1;PIANOBEL;PIANOBEL
142 1;VIBRA3;VIBRA3
143 1;HARP1;HARP1
144 1;HARP2;HARP2
145 1;HARP3;HARP3
146 1;JAPAN4;JAPAN4
147 1;GUITAR1;GUITAR1
148 1;SAX2;SAX2
149 1;JAVAICAN;JAVAICAN
150 1;MYBANJ1;MYBANJ1
151 1;MYSTRG1;MYSTRG1
152 1;SNAKEFL2;SNAKEFL2
153 1;SNAKEFL3;SNAKEFL3
154 1;MYMOOG2;MYMOOG2
155 1;SITAR12;SITAR12
156 1;MYFLUTE2;MYFLUTE2
157 1;VIOLIN1;VIOLIN1
158 1;VIOLIN2;VIOLIN2
159 1;SYNBASS5;SYNBASS5
160 1;SYNBASS6;SYNBASS6
161 2;TAMB3;TAMB3
162 1;MYBIZAR1;MYBIZAR1
166 Data:
167 songdata\0\0Pre-level;prelevel,Death;death,Game over;gameover,Level music 1;levelmusic1,Finish a level;finish,Bonus: Padlock;padlock,Bonus: Life;life,Bonus: Password;password,Flying carpet (not in use);carpet,Credits;credits,Level music 2;levelmusic2,Level music 3;levelmusic3,Level music 4;levelmusic4,Level music 5;levelmusic5,The end;theend,Intro;intro\0sfxdata\0\0Sfx 0 (not in use);sfx_0,Sfx 1: Hit enemy;sfx_hitenemy,Sfx 2 (not in use);sfx_2,Sfx 3: Throw;sfx_throw,Sfx 4: Enemy hits player;sfx_enemyhitsplayer,Sfx 5: Object hits player;sfx_objecthitsplayer,Sfx 6 (not in use);sfx_6,Sfx 7 (not in use);sfx_7,Sfx 8 (not in use);sfx_8,Sfx 9: Pick up an object;sfx_pickup,Sfx 10 (not in use);sfx_10,Sfx 11 (not in use);sfx_11,Sfx 12: Bounce;sfx_bounce,Sfx 13 (not in use);sfx_13\0firstins\0\01573\0insdata\0\01;MYBIZAR2;MYBIZAR2,1;MYEFF3;MYEFF3,1;MYSNTH11;MYSNTH11,1;MYSNTH13;MYSNTH13,2;HHOPEN2;HHOPEN2,2;CHARL1;CHARL1,1;MYBASS1;MYBASS1,1;MYSYNT5;MYSYNT5,1;ORGAN4;ORGAN4,2;RKSNARE1;RKSNARE1,2;LOGDRUM2;LOGDRUM2,2;SFX_STOP;SFX_STOP,1;MARIMBA1;MARIMBA1,1;PIANO1;PIANO1,1;PIANO3;PIANO3,1;PIANOBEL;PIANOBEL,1;VIBRA3;VIBRA3,1;HARP1;HARP1,1;HARP2;HARP2,1;HARP3;HARP3,1;JAPAN4;JAPAN4,1;GUITAR1;GUITAR1,1;SAX2;SAX2,1;JAVAICAN;JAVAICAN,1;MYBANJ1;MYBANJ1,1;MYSTRG1;MYSTRG1,1;SNAKEFL2;SNAKEFL2,1;SNAKEFL3;SNAKEFL3,1;MYMOOG2;MYMOOG2,1;SITAR12;SITAR12,1;MYFLUTE2;MYFLUTE2,1;VIOLIN1;VIOLIN1,1;VIOLIN2;VIOLIN2,1;SYNBASS5;SYNBASS5,1;SYNBASS6;SYNBASS6,2;TAMB3;TAMB3,1;MYBIZAR1;MYBIZAR1\0
173 [data] (offset 1576)
175 [music offset]
176 for each song {
177   for each music channel {
178     music channel offset 2B unsigned (offset + pointer difference)
179   }
180   no more channels: 0xFFFF
183 [instrument offset]
184 for each song {
185   for each instrument {
186     instrumentdata offset 2B unsigned (offset + pointer difference)
187       (if instrumentdata = 0: instrument not in use)
188   }
189   skip delay (to modify the song's tempo) 2B unsigned
190   no more instruments: 0xFFFF
193 [sound effects offset]
194 for each sound effect {
195   for each operator (always 2) {
196     Attack Rate / Decay Rate 1B (sent to address 0x60 + op channel)
197     Sustain Level / Release Rate 1B (sent to address 0x80 + op channel)
198     Key scaling level / Operator output level 1B (sent to address 0x40 + op channel)
199     Amp Mod / Vibrato / EG type / Key Scaling / Multiple 1B (sent to address 0x20 + op channel)
200     Wave type 1B (sent to address 0xE0 + op channel)
201   }
202   Feedback algorithm 1B (sent to address 0xC0 + channel)
205 [instrumentdata offset]
206 for each operator (always 2) {
207   Attack Rate / Decay Rate 1B (sent to address 0x60 + op channel)
208   Sustain Level / Release Rate 1B (sent to address 0x80 + op channel)
209   Key scaling level / Operator output level 1B (sent to address 0x40 + op channel)
210   Amp Mod / Vibrato / EG type / Key Scaling / Multiple 1B (sent to address 0x20 + op channel)
211   Wave type 1B (sent to address 0xE0 + op channel)
213 Feedback algorithm 1B (sent to address 0xC0 + channel)
215 [music data]
216 new byte:
217 load 1 byte from channel offset
218 bits: abbbcccc
219 cccc: Frequence/note (0-11: C-C#-D-D#...A-A#-B, 12: pause) (percussion: 0-11: not pause, 12: pause)
220 bbb: Octave (percussion (0-3): instrument + 15)
221 a: If not set, play the note and continue to next channel, if set, escape
223 [escape]
224 bbb: function
225 0: Change note duration, new duration: cccc
226 1: Change volume, new volume: cccc
227 2: Change tempo, new tempo: cccc (appearently not in use)
228 3: Change triple duration: new tr.d: cccc (duration must be 7 to use tr.d. 3 tr.d. equals 2 duration)
229 4: Change "lie", new "lie": cccc (will silence the channel if not 1)
230 5: Change "vox", new "vox": cccc (channel number, 0-8)
231 6: Change instrument:
232   if cccc = 1: new percussion instrument: 15 + last octave
233   if cccc > 1: new instrument: cccc - 1
234   if cccc = 0: new instrument: 0
235 7: Extra functions (load extra bytes for arguments)
237   cccc: function2
238   0: Call a sub (2 bytes: new offset). Jump to new offset + pointer difference, store old pointer.
239   1: Update loop counter (1 byte)
240   2: Loop (2 bytes: new offset). Reduce loop counter. If not 0, jump back to new offset + pointer
241      difference.
242   3: Return from sub. Jump to pointer stored when the sub was called.
243   4: Jump (2 bytes: new offset). Jump to new offset + pointer difference.
244   15: Finish. Close the channel. Level music will restart when all channels are closed. Continue
245       to next channel.
247 After escape, jump back to new byte