1 /* MikMod sound library 2 (c) 1998-2014 Miodrag Vallat and others - see the AUTHORS file 3 for complete list. 4 5 This library is free software; you can redistribute it and/or modify 6 it under the terms of the GNU Library General Public License as 7 published by the Free Software Foundation; either version 2 of 8 the License, or (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public 16 License along with this library; if not, write to the Free Software 17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 18 02111-1307, USA. 19 */ 20 21 /*============================================================================== 22 23 MikMod sound library include file 24 25 ==============================================================================*/ 26 27 #ifndef _MIKMOD_H_ 28 #define _MIKMOD_H_ 29 30 #include <stdio.h> 31 #include <stdlib.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* 38 * ========== Compiler magic for shared libraries 39 * 40 * ========== NOTE TO WINDOWS DEVELOPERS: 41 * If you are compiling for Windows and will link to the static library 42 * (libmikmod.a with MinGW, or mikmod_static.lib with MSVC or LCC, etc), 43 * you must define MIKMOD_STATIC in your project. Otherwise, dllimport 44 * will be assumed. 45 */ 46 #if defined(_WIN32) || defined(__CYGWIN__) 47 # if defined(MIKMOD_BUILD) && defined(DLL_EXPORT) /* building libmikmod as a dll for windows */ 48 # define MIKMODAPI __declspec(dllexport) 49 # elif defined(MIKMOD_BUILD) || defined(MIKMOD_STATIC) /* building or using static libmikmod for windows */ 50 # define MIKMODAPI 51 # else 52 # define MIKMODAPI __declspec(dllimport) /* using libmikmod dll for windows */ 53 # endif 54 #elif defined(__OS2__) && defined(__WATCOMC__) 55 # if defined(MIKMOD_BUILD) && defined(__SW_BD) /* building libmikmod as a dll for os/2 */ 56 # define MIKMODAPI __declspec(dllexport) 57 # else 58 # define MIKMODAPI /* using dll or static libmikmod for os/2 */ 59 # endif 60 /* SYM_VISIBILITY should be defined if both the compiler 61 * and the target support the visibility attributes. the 62 * configury does that automatically. for the standalone 63 * makefiles, etc, the developer should add the required 64 * flags, i.e.: -DSYM_VISIBILITY -fvisibility=hidden */ 65 #elif defined(MIKMOD_BUILD) && defined(SYM_VISIBILITY) 66 # define MIKMODAPI __attribute__((visibility("default"))) 67 #else 68 # define MIKMODAPI 69 #endif 70 71 /* 72 * ========== Library version 73 */ 74 75 #define LIBMIKMOD_VERSION_MAJOR 3L 76 #define LIBMIKMOD_VERSION_MINOR 3L 77 #define LIBMIKMOD_REVISION 11L 78 79 #define LIBMIKMOD_VERSION \ 80 ((LIBMIKMOD_VERSION_MAJOR<<16)| \ 81 (LIBMIKMOD_VERSION_MINOR<< 8)| \ 82 (LIBMIKMOD_REVISION)) 83 84 MIKMODAPI extern long MikMod_GetVersion(void); 85 86 /* 87 * ========== Dependency platform headers 88 */ 89 90 #ifdef _WIN32 91 #ifndef WIN32_LEAN_AND_MEAN 92 #define WIN32_LEAN_AND_MEAN 93 #endif 94 #include <windows.h> 95 #include <io.h> 96 #include <mmsystem.h> 97 #define _MIKMOD_WIN32 98 #endif 99 100 #if defined(__DJGPP__) || defined(MSDOS) || defined(__MSDOS__) || defined(__DOS__) 101 #define _MIKMOD_DOS 102 #endif 103 104 #if defined(__OS2__) || defined(__EMX__) 105 #define INCL_DOSSEMAPHORES 106 #include <os2.h> 107 #include <io.h> 108 #define _MIKMOD_OS2 109 #endif 110 111 #if defined(__MORPHOS__) || defined(__AROS__) || defined(_AMIGA) || defined(__AMIGA__) || defined(__amigaos__) || defined(AMIGAOS) 112 #include <exec/types.h> 113 #define _MIKMOD_AMIGA 114 #endif 115 116 /* 117 * ========== Platform independent-type definitions 118 * (pain when it comes to cross-platform maintenance..) 119 */ 120 121 #if !(defined(_MIKMOD_OS2) || defined(_MIKMOD_WIN32)) 122 typedef char CHAR; 123 #endif 124 125 /* BOOL: 0=false, <>0 true -- 16 bits on Amiga, int-wide on others. */ 126 #if !(defined(_MIKMOD_OS2) || defined(_MIKMOD_WIN32) || defined(_MIKMOD_AMIGA)) 127 typedef int BOOL; 128 #endif 129 130 /* 1 byte, signed and unsigned: */ 131 typedef signed char SBYTE; 132 #ifndef _MIKMOD_AMIGA 133 typedef unsigned char UBYTE; 134 #endif 135 136 /* 2 bytes, signed and unsigned: */ 137 #if !(defined __LCC__ && defined _WIN32) 138 typedef signed short int SWORD; 139 #endif 140 #if !((defined __LCC__ && defined _WIN32) || defined(_MIKMOD_AMIGA)) 141 typedef unsigned short int UWORD; 142 #endif 143 144 /* 4 bytes, signed and unsigned: */ 145 #if defined(_LP64) || defined(__LP64__) || defined(__arch64__) || defined(__alpha) || defined(__x86_64) || defined(__powerpc64__) 146 /* 64 bit architectures: */ 147 typedef signed int SLONG; 148 #if !(defined(_WIN32) || defined(_MIKMOD_AMIGA)) 149 typedef unsigned int ULONG; 150 #endif 151 152 #else /* 32 bit architectures: */ 153 typedef signed long int SLONG; 154 #if !(defined(_MIKMOD_OS2) || defined(_MIKMOD_WIN32) || defined(_MIKMOD_AMIGA)) 155 typedef unsigned long int ULONG; 156 #endif 157 #endif 158 159 /* make sure types are of correct sizes: */ 160 typedef int __mikmod_typetest [ 161 ( 162 (sizeof(SBYTE)==1) && (sizeof(UBYTE)==1) 163 && (sizeof(SWORD)==2) && (sizeof(UWORD)==2) 164 && (sizeof(SLONG)==4) && (sizeof(ULONG)==4) 165 #ifndef _MIKMOD_AMIGA 166 && (sizeof(BOOL) == sizeof(int)) 167 #endif 168 && (sizeof(CHAR) == sizeof(char)) 169 ) * 2 - 1 ]; 170 171 /* 172 * ========== Error codes 173 */ 174 175 enum { 176 MMERR_OPENING_FILE = 1, 177 MMERR_OUT_OF_MEMORY, 178 MMERR_DYNAMIC_LINKING, 179 180 MMERR_SAMPLE_TOO_BIG, 181 MMERR_OUT_OF_HANDLES, 182 MMERR_UNKNOWN_WAVE_TYPE, 183 184 MMERR_LOADING_PATTERN, 185 MMERR_LOADING_TRACK, 186 MMERR_LOADING_HEADER, 187 MMERR_LOADING_SAMPLEINFO, 188 MMERR_NOT_A_MODULE, 189 MMERR_NOT_A_STREAM, 190 MMERR_MED_SYNTHSAMPLES, 191 MMERR_ITPACK_INVALID_DATA, 192 193 MMERR_DETECTING_DEVICE, 194 MMERR_INVALID_DEVICE, 195 MMERR_INITIALIZING_MIXER, 196 MMERR_OPENING_AUDIO, 197 MMERR_8BIT_ONLY, 198 MMERR_16BIT_ONLY, 199 MMERR_STEREO_ONLY, 200 MMERR_ULAW, 201 MMERR_NON_BLOCK, 202 203 MMERR_AF_AUDIO_PORT, 204 205 MMERR_AIX_CONFIG_INIT, 206 MMERR_AIX_CONFIG_CONTROL, 207 MMERR_AIX_CONFIG_START, 208 209 MMERR_GUS_SETTINGS, 210 MMERR_GUS_RESET, 211 MMERR_GUS_TIMER, 212 213 MMERR_HP_SETSAMPLESIZE, 214 MMERR_HP_SETSPEED, 215 MMERR_HP_CHANNELS, 216 MMERR_HP_AUDIO_OUTPUT, 217 MMERR_HP_AUDIO_DESC, 218 MMERR_HP_BUFFERSIZE, 219 220 MMERR_OSS_SETFRAGMENT, 221 MMERR_OSS_SETSAMPLESIZE, 222 MMERR_OSS_SETSTEREO, 223 MMERR_OSS_SETSPEED, 224 225 MMERR_SGI_SPEED, 226 MMERR_SGI_16BIT, 227 MMERR_SGI_8BIT, 228 MMERR_SGI_STEREO, 229 MMERR_SGI_MONO, 230 231 MMERR_SUN_INIT, 232 233 MMERR_OS2_MIXSETUP, 234 MMERR_OS2_SEMAPHORE, 235 MMERR_OS2_TIMER, 236 MMERR_OS2_THREAD, 237 238 MMERR_DS_PRIORITY, 239 MMERR_DS_BUFFER, 240 MMERR_DS_FORMAT, 241 MMERR_DS_NOTIFY, 242 MMERR_DS_EVENT, 243 MMERR_DS_THREAD, 244 MMERR_DS_UPDATE, 245 246 MMERR_WINMM_HANDLE, 247 MMERR_WINMM_ALLOCATED, 248 MMERR_WINMM_DEVICEID, 249 MMERR_WINMM_FORMAT, 250 MMERR_WINMM_UNKNOWN, 251 252 MMERR_MAC_SPEED, 253 MMERR_MAC_START, 254 255 MMERR_OSX_UNKNOWN_DEVICE, 256 MMERR_OSX_BAD_PROPERTY, 257 MMERR_OSX_UNSUPPORTED_FORMAT, 258 MMERR_OSX_SET_STEREO, 259 MMERR_OSX_BUFFER_ALLOC, 260 MMERR_OSX_ADD_IO_PROC, 261 MMERR_OSX_DEVICE_START, 262 MMERR_OSX_PTHREAD, 263 264 MMERR_DOSWSS_STARTDMA, 265 MMERR_DOSSB_STARTDMA, 266 267 MMERR_NO_FLOAT32,/* should actually be after MMERR_ULAW or something */ 268 269 MMERR_OPENAL_CREATECTX, 270 MMERR_OPENAL_CTXCURRENT, 271 MMERR_OPENAL_GENBUFFERS, 272 MMERR_OPENAL_GENSOURCES, 273 MMERR_OPENAL_SOURCE, 274 MMERR_OPENAL_QUEUEBUFFERS, 275 MMERR_OPENAL_UNQUEUEBUFFERS, 276 MMERR_OPENAL_BUFFERDATA, 277 MMERR_OPENAL_GETSOURCE, 278 MMERR_OPENAL_SOURCEPLAY, 279 MMERR_OPENAL_SOURCESTOP, 280 281 MMERR_ALSA_NOCONFIG, 282 MMERR_ALSA_SETPARAMS, 283 MMERR_ALSA_SETFORMAT, 284 MMERR_ALSA_SETRATE, 285 MMERR_ALSA_SETCHANNELS, 286 MMERR_ALSA_BUFFERSIZE, 287 MMERR_ALSA_PCM_START, 288 MMERR_ALSA_PCM_WRITE, 289 MMERR_ALSA_PCM_RECOVER, 290 291 MMERR_SNDIO_SETPARAMS, 292 MMERR_SNDIO_BADPARAMS, 293 294 MMERR_MAX 295 }; 296 297 /* 298 * ========== Error handling 299 */ 300 301 typedef void (MikMod_handler)(void); 302 typedef MikMod_handler *MikMod_handler_t; 303 304 MIKMODAPI extern int MikMod_errno; 305 MIKMODAPI extern BOOL MikMod_critical; 306 MIKMODAPI extern const char *MikMod_strerror(int); 307 308 MIKMODAPI extern MikMod_handler_t MikMod_RegisterErrorHandler(MikMod_handler_t); 309 310 /* 311 * ========== Library initialization and core functions 312 */ 313 314 struct MDRIVER; 315 316 MIKMODAPI extern void MikMod_RegisterAllDrivers(void); 317 318 MIKMODAPI extern CHAR* MikMod_InfoDriver(void); 319 MIKMODAPI extern void MikMod_RegisterDriver(struct MDRIVER*); 320 MIKMODAPI extern int MikMod_DriverFromAlias(const CHAR*); 321 MIKMODAPI extern struct MDRIVER *MikMod_DriverByOrdinal(int); 322 323 MIKMODAPI extern int MikMod_Init(const CHAR*); 324 MIKMODAPI extern void MikMod_Exit(void); 325 MIKMODAPI extern int MikMod_Reset(const CHAR*); 326 MIKMODAPI extern int MikMod_SetNumVoices(int,int); 327 MIKMODAPI extern BOOL MikMod_Active(void); 328 MIKMODAPI extern int MikMod_EnableOutput(void); 329 MIKMODAPI extern void MikMod_DisableOutput(void); 330 MIKMODAPI extern void MikMod_Update(void); 331 332 MIKMODAPI extern BOOL MikMod_InitThreads(void); 333 MIKMODAPI extern void MikMod_Lock(void); 334 MIKMODAPI extern void MikMod_Unlock(void); 335 336 MIKMODAPI extern void* MikMod_malloc(size_t); 337 MIKMODAPI extern void* MikMod_calloc(size_t,size_t); 338 MIKMODAPI extern void* MikMod_realloc(void*,size_t); 339 MIKMODAPI extern CHAR* MikMod_strdup(const CHAR*); 340 MIKMODAPI extern void MikMod_free(void*); /* frees if ptr != NULL */ 341 342 /* 343 * ========== Reader, Writer 344 */ 345 346 typedef struct MREADER { 347 int (*Seek)(struct MREADER*,long,int); 348 long (*Tell)(struct MREADER*); 349 BOOL (*Read)(struct MREADER*,void*,size_t); 350 int (*Get)(struct MREADER*); 351 BOOL (*Eof)(struct MREADER*); 352 long iobase; 353 long prev_iobase; 354 } MREADER; 355 356 typedef struct MWRITER { 357 int (*Seek)(struct MWRITER*, long, int); 358 long (*Tell)(struct MWRITER*); 359 BOOL (*Write)(struct MWRITER*, const void*, size_t); 360 int (*Put)(struct MWRITER*, int); 361 } MWRITER; 362 363 /* 364 * ========== Samples 365 */ 366 367 /* Sample playback should not be interrupted */ 368 #define SFX_CRITICAL 1 369 370 /* Sample format [loading and in-memory] flags: */ 371 #define SF_16BITS 0x0001 372 #define SF_STEREO 0x0002 373 #define SF_SIGNED 0x0004 374 #define SF_BIG_ENDIAN 0x0008 375 #define SF_DELTA 0x0010 376 #define SF_ITPACKED 0x0020 377 378 #define SF_FORMATMASK 0x003F 379 380 /* General Playback flags */ 381 382 #define SF_LOOP 0x0100 383 #define SF_BIDI 0x0200 384 #define SF_REVERSE 0x0400 385 #define SF_SUSTAIN 0x0800 386 387 #define SF_PLAYBACKMASK 0x0C00 388 389 /* Module-only Playback Flags */ 390 391 #define SF_OWNPAN 0x1000 392 #define SF_UST_LOOP 0x2000 393 394 #define SF_EXTRAPLAYBACKMASK 0x3000 395 396 /* Panning constants */ 397 #define PAN_LEFT 0 398 #define PAN_HALFLEFT 64 399 #define PAN_CENTER 128 400 #define PAN_HALFRIGHT 192 401 #define PAN_RIGHT 255 402 #define PAN_SURROUND 512 /* panning value for Dolby Surround */ 403 404 typedef struct SAMPLE { 405 SWORD panning; /* panning (0-255 or PAN_SURROUND) */ 406 ULONG speed; /* Base playing speed/frequency of note */ 407 UBYTE volume; /* volume 0-64 */ 408 UWORD inflags; /* sample format on disk */ 409 UWORD flags; /* sample format in memory */ 410 ULONG length; /* length of sample (in samples!) */ 411 ULONG loopstart; /* repeat position (relative to start, in samples) */ 412 ULONG loopend; /* repeat end */ 413 ULONG susbegin; /* sustain loop begin (in samples) \ Not Supported */ 414 ULONG susend; /* sustain loop end / Yet! */ 415 416 /* Variables used by the module player only! (ignored for sound effects) */ 417 UBYTE globvol; /* global volume */ 418 UBYTE vibflags; /* autovibrato flag stuffs */ 419 UBYTE vibtype; /* Vibratos moved from INSTRUMENT to SAMPLE */ 420 UBYTE vibsweep; 421 UBYTE vibdepth; 422 UBYTE vibrate; 423 CHAR* samplename; /* name of the sample */ 424 425 /* Values used internally only */ 426 UWORD avibpos; /* autovibrato pos [player use] */ 427 UBYTE divfactor; /* for sample scaling, maintains proper period slides */ 428 ULONG seekpos; /* seek position in file */ 429 SWORD handle; /* sample handle used by individual drivers */ 430 void (*onfree)(void *ctx); /* called from Sample_Free if not NULL */ 431 void *ctx; /* context passed to previous function*/ 432 } SAMPLE; 433 434 /* Sample functions */ 435 436 MIKMODAPI extern SAMPLE *Sample_LoadRaw(const CHAR *,ULONG rate, ULONG channel, ULONG flags); 437 MIKMODAPI extern SAMPLE *Sample_LoadRawFP(FILE *fp,ULONG rate,ULONG channel, ULONG flags); 438 MIKMODAPI extern SAMPLE *Sample_LoadRawMem(const char *buf, int len, ULONG rate, ULONG channel, ULONG flags); 439 MIKMODAPI extern SAMPLE *Sample_LoadRawGeneric(MREADER*reader,ULONG rate, ULONG channel, ULONG flags); 440 441 MIKMODAPI extern SAMPLE *Sample_Load(const CHAR*); 442 MIKMODAPI extern SAMPLE *Sample_LoadFP(FILE*); 443 MIKMODAPI extern SAMPLE *Sample_LoadMem(const char *buf, int len); 444 MIKMODAPI extern SAMPLE *Sample_LoadGeneric(MREADER*); 445 MIKMODAPI extern void Sample_Free(SAMPLE*); 446 MIKMODAPI extern SBYTE Sample_Play(SAMPLE*,ULONG,UBYTE); 447 448 MIKMODAPI extern void Voice_SetVolume(SBYTE,UWORD); 449 MIKMODAPI extern UWORD Voice_GetVolume(SBYTE); 450 MIKMODAPI extern void Voice_SetFrequency(SBYTE,ULONG); 451 MIKMODAPI extern ULONG Voice_GetFrequency(SBYTE); 452 MIKMODAPI extern void Voice_SetPanning(SBYTE,ULONG); 453 MIKMODAPI extern ULONG Voice_GetPanning(SBYTE); 454 MIKMODAPI extern void Voice_Play(SBYTE,SAMPLE*,ULONG); 455 MIKMODAPI extern void Voice_Stop(SBYTE); 456 MIKMODAPI extern BOOL Voice_Stopped(SBYTE); 457 MIKMODAPI extern SLONG Voice_GetPosition(SBYTE); 458 MIKMODAPI extern ULONG Voice_RealVolume(SBYTE); 459 460 /* 461 * ========== Internal module representation (UniMod) 462 */ 463 464 /* 465 Instrument definition - for information only, the only field which may be 466 of use in user programs is the name field 467 */ 468 469 /* Instrument note count */ 470 #define INSTNOTES 120 471 472 /* Envelope point */ 473 typedef struct ENVPT { 474 SWORD pos; 475 SWORD val; 476 } ENVPT; 477 478 /* Envelope point count */ 479 #define ENVPOINTS 32 480 481 /* Instrument structure */ 482 typedef struct INSTRUMENT { 483 CHAR* insname; 484 485 UBYTE flags; 486 UWORD samplenumber[INSTNOTES]; 487 UBYTE samplenote[INSTNOTES]; 488 489 UBYTE nnatype; 490 UBYTE dca; /* duplicate check action */ 491 UBYTE dct; /* duplicate check type */ 492 UBYTE globvol; 493 UWORD volfade; 494 SWORD panning; /* instrument-based panning var */ 495 496 UBYTE pitpansep; /* pitch pan separation (0 to 255) */ 497 UBYTE pitpancenter; /* pitch pan center (0 to 119) */ 498 UBYTE rvolvar; /* random volume varations (0 - 100%) */ 499 UBYTE rpanvar; /* random panning varations (0 - 100%) */ 500 501 /* volume envelope */ 502 UBYTE volflg; /* bit 0: on 1: sustain 2: loop */ 503 UBYTE volpts; 504 UBYTE volsusbeg; 505 UBYTE volsusend; 506 UBYTE volbeg; 507 UBYTE volend; 508 ENVPT volenv[ENVPOINTS]; 509 /* panning envelope */ 510 UBYTE panflg; /* bit 0: on 1: sustain 2: loop */ 511 UBYTE panpts; 512 UBYTE pansusbeg; 513 UBYTE pansusend; 514 UBYTE panbeg; 515 UBYTE panend; 516 ENVPT panenv[ENVPOINTS]; 517 /* pitch envelope */ 518 UBYTE pitflg; /* bit 0: on 1: sustain 2: loop */ 519 UBYTE pitpts; 520 UBYTE pitsusbeg; 521 UBYTE pitsusend; 522 UBYTE pitbeg; 523 UBYTE pitend; 524 ENVPT pitenv[ENVPOINTS]; 525 } INSTRUMENT; 526 527 struct MP_CONTROL; 528 struct MP_VOICE; 529 530 /* 531 Module definition 532 */ 533 534 /* maximum master channels supported */ 535 #define UF_MAXCHAN 64 536 537 /* Module flags */ 538 #define UF_XMPERIODS 0x0001 /* XM periods / finetuning */ 539 #define UF_LINEAR 0x0002 /* LINEAR periods (UF_XMPERIODS must be set) */ 540 #define UF_INST 0x0004 /* Instruments are used */ 541 #define UF_NNA 0x0008 /* IT: NNA used, set numvoices rather 542 than numchn */ 543 #define UF_S3MSLIDES 0x0010 /* uses old S3M volume slides */ 544 #define UF_BGSLIDES 0x0020 /* continue volume slides in the background */ 545 #define UF_HIGHBPM 0x0040 /* MED: can use >255 bpm */ 546 #define UF_NOWRAP 0x0080 /* XM-type (i.e. illogical) pattern break 547 semantics */ 548 #define UF_ARPMEM 0x0100 /* IT: need arpeggio memory */ 549 #define UF_FT2QUIRKS 0x0200 /* emulate some FT2 replay quirks */ 550 #define UF_PANNING 0x0400 /* module uses panning effects or have 551 non-tracker default initial panning */ 552 553 typedef struct MODULE { 554 /* general module information */ 555 CHAR* songname; /* name of the song */ 556 CHAR* modtype; /* string type of module loaded */ 557 CHAR* comment; /* module comments */ 558 559 UWORD flags; /* See module flags above */ 560 UBYTE numchn; /* number of module channels */ 561 UBYTE numvoices; /* max # voices used for full NNA playback */ 562 UWORD numpos; /* number of positions in this song */ 563 UWORD numpat; /* number of patterns in this song */ 564 UWORD numins; /* number of instruments */ 565 UWORD numsmp; /* number of samples */ 566 567 struct INSTRUMENT* instruments; /* all instruments */ 568 struct SAMPLE* samples; /* all samples */ 569 570 UBYTE realchn; /* real number of channels used */ 571 UBYTE totalchn; /* total number of channels used (incl NNAs) */ 572 573 /* playback settings */ 574 UWORD reppos; /* restart position */ 575 UBYTE initspeed; /* initial song speed */ 576 UWORD inittempo; /* initial song tempo */ 577 UBYTE initvolume; /* initial global volume (0 - 128) */ 578 UWORD panning[UF_MAXCHAN]; /* panning positions */ 579 UBYTE chanvol[UF_MAXCHAN]; /* channel positions */ 580 UWORD bpm; /* current beats-per-minute speed */ 581 UWORD sngspd; /* current song speed */ 582 SWORD volume; /* song volume (0-128) (or user volume) */ 583 584 BOOL extspd; /* extended speed flag (default enabled) */ 585 BOOL panflag; /* panning flag (default enabled) */ 586 BOOL wrap; /* wrap module ? (default disabled) */ 587 BOOL loop; /* allow module to loop ? (default enabled) */ 588 BOOL fadeout; /* volume fade out during last pattern */ 589 590 UWORD patpos; /* current row number */ 591 SWORD sngpos; /* current song position */ 592 ULONG sngtime; /* current song time in 2^-10 seconds */ 593 594 SWORD relspd; /* relative speed factor */ 595 596 /* internal module representation */ 597 UWORD numtrk; /* number of tracks */ 598 UBYTE** tracks; /* array of numtrk pointers to tracks */ 599 UWORD* patterns; /* array of Patterns */ 600 UWORD* pattrows; /* array of number of rows for each pattern */ 601 UWORD* positions; /* all positions */ 602 603 BOOL forbid; /* if true, no player update! */ 604 UWORD numrow; /* number of rows on current pattern */ 605 UWORD vbtick; /* tick counter (counts from 0 to sngspd) */ 606 UWORD sngremainder;/* used for song time computation */ 607 608 struct MP_CONTROL* control; /* Effects Channel info (size pf->numchn) */ 609 struct MP_VOICE* voice; /* Audio Voice information (size md_numchn) */ 610 611 UBYTE globalslide; /* global volume slide rate */ 612 UBYTE pat_repcrazy;/* module has just looped to position -1 */ 613 UWORD patbrk; /* position where to start a new pattern */ 614 UBYTE patdly; /* patterndelay counter (command memory) */ 615 UBYTE patdly2; /* patterndelay counter (real one) */ 616 SWORD posjmp; /* flag to indicate a jump is needed... */ 617 UWORD bpmlimit; /* threshold to detect bpm or speed values */ 618 } MODULE; 619 620 621 /* This structure is used to query current playing voices status */ 622 typedef struct VOICEINFO { 623 INSTRUMENT* i; /* Current channel instrument */ 624 SAMPLE* s; /* Current channel sample */ 625 SWORD panning; /* panning position */ 626 SBYTE volume; /* channel's "global" volume (0..64) */ 627 UWORD period; /* period to play the sample at */ 628 UBYTE kick; /* if true = sample has been restarted */ 629 } VOICEINFO; 630 631 /* 632 * ========== Module loaders 633 */ 634 635 struct MLOADER; 636 637 MIKMODAPI extern CHAR* MikMod_InfoLoader(void); 638 MIKMODAPI extern void MikMod_RegisterAllLoaders(void); 639 MIKMODAPI extern void MikMod_RegisterLoader(struct MLOADER*); 640 641 MIKMODAPI extern struct MLOADER load_669; /* 669 and Extended-669 (by Tran/Renaissance) */ 642 MIKMODAPI extern struct MLOADER load_amf; /* DMP Advanced Module Format (by Otto Chrons) */ 643 MIKMODAPI extern struct MLOADER load_asy; /* ASYLUM Music Format 1.0 */ 644 MIKMODAPI extern struct MLOADER load_dsm; /* DSIK internal module format */ 645 MIKMODAPI extern struct MLOADER load_far; /* Farandole Composer (by Daniel Potter) */ 646 MIKMODAPI extern struct MLOADER load_gdm; /* General DigiMusic (by Edward Schlunder) */ 647 MIKMODAPI extern struct MLOADER load_gt2; /* Graoumf tracker */ 648 MIKMODAPI extern struct MLOADER load_it; /* Impulse Tracker (by Jeffrey Lim) */ 649 MIKMODAPI extern struct MLOADER load_imf; /* Imago Orpheus (by Lutz Roeder) */ 650 MIKMODAPI extern struct MLOADER load_med; /* Amiga MED modules (by Teijo Kinnunen) */ 651 MIKMODAPI extern struct MLOADER load_m15; /* Soundtracker 15-instrument */ 652 MIKMODAPI extern struct MLOADER load_mod; /* Standard 31-instrument Module loader */ 653 MIKMODAPI extern struct MLOADER load_mtm; /* Multi-Tracker Module (by Renaissance) */ 654 MIKMODAPI extern struct MLOADER load_okt; /* Amiga Oktalyzer */ 655 MIKMODAPI extern struct MLOADER load_stm; /* ScreamTracker 2 (by Future Crew) */ 656 MIKMODAPI extern struct MLOADER load_stx; /* STMIK 0.2 (by Future Crew) */ 657 MIKMODAPI extern struct MLOADER load_s3m; /* ScreamTracker 3 (by Future Crew) */ 658 MIKMODAPI extern struct MLOADER load_ult; /* UltraTracker (by MAS) */ 659 MIKMODAPI extern struct MLOADER load_umx; /* Unreal UMX container of Epic Games */ 660 MIKMODAPI extern struct MLOADER load_uni; /* MikMod and APlayer internal module format */ 661 MIKMODAPI extern struct MLOADER load_xm; /* FastTracker 2 (by Triton) */ 662 663 /* 664 * ========== Module player 665 */ 666 667 MIKMODAPI extern MODULE* Player_Load(const CHAR*,int,BOOL); 668 MIKMODAPI extern MODULE* Player_LoadFP(FILE*,int,BOOL); 669 MIKMODAPI extern MODULE* Player_LoadMem(const char *buffer,int len,int maxchan,BOOL curious); 670 MIKMODAPI extern MODULE* Player_LoadGeneric(MREADER*,int,BOOL); 671 MIKMODAPI extern CHAR* Player_LoadTitle(const CHAR*); 672 MIKMODAPI extern CHAR* Player_LoadTitleFP(FILE*); 673 MIKMODAPI extern CHAR* Player_LoadTitleMem(const char *buffer,int len); 674 MIKMODAPI extern CHAR* Player_LoadTitleGeneric(MREADER*); 675 676 MIKMODAPI extern void Player_Free(MODULE*); 677 MIKMODAPI extern void Player_Start(MODULE*); 678 MIKMODAPI extern BOOL Player_Active(void); 679 MIKMODAPI extern void Player_Stop(void); 680 MIKMODAPI extern void Player_TogglePause(void); 681 MIKMODAPI extern BOOL Player_Paused(void); 682 MIKMODAPI extern void Player_NextPosition(void); 683 MIKMODAPI extern void Player_PrevPosition(void); 684 MIKMODAPI extern void Player_SetPosition(UWORD); 685 MIKMODAPI extern BOOL Player_Muted(UBYTE); 686 MIKMODAPI extern void Player_SetVolume(SWORD); 687 MIKMODAPI extern MODULE* Player_GetModule(void); 688 MIKMODAPI extern void Player_SetSpeed(UWORD); 689 MIKMODAPI extern void Player_SetTempo(UWORD); 690 MIKMODAPI extern void Player_Unmute(SLONG,...); 691 MIKMODAPI extern void Player_Mute(SLONG,...); 692 MIKMODAPI extern void Player_ToggleMute(SLONG,...); 693 MIKMODAPI extern int Player_GetChannelVoice(UBYTE); 694 MIKMODAPI extern UWORD Player_GetChannelPeriod(UBYTE); 695 MIKMODAPI extern int Player_QueryVoices(UWORD numvoices, VOICEINFO *vinfo); 696 MIKMODAPI extern int Player_GetRow(void); 697 MIKMODAPI extern int Player_GetOrder(void); 698 699 typedef void (*MikMod_player_t)(void); 700 typedef void (*MikMod_callback_t)(unsigned char *data, size_t len); 701 702 MIKMODAPI extern MikMod_player_t MikMod_RegisterPlayer(MikMod_player_t); 703 704 #define MUTE_EXCLUSIVE 32000 705 #define MUTE_INCLUSIVE 32001 706 707 /* 708 * ========== Drivers 709 */ 710 711 enum { 712 MD_MUSIC = 0, 713 MD_SNDFX 714 }; 715 716 enum { 717 MD_HARDWARE = 0, 718 MD_SOFTWARE 719 }; 720 721 /* Mixing flags */ 722 723 /* These ones take effect only after MikMod_Init or MikMod_Reset */ 724 #define DMODE_16BITS 0x0001 /* enable 16 bit output */ 725 #define DMODE_STEREO 0x0002 /* enable stereo output */ 726 #define DMODE_SOFT_SNDFX 0x0004 /* Process sound effects via software mixer */ 727 #define DMODE_SOFT_MUSIC 0x0008 /* Process music via software mixer */ 728 #define DMODE_HQMIXER 0x0010 /* Use high-quality (slower) software mixer */ 729 #define DMODE_FLOAT 0x0020 /* enable float output */ 730 /* These take effect immediately. */ 731 #define DMODE_SURROUND 0x0100 /* enable surround sound */ 732 #define DMODE_INTERP 0x0200 /* enable interpolation */ 733 #define DMODE_REVERSE 0x0400 /* reverse stereo */ 734 #define DMODE_SIMDMIXER 0x0800 /* enable SIMD mixing */ 735 #define DMODE_NOISEREDUCTION 0x1000 /* Low pass filtering */ 736 737 738 struct SAMPLOAD; 739 740 typedef struct MDRIVER { 741 struct MDRIVER* next; 742 const CHAR* Name; 743 const CHAR* Version; 744 745 UBYTE HardVoiceLimit; /* Limit of hardware mixer voices */ 746 UBYTE SoftVoiceLimit; /* Limit of software mixer voices */ 747 748 const CHAR* Alias; 749 const CHAR* CmdLineHelp; 750 751 void (*CommandLine) (const CHAR*); 752 BOOL (*IsPresent) (void); 753 SWORD (*SampleLoad) (struct SAMPLOAD*,int); 754 void (*SampleUnload) (SWORD); 755 ULONG (*FreeSampleSpace) (int); 756 ULONG (*RealSampleLength) (int,struct SAMPLE*); 757 int (*Init) (void); 758 void (*Exit) (void); 759 int (*Reset) (void); 760 int (*SetNumVoices) (void); 761 int (*PlayStart) (void); 762 void (*PlayStop) (void); 763 void (*Update) (void); 764 void (*Pause) (void); 765 void (*VoiceSetVolume) (UBYTE,UWORD); 766 UWORD (*VoiceGetVolume) (UBYTE); 767 void (*VoiceSetFrequency)(UBYTE,ULONG); 768 ULONG (*VoiceGetFrequency)(UBYTE); 769 void (*VoiceSetPanning) (UBYTE,ULONG); 770 ULONG (*VoiceGetPanning) (UBYTE); 771 void (*VoicePlay) (UBYTE,SWORD,ULONG,ULONG,ULONG,ULONG,UWORD); 772 void (*VoiceStop) (UBYTE); 773 BOOL (*VoiceStopped) (UBYTE); 774 SLONG (*VoiceGetPosition) (UBYTE); 775 ULONG (*VoiceRealVolume) (UBYTE); 776 } MDRIVER; 777 778 /* These variables can be changed at ANY time and results will be immediate */ 779 MIKMODAPI extern UBYTE md_volume; /* global sound volume (0-128) */ 780 MIKMODAPI extern UBYTE md_musicvolume; /* volume of song */ 781 MIKMODAPI extern UBYTE md_sndfxvolume; /* volume of sound effects */ 782 MIKMODAPI extern UBYTE md_reverb; /* 0 = none; 15 = chaos */ 783 MIKMODAPI extern UBYTE md_pansep; /* 0 = mono; 128 == 100% (full left/right) */ 784 785 /* The variables below can be changed at any time, but changes will not be 786 implemented until MikMod_Reset is called. A call to MikMod_Reset may result 787 in a skip or pop in audio (depending on the soundcard driver and the settings 788 changed). */ 789 MIKMODAPI extern UWORD md_device; /* device */ 790 MIKMODAPI extern UWORD md_mixfreq; /* mixing frequency */ 791 MIKMODAPI extern UWORD md_mode; /* mode. See DMODE_? flags above */ 792 793 /* The following variable should not be changed! */ 794 MIKMODAPI extern MDRIVER* md_driver; /* Current driver in use. */ 795 796 /* Known drivers list */ 797 798 MIKMODAPI extern struct MDRIVER drv_nos; /* no sound */ 799 MIKMODAPI extern struct MDRIVER drv_pipe; /* piped output */ 800 MIKMODAPI extern struct MDRIVER drv_raw; /* raw file disk writer [music.raw] */ 801 MIKMODAPI extern struct MDRIVER drv_stdout; /* output to stdout */ 802 MIKMODAPI extern struct MDRIVER drv_wav; /* RIFF WAVE file disk writer [music.wav] */ 803 MIKMODAPI extern struct MDRIVER drv_aiff; /* AIFF file disk writer [music.aiff] */ 804 805 MIKMODAPI extern struct MDRIVER drv_ultra; /* Linux Ultrasound driver */ 806 MIKMODAPI extern struct MDRIVER drv_sam9407;/* Linux sam9407 driver */ 807 808 MIKMODAPI extern struct MDRIVER drv_AF; /* Dec Alpha AudioFile */ 809 MIKMODAPI extern struct MDRIVER drv_ahi; /* Amiga AHI */ 810 MIKMODAPI extern struct MDRIVER drv_aix; /* AIX audio device */ 811 MIKMODAPI extern struct MDRIVER drv_alsa; /* Advanced Linux Sound Architecture (ALSA) */ 812 MIKMODAPI extern struct MDRIVER drv_esd; /* Enlightened sound daemon (EsounD) */ 813 MIKMODAPI extern struct MDRIVER drv_pulseaudio; /* PulseAudio */ 814 MIKMODAPI extern struct MDRIVER drv_hp; /* HP-UX audio device */ 815 MIKMODAPI extern struct MDRIVER drv_nas; /* Network Audio System (NAS) */ 816 MIKMODAPI extern struct MDRIVER drv_oss; /* OpenSound System (Linux,FreeBSD...) */ 817 MIKMODAPI extern struct MDRIVER drv_openal; /* OpenAL driver */ 818 MIKMODAPI extern struct MDRIVER drv_sdl; /* SDL audio driver */ 819 MIKMODAPI extern struct MDRIVER drv_sgi; /* SGI audio library */ 820 MIKMODAPI extern struct MDRIVER drv_sndio; /* OpenBSD sndio */ 821 MIKMODAPI extern struct MDRIVER drv_sun; /* Sun/NetBSD/OpenBSD audio device */ 822 823 MIKMODAPI extern struct MDRIVER drv_dart; /* OS/2 Direct Audio RealTime */ 824 MIKMODAPI extern struct MDRIVER drv_os2; /* OS/2 MMPM/2 */ 825 826 MIKMODAPI extern struct MDRIVER drv_ds; /* Win32 DirectSound driver */ 827 MIKMODAPI extern struct MDRIVER drv_xaudio2;/* Win32 XAudio2 driver */ 828 MIKMODAPI extern struct MDRIVER drv_win; /* Win32 multimedia API driver */ 829 830 MIKMODAPI extern struct MDRIVER drv_mac; /* Macintosh Sound Manager driver */ 831 MIKMODAPI extern struct MDRIVER drv_osx; /* MacOS X CoreAudio Driver */ 832 833 MIKMODAPI extern struct MDRIVER drv_dc; /* Dreamcast driver */ 834 MIKMODAPI extern struct MDRIVER drv_gp32; /* GP32 Sound driver */ 835 MIKMODAPI extern struct MDRIVER drv_psp; /* PlayStation Portable driver */ 836 837 MIKMODAPI extern struct MDRIVER drv_wss; /* DOS WSS driver */ 838 MIKMODAPI extern struct MDRIVER drv_sb; /* DOS S/B driver */ 839 840 MIKMODAPI extern struct MDRIVER drv_osles; /* OpenSL ES driver for android */ 841 842 /*========== Virtual channel mixer interface (for user-supplied drivers only) */ 843 844 MIKMODAPI extern int VC_Init(void); 845 MIKMODAPI extern void VC_Exit(void); 846 MIKMODAPI extern void VC_SetCallback(MikMod_callback_t callback); 847 MIKMODAPI extern int VC_SetNumVoices(void); 848 MIKMODAPI extern ULONG VC_SampleSpace(int); 849 MIKMODAPI extern ULONG VC_SampleLength(int,SAMPLE*); 850 851 MIKMODAPI extern int VC_PlayStart(void); 852 MIKMODAPI extern void VC_PlayStop(void); 853 854 MIKMODAPI extern SWORD VC_SampleLoad(struct SAMPLOAD*,int); 855 MIKMODAPI extern void VC_SampleUnload(SWORD); 856 857 MIKMODAPI extern ULONG VC_WriteBytes(SBYTE*,ULONG); 858 MIKMODAPI extern ULONG VC_SilenceBytes(SBYTE*,ULONG); 859 860 MIKMODAPI extern void VC_VoiceSetVolume(UBYTE,UWORD); 861 MIKMODAPI extern UWORD VC_VoiceGetVolume(UBYTE); 862 MIKMODAPI extern void VC_VoiceSetFrequency(UBYTE,ULONG); 863 MIKMODAPI extern ULONG VC_VoiceGetFrequency(UBYTE); 864 MIKMODAPI extern void VC_VoiceSetPanning(UBYTE,ULONG); 865 MIKMODAPI extern ULONG VC_VoiceGetPanning(UBYTE); 866 MIKMODAPI extern void VC_VoicePlay(UBYTE,SWORD,ULONG,ULONG,ULONG,ULONG,UWORD); 867 868 MIKMODAPI extern void VC_VoiceStop(UBYTE); 869 MIKMODAPI extern BOOL VC_VoiceStopped(UBYTE); 870 MIKMODAPI extern SLONG VC_VoiceGetPosition(UBYTE); 871 MIKMODAPI extern ULONG VC_VoiceRealVolume(UBYTE); 872 873 #ifdef __cplusplus 874 } 875 #endif 876 877 #endif 878 879 /* ex:set ts=4: */ 880