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