1 #ifndef _ITPLAY_H 2 #define _ITPLAY_H 1 3 4 struct sampleinfo; /* dev/mcp.h */ 5 #define it_sampleinfo sampleinfo 6 7 struct it_envelope 8 { 9 int len; 10 int loops, loope; 11 int sloops, sloope; 12 int type; 13 enum 14 { 15 env_type_active=1, env_type_looped=2, env_type_slooped=4, env_type_carry=8, env_type_filter=128 16 } env_types; 17 uint16_t x[26]; 18 int8_t y[28]; 19 }; 20 21 struct it_sample 22 { 23 char name[32]; 24 char packed; 25 uint16_t handle; 26 int16_t normnote; 27 uint8_t gvl; 28 uint8_t vol; 29 uint8_t vis; 30 uint8_t vid; 31 uint8_t vit; 32 uint8_t vir; 33 uint8_t dfp; 34 }; 35 36 #define IT_KEYTABS 120 37 struct it_instrument 38 { 39 char name[32]; 40 uint8_t handle; 41 uint8_t keytab[IT_KEYTABS][2]; 42 int32_t fadeout; 43 struct it_envelope envs[3]; 44 uint8_t nna; 45 uint8_t dct; 46 uint8_t dca; 47 uint8_t pps; 48 uint8_t ppc; 49 uint8_t gbv; 50 uint8_t dfp; 51 uint8_t rv; 52 uint8_t rp; 53 uint8_t ifp; 54 uint8_t ifr; 55 uint8_t mch; 56 uint8_t mpr; 57 uint16_t midibnk; 58 }; 59 60 struct it_chaninfo 61 { 62 uint8_t ins; 63 int smp; 64 uint8_t note; 65 uint8_t vol; 66 uint8_t pan; 67 uint8_t notehit; 68 uint8_t volslide; 69 uint8_t pitchslide; 70 uint8_t panslide; 71 uint8_t volfx; 72 uint8_t pitchfx; 73 uint8_t notefx; 74 uint8_t fx; 75 }; 76 77 78 struct it_module 79 { 80 char name[32]; 81 int nchan; 82 int ninst; 83 int nsampi; 84 int nsamp; 85 int npat; 86 int nord; 87 int linearfreq; 88 int endord; 89 char **message; 90 char **midicmds; 91 uint16_t *orders; 92 uint16_t *patlens; 93 uint8_t **patterns; 94 struct it_sample *samples; 95 struct it_instrument *instruments; 96 struct it_sampleinfo *sampleinfos; 97 int deltapacked; 98 int inispeed; 99 int initempo; 100 int inigvol; 101 uint8_t inipan[64]; 102 uint8_t inivol[64]; 103 int chsep; 104 int linear; 105 int oldfx; 106 int instmode; 107 int geffect; 108 }; 109 110 struct ocpfilehandle_t; 111 extern int __attribute__ ((visibility ("internal"))) it_load(struct it_module *, struct ocpfilehandle_t *); /* done */ 112 extern void __attribute__ ((visibility ("internal"))) it_free(struct it_module *); /* done */ 113 extern void __attribute__ ((visibility ("internal"))) it_optimizepatlens(struct it_module *); /* done */ 114 extern int __attribute__ ((visibility ("internal"))) it_precalctime(struct it_module *, int startpos, int (*calctimer)[2], int calcn, int ite); /* done */ 115 116 extern int __attribute__ ((visibility ("internal"))) decompress8 (struct ocpfilehandle_t *, void *dst, int len, char it215); /* done */ 117 extern int __attribute__ ((visibility ("internal"))) decompress16(struct ocpfilehandle_t *, void *dst, int len, char it215); /* done */ 118 119 enum 120 { 121 cmdSpeed=1, cmdJump=2, cmdBreak=3, cmdVolSlide=4, cmdPortaD=5, 122 cmdPortaU=6, cmdPortaNote=7, cmdVibrato=8, cmdTremor=9, cmdArpeggio=10, 123 cmdVibVol=11, cmdPortaVol=12, cmdChanVol=13, cmdChanVolSlide=14, 124 cmdOffset=15, cmdPanSlide=16, cmdRetrigger=17, cmdTremolo=18, 125 cmdSpecial=19, cmdTempo=20, cmdFineVib=21, cmdGVolume=22, 126 cmdGVolSlide=23, cmdPanning=24, cmdPanbrello=25, cmdMIDI=26, 127 128 cmdSVibType=3, cmdSTremType=4, cmdSPanbrType=5, cmdSPatDelayTick=6, 129 cmdSInstFX=7, cmdSPanning=8, cmdSSurround=9, cmdSOffsetHigh=10, 130 cmdSPatLoop=11, cmdSNoteCut=12, cmdSNoteDelay=13, cmdSPatDelayRow=14, 131 cmdSSetMIDIMacro=15, 132 133 cmdSIPastCut=0, cmdSIPastOff=1, cmdSIPastFade=2, cmdSINNACut=3, 134 cmdSINNACont=4, cmdSINNAOff=5, cmdSINNAFade=6, cmdSIVolEnvOff=7, 135 cmdSIVolEnvOn=8, cmdSIPanEnvOff=9, cmdSIPanEnvOn=10, 136 cmdSIPitchEnvOff=11, cmdSIPitchEnvOn=12, 137 138 cmdVVolume=1, cmdVFVolSlU=66, cmdVFVolSlD=76, cmdVVolSlU=86, 139 cmdVVolSlD=96, cmdVPortaD=106, cmdVPortaU=116, cmdVPanning=129, 140 cmdVPortaNote=194, cmdVVibrato=204, 141 142 cmdNNote=1, cmdNNoteFade=121, cmdNNoteCut=254, cmdNNoteOff=255, 143 cmdSync=30303 144 }; 145 146 enum 147 { 148 ifxGVSUp=1, ifxGVSDown, 149 ifxVSUp=1, ifxVSDown, 150 ifxPSUp=1, ifxPSDown, ifxPSToNote, 151 ifxPnSRight=1, ifxPnSLeft, 152 ifxVXVibrato=1, ifxVXTremor, 153 ifxPXVibrato=1, ifxPXArpeggio, 154 ifxPnXVibrato=1, 155 ifxNXNoteCut=1, ifxNXRetrig, ifxNXDelay, 156 157 ifxVolSlideUp=1, ifxVolSlideDown, 158 ifxRowVolSlideUp, ifxRowVolSlideDown, 159 ifxPitchSlideUp, ifxPitchSlideDown, ifxPitchSlideToNote, 160 ifxRowPitchSlideUp, ifxRowPitchSlideDown, 161 ifxPanSlideRight, ifxPanSlideLeft, 162 ifxVolVibrato, ifxTremor, 163 ifxPitchVibrato, ifxArpeggio, 164 ifxNoteCut, ifxRetrig, 165 ifxOffset, ifxEnvPos, 166 ifxDelay, 167 ifxChanVolSlideUp, ifxChanVolSlideDown, 168 ifxRowChanVolSlideUp, ifxRowChanVolSlideDown, 169 ifxPastCut, ifxPastOff, ifxPastFade, 170 ifxVEnvOff, ifxVEnvOn, ifxPEnvOff, ifxPEnvOn, ifxFEnvOff, ifxFEnvOn, 171 ifxPanBrello 172 }; 173 174 struct it_logchan; 175 176 struct it_physchan 177 { 178 int no; 179 int lch; 180 struct it_logchan *lchp; 181 const struct it_sample *smp; 182 const struct it_instrument *inst; 183 int note; 184 int newsamp; 185 int newpos; 186 int vol; 187 int fvol; 188 int pan; 189 int fpan; 190 int cutoff; 191 int fcutoff; 192 int reso; 193 int srnd; 194 int pitch; 195 int fpitch; 196 int fadeval; 197 int fadespd; 198 int notefade; 199 int notecut; 200 int noteoff; 201 int dead; 202 int looptype; 203 int volenv; 204 int panenv; 205 int pitchenv; 206 int filterenv; 207 int penvtype; 208 int panenvpos; 209 int volenvpos; 210 int pitchenvpos; 211 int filterenvpos; 212 int noteoffset; 213 int avibpos; 214 int avibdep; 215 }; 216 217 struct it_logchan 218 { 219 struct it_physchan *pch; 220 struct it_physchan newchan; 221 int lastins; 222 int curnote; 223 int lastnote; 224 int cvol; 225 int vol; 226 int fvol; 227 int cpan; 228 int pan; 229 int fpan; 230 int srnd; 231 int pitch; 232 int fpitch; 233 int dpitch; 234 int cutoff; 235 int fcutoff; 236 int reso; 237 int mute; 238 int disabled; 239 int vcmd; 240 int command; 241 int specialcmd; 242 int specialdata; 243 int volslide; 244 int cvolslide; 245 int panslide; 246 int gvolslide; 247 int vibspd; 248 int vibdep; 249 int vibtype; 250 int vibpos; 251 int tremspd; 252 int tremdep; 253 int tremtype; 254 int trempos; 255 int panbrspd; 256 int panbrdep; 257 int panbrtype; 258 int panbrpos; 259 int panbrrnd; 260 int arpeggio1; 261 int arpeggio2; 262 int offset; 263 int porta; 264 int vporta; /* volume column */ 265 int eporta; /* effect column */ 266 int portanote; 267 int vportanote; /* volume column */ 268 int eportanote; /* volume column */ 269 int vvolslide; 270 int retrigpos; 271 int retrigspd; 272 int retrigvol; 273 int tremoroff; 274 int tremoron; 275 int tremoroncounter; 276 int tremoroffcounter; 277 int patloopstart; 278 int patloopcount; 279 int nna; 280 int realnote; 281 int basenote; 282 int realsync; 283 int realsynctime; 284 uint8_t delayed[8]; 285 int tempo; 286 int evpos0; 287 int evmodtype; 288 int evmod; 289 int evmodpos; 290 int evpos; 291 int evtime; 292 int sfznum; 293 uint8_t fnotehit; 294 uint8_t fvolslide; 295 uint8_t fpitchslide; 296 uint8_t fpanslide; 297 uint8_t fvolfx; 298 uint8_t fpitchfx; 299 uint8_t fnotefx; 300 uint8_t fx; 301 }; 302 303 304 305 struct itplayer 306 { 307 int randseed; 308 309 int pitchhigh; 310 int pitchlow; 311 int gotoord; 312 int gotorow; 313 int manualgoto; 314 int patdelayrow; 315 int patdelaytick; 316 uint8_t *patptr; 317 int linear; 318 int oldfx; 319 int instmode; 320 int geffect; 321 int chsep; 322 int speed; 323 int tempo; 324 int gvol; 325 int gvolslide; 326 int curtick; 327 int currow; 328 int curord; 329 int endord; 330 int nord; 331 int nchan; 332 int npchan; 333 int ninst; 334 int nsamp; 335 int nsampi; 336 int noloop; 337 int looped; 338 struct it_logchan *channels; 339 struct it_physchan *pchannels; 340 const struct it_instrument *instruments; 341 const struct it_sample *samples; 342 const struct it_sampleinfo *sampleinfos; 343 const uint16_t *orders; 344 uint8_t **patterns; 345 const uint16_t *patlens; 346 char **midicmds; 347 348 int (*que)[4]; 349 int querpos; 350 int quewpos; 351 int quelen; 352 int proctime; 353 int realpos; 354 int realsync; 355 int realsynctime; 356 int realtempo; 357 int realspeed; 358 int realgvol; 359 360 enum 361 { 362 quePos, queSync, queTempo, queSpeed, queGVol 363 } que_types; 364 }; 365 366 extern int __attribute__ ((visibility ("internal"))) loadsamples(struct it_module *m);/* - done */ 367 extern int __attribute__ ((visibility ("internal"))) play(struct itplayer *this, const struct it_module *m, int ch, struct ocpfilehandle_t *file); /* - done */ 368 extern void __attribute__ ((visibility ("internal"))) stop(struct itplayer *this); /* - done */ 369 370 extern int __attribute__ ((visibility ("internal"))) getsync(struct itplayer *this, int ch, int *time); /* - done */ 371 extern int __attribute__ ((visibility ("internal"))) getpos(struct itplayer *this); /* - done */ 372 extern int __attribute__ ((visibility ("internal"))) getrealpos(struct itplayer *this); /* - done */ 373 /* extern int __attribute__ ((visibility ("internal"))) getticktime(struct itplayer *this); */ /* - done */ 374 /* extern int __attribute__ ((visibility ("internal"))) getrowtime(struct itplayer *this); */ /* - done */ 375 /* extern void __attribute__ ((visibility ("internal"))) setevpos(struct itplayer *this, int ch, int pos, int modtype, int mod); */ /* - done */ 376 /* extern int __attribute__ ((visibility ("internal"))) getevpos(struct itplayer *this, int ch, int *time); */ /* - done */ 377 /* extern int __attribute__ ((visibility ("internal"))) findevpos(struct itplayer *this, int pos, int *time); */ /* - done */ 378 extern void __attribute__ ((visibility ("internal"))) setpos(struct itplayer *this, int ord, int row); /* - done */ 379 extern void __attribute__ ((visibility ("internal"))) mutechan(struct itplayer *this, int c, int m); /* - done */ 380 extern void __attribute__ ((visibility ("internal"))) getglobinfo(struct itplayer *this, int *speed, int *bpm, int *gvol, int *gs); /* - done */ 381 extern int __attribute__ ((visibility ("internal"))) getchansample(struct itplayer *this, int ch, int16_t *buf, int len, uint32_t rate, int opt); /* - done */ 382 extern int __attribute__ ((visibility ("internal"))) getdotsdata(struct itplayer *this, int ch, int pch, int *smp, int *note, int *voll, int *volr, int *sus); /* - done */ 383 extern void __attribute__ ((visibility ("internal"))) itplayer_getrealvol(struct itplayer *this, int ch, int *l, int *r); /* - done */ 384 extern void __attribute__ ((visibility ("internal"))) setloop(struct itplayer *this, int s); /* - done */ 385 extern int __attribute__ ((visibility ("internal"))) getloop(struct itplayer *this); /* - done */ 386 extern int __attribute__ ((visibility ("internal"))) chanactive(struct itplayer *this, int ch, int *lc); /* - done */ 387 extern int __attribute__ ((visibility ("internal"))) getchanins(struct itplayer *this, int ch); /* - done */ 388 extern int __attribute__ ((visibility ("internal"))) getchansamp(struct itplayer *this, int ch); /* - done */ 389 extern int __attribute__ ((visibility ("internal"))) lchanactive(struct itplayer *, int lc); /* - done */ 390 extern void __attribute__ ((visibility ("internal"))) getchaninfo(struct itplayer *this, uint8_t ch, struct it_chaninfo *ci); /* - done */ 391 extern int __attribute__ ((visibility ("internal"))) getchanalloc(struct itplayer *this, uint8_t ch); /* - done */ 392 393 /* 394 #####static void playtickstatic(struct itplayer *); - done 395 #####static itplayerclass *staticthis; # - done 396 static void playtick(struct itplayer *this); - done 397 398 static void readque(struct itplayer *this); - done 399 static void putque(struct itplayer *this, int type, int val1, int val2); - done 400 401 static void playnote(struct itplayer *, it_logchan *c, const uint8_t *cmd); - done 402 static void playvcmd(struct itplayer *, struct it_logchan *c, int vcmd); - done 403 static void playcmd(struct itplayer *this, struct it_logchan *c, int cmd, int data); 404 static void inittickchan(struct it_physchan *p); - done 405 static void inittick(struct it_logchan *c); - done 406 static void initrow(struct it_logchan *c); - done 407 static void updatechan(struct logchan *c); - done 408 static void processfx(struct itplayer *this, struct it_logchan *c); - done 409 static void processchan(struct itplayer *this, struct it_physchan *p); - done 410 static void allocatechan(struct itplayer *this, struct it_logchan *c); - done 411 static void putchandata(struct itplayer *this, struct it_physchan *p); - done 412 static void putglobdata(struct itplayer *this); - done 413 static void getproctime(struct itplayer *this); - done 414 static void checkchan(struct itplayer *this, struct it_physchan *p); - done 415 static int range64(int v); - done 416 static int range128(int v); - done 417 static int rangepitch(struct itplayer *this, int p); - done 418 static int rowslide(int data); - done 419 static int rowvolslide(int data); - done 420 static int tickslide(int data); - done 421 static int rowudslide(int data); - done 422 static void dovibrato(struct itplayer *this, struct it_logchan *c); - done 423 static void dotremolo(struct itplayer *this, struct it_logchan *c); - done 424 static void dopanbrello(struct itplayer *this, struct it_logchan *c); - done 425 static void doportanote(struct itplayer *this, struct it_logchan *c); - done 426 static void doretrigger(struct it_logchan *c); - done 427 static void dotremor(struct it_logchan *c); - done 428 static void dodelay(struct itplayer *this, struct it_logchan *c); - done 429 static int ishex(char c); - done 430 static void parsemidicmd(struct it_logchan *c, char *cmd, int z); - done 431 static int random(struct itplayer *this); - done 432 static int processenvelope(const struct it_envelope *env, int *pos, int noteoff, int active); - done 433 */ 434 435 extern void __attribute__ ((visibility ("internal"))) itpInstSetup(const struct it_instrument *ins, int nins, const struct it_sample *smp, int nsmp, const struct it_sampleinfo *smpi,/* int unused,*/ int type, void (*MarkyBoy)(uint8_t *, uint8_t *)); /* private, done */ 436 437 extern void __attribute__ ((visibility ("internal"))) itTrkSetup(const struct it_module *mod); /* private, done */ 438 439 extern __attribute__ ((visibility ("internal"))) struct itplayer itplayer; 440 #endif 441