1 /* MikMod sound library
2 (c) 1998-2014 Miodrag Vallat and others - see the AUTHORS file
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.
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.
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
21 /*==============================================================================
23 MikMod sound library include file
25 ==============================================================================*/
42 * ========== Compiler magic for shared libraries
44 * ========== NOTE TO WINDOWS DEVELOPERS:
45 * If you are compiling for Windows and will link to the static library
46 * (libmikmod.a with MinGW, or mikmod_static.lib with MSVC or LCC, etc),
47 * you must define MIKMOD_STATIC in your project. Otherwise, dllimport
50 #if defined(_WIN32) || defined(__CYGWIN__)
51 # if defined(MIKMOD_BUILD) && defined(DLL_EXPORT) /* building libmikmod as a dll for windows */
52 # define MIKMODAPI __declspec(dllexport)
53 # elif defined(MIKMOD_BUILD) || defined(MIKMOD_STATIC) /* building or using static libmikmod for windows */
56 # define MIKMODAPI __declspec(dllimport) /* using libmikmod dll for windows */
58 #elif defined(__OS2__) && defined(__WATCOMC__)
59 # if defined(MIKMOD_BUILD) && defined(__SW_BD) /* building libmikmod as a dll for os/2 */
60 # define MIKMODAPI __declspec(dllexport)
62 # define MIKMODAPI /* using dll or static libmikmod for os/2 */
64 /* SYM_VISIBILITY should be defined if both the compiler
65 * and the target support the visibility attributes. the
66 * configury does that automatically. for the standalone
67 * makefiles, etc, the developer should add the required
68 * flags, i.e.: -DSYM_VISIBILITY -fvisibility=hidden */
69 #elif defined(MIKMOD_BUILD) && defined(SYM_VISIBILITY)
70 # define MIKMODAPI __attribute__((visibility("default")))
76 * ========== Library version
79 #define LIBMIKMOD_VERSION_MAJOR 3L
80 #define LIBMIKMOD_VERSION_MINOR 3L
81 #define LIBMIKMOD_REVISION 10L
83 #define LIBMIKMOD_VERSION \
84 ((LIBMIKMOD_VERSION_MAJOR<<16)| \
85 (LIBMIKMOD_VERSION_MINOR<< 8)| \
88 MIKMODAPI extern long MikMod_GetVersion(void);
91 * ========== Dependency platform headers
95 #ifndef WIN32_LEAN_AND_MEAN
96 #define WIN32_LEAN_AND_MEAN
100 #include <mmsystem.h>
101 #define _MIKMOD_WIN32
104 #if defined(__DJGPP__) || defined(MSDOS) || defined(__MSDOS__) || defined(__DOS__)
108 #if defined(__OS2__) || defined(__EMX__)
109 #define INCL_DOSSEMAPHORES
115 #if defined(__MORPHOS__) || defined(__AROS__) || defined(_AMIGA) || defined(__AMIGA__) || defined(__amigaos__) || defined(AMIGAOS)
116 #include <exec/types.h>
117 #define _MIKMOD_AMIGA
121 * ========== Platform independent-type definitions
122 * (pain when it comes to cross-platform maintenance..)
125 #if !(defined(_MIKMOD_OS2) || defined(_MIKMOD_WIN32))
129 /* BOOL: 0=false, <>0 true -- 16 bits on Amiga, int-wide on others. */
130 #if !(defined(_MIKMOD_OS2) || defined(_MIKMOD_WIN32) || defined(_MIKMOD_AMIGA))
134 /* 1 byte, signed and unsigned: */
135 typedef signed char SBYTE;
136 #ifndef _MIKMOD_AMIGA
137 typedef unsigned char UBYTE;
140 /* 2 bytes, signed and unsigned: */
142 typedef signed short int SWORD;
144 #if !(defined(__LCC__) || defined(_MIKMOD_AMIGA))
145 typedef unsigned short int UWORD;
148 /* 4 bytes, signed and unsigned: */
149 #if defined(_LP64) || defined(__LP64__) || defined(__arch64__) || defined(__alpha) || defined(__x86_64) || defined(__powerpc64__)
150 /* 64 bit architectures: */
151 typedef signed int SLONG;
152 #if !(defined(_WIN32) || defined(_MIKMOD_AMIGA))
153 typedef unsigned int ULONG;
156 #else /* 32 bit architectures: */
157 typedef signed long int SLONG;
158 #if !(defined(_MIKMOD_OS2) || defined(_MIKMOD_WIN32) || defined(_MIKMOD_AMIGA))
159 typedef unsigned long int ULONG;
163 /* make sure types are of correct sizes: */
164 typedef int __mikmod_typetest [
166 (sizeof(SBYTE)==1) && (sizeof(UBYTE)==1)
167 && (sizeof(SWORD)==2) && (sizeof(UWORD)==2)
168 && (sizeof(SLONG)==4) && (sizeof(ULONG)==4)
169 #ifndef _MIKMOD_AMIGA
170 && (sizeof(BOOL) == sizeof(int))
172 && (sizeof(CHAR) == sizeof(char))
176 * ========== Error codes
180 MMERR_OPENING_FILE = 1,
182 MMERR_DYNAMIC_LINKING,
184 MMERR_SAMPLE_TOO_BIG,
185 MMERR_OUT_OF_HANDLES,
186 MMERR_UNKNOWN_WAVE_TYPE,
188 MMERR_LOADING_PATTERN,
190 MMERR_LOADING_HEADER,
191 MMERR_LOADING_SAMPLEINFO,
194 MMERR_MED_SYNTHSAMPLES,
195 MMERR_ITPACK_INVALID_DATA,
197 MMERR_DETECTING_DEVICE,
198 MMERR_INVALID_DEVICE,
199 MMERR_INITIALIZING_MIXER,
209 MMERR_AIX_CONFIG_INIT,
210 MMERR_AIX_CONFIG_CONTROL,
211 MMERR_AIX_CONFIG_START,
217 MMERR_HP_SETSAMPLESIZE,
220 MMERR_HP_AUDIO_OUTPUT,
224 MMERR_OSS_SETFRAGMENT,
225 MMERR_OSS_SETSAMPLESIZE,
251 MMERR_WINMM_ALLOCATED,
252 MMERR_WINMM_DEVICEID,
259 MMERR_OSX_UNKNOWN_DEVICE,
260 MMERR_OSX_BAD_PROPERTY,
261 MMERR_OSX_UNSUPPORTED_FORMAT,
262 MMERR_OSX_SET_STEREO,
263 MMERR_OSX_BUFFER_ALLOC,
264 MMERR_OSX_ADD_IO_PROC,
265 MMERR_OSX_DEVICE_START,
268 MMERR_DOSWSS_STARTDMA,
269 MMERR_DOSSB_STARTDMA,
271 MMERR_NO_FLOAT32,/* should actually be after MMERR_ULAW or something */
273 MMERR_OPENAL_CREATECTX,
274 MMERR_OPENAL_CTXCURRENT,
275 MMERR_OPENAL_GENBUFFERS,
276 MMERR_OPENAL_GENSOURCES,
278 MMERR_OPENAL_QUEUEBUFFERS,
279 MMERR_OPENAL_UNQUEUEBUFFERS,
280 MMERR_OPENAL_BUFFERDATA,
281 MMERR_OPENAL_GETSOURCE,
282 MMERR_OPENAL_SOURCEPLAY,
283 MMERR_OPENAL_SOURCESTOP,
286 MMERR_ALSA_SETPARAMS,
287 MMERR_ALSA_SETFORMAT,
289 MMERR_ALSA_SETCHANNELS,
290 MMERR_ALSA_BUFFERSIZE,
291 MMERR_ALSA_PCM_START,
292 MMERR_ALSA_PCM_WRITE,
293 MMERR_ALSA_PCM_RECOVER,
295 MMERR_SNDIO_SETPARAMS,
296 MMERR_SNDIO_BADPARAMS,
302 * ========== Error handling
305 typedef void (MikMod_handler)(void);
306 typedef MikMod_handler *MikMod_handler_t;
308 MIKMODAPI extern int MikMod_errno;
309 MIKMODAPI extern BOOL MikMod_critical;
310 MIKMODAPI extern const char *MikMod_strerror(int);
312 MIKMODAPI extern MikMod_handler_t MikMod_RegisterErrorHandler(MikMod_handler_t);
315 * ========== Library initialization and core functions
320 MIKMODAPI extern void MikMod_RegisterAllDrivers(void);
322 MIKMODAPI extern CHAR* MikMod_InfoDriver(void);
323 MIKMODAPI extern void MikMod_RegisterDriver(struct MDRIVER*);
324 MIKMODAPI extern int MikMod_DriverFromAlias(const CHAR*);
325 MIKMODAPI extern struct MDRIVER *MikMod_DriverByOrdinal(int);
327 MIKMODAPI extern int MikMod_Init(const CHAR*);
328 MIKMODAPI extern void MikMod_Exit(void);
329 MIKMODAPI extern int MikMod_Reset(const CHAR*);
330 MIKMODAPI extern int MikMod_SetNumVoices(int,int);
331 MIKMODAPI extern BOOL MikMod_Active(void);
332 MIKMODAPI extern int MikMod_EnableOutput(void);
333 MIKMODAPI extern void MikMod_DisableOutput(void);
334 MIKMODAPI extern void MikMod_Update(void);
336 MIKMODAPI extern BOOL MikMod_InitThreads(void);
337 MIKMODAPI extern void MikMod_Lock(void);
338 MIKMODAPI extern void MikMod_Unlock(void);
340 MIKMODAPI extern void* MikMod_malloc(size_t);
341 MIKMODAPI extern void* MikMod_calloc(size_t,size_t);
342 MIKMODAPI extern void* MikMod_realloc(void*,size_t);
343 MIKMODAPI extern CHAR* MikMod_strdup(const CHAR*);
344 MIKMODAPI extern void MikMod_free(void*); /* frees if ptr != NULL */
347 * ========== Reader, Writer
350 typedef struct MREADER {
351 int (*Seek)(struct MREADER*,long,int);
352 long (*Tell)(struct MREADER*);
353 BOOL (*Read)(struct MREADER*,void*,size_t);
354 int (*Get)(struct MREADER*);
355 BOOL (*Eof)(struct MREADER*);
360 typedef struct MWRITER {
361 int (*Seek)(struct MWRITER*, long, int);
362 long (*Tell)(struct MWRITER*);
363 BOOL (*Write)(struct MWRITER*, const void*, size_t);
364 int (*Put)(struct MWRITER*, int);
371 /* Sample playback should not be interrupted */
372 #define SFX_CRITICAL 1
374 /* Sample format [loading and in-memory] flags: */
375 #define SF_16BITS 0x0001
376 #define SF_STEREO 0x0002
377 #define SF_SIGNED 0x0004
378 #define SF_BIG_ENDIAN 0x0008
379 #define SF_DELTA 0x0010
380 #define SF_ITPACKED 0x0020
382 #define SF_FORMATMASK 0x003F
384 /* General Playback flags */
386 #define SF_LOOP 0x0100
387 #define SF_BIDI 0x0200
388 #define SF_REVERSE 0x0400
389 #define SF_SUSTAIN 0x0800
391 #define SF_PLAYBACKMASK 0x0C00
393 /* Module-only Playback Flags */
395 #define SF_OWNPAN 0x1000
396 #define SF_UST_LOOP 0x2000
398 #define SF_EXTRAPLAYBACKMASK 0x3000
400 /* Panning constants */
402 #define PAN_HALFLEFT 64
403 #define PAN_CENTER 128
404 #define PAN_HALFRIGHT 192
405 #define PAN_RIGHT 255
406 #define PAN_SURROUND 512 /* panning value for Dolby Surround */
408 typedef struct SAMPLE {
409 SWORD panning; /* panning (0-255 or PAN_SURROUND) */
410 ULONG speed; /* Base playing speed/frequency of note */
411 UBYTE volume; /* volume 0-64 */
412 UWORD inflags; /* sample format on disk */
413 UWORD flags; /* sample format in memory */
414 ULONG length; /* length of sample (in samples!) */
415 ULONG loopstart; /* repeat position (relative to start, in samples) */
416 ULONG loopend; /* repeat end */
417 ULONG susbegin; /* sustain loop begin (in samples) \ Not Supported */
418 ULONG susend; /* sustain loop end / Yet! */
420 /* Variables used by the module player only! (ignored for sound effects) */
421 UBYTE globvol; /* global volume */
422 UBYTE vibflags; /* autovibrato flag stuffs */
423 UBYTE vibtype; /* Vibratos moved from INSTRUMENT to SAMPLE */
427 CHAR* samplename; /* name of the sample */
429 /* Values used internally only */
430 UWORD avibpos; /* autovibrato pos [player use] */
431 UBYTE divfactor; /* for sample scaling, maintains proper period slides */
432 ULONG seekpos; /* seek position in file */
433 SWORD handle; /* sample handle used by individual drivers */
434 void (*onfree)(void *ctx); /* called from Sample_Free if not NULL */
435 void *ctx; /* context passed to previous function*/
438 /* Sample functions */
440 MIKMODAPI extern SAMPLE *Sample_LoadRaw(const CHAR *,ULONG rate, ULONG channel, ULONG flags);
441 MIKMODAPI extern SAMPLE *Sample_LoadRawFP(FILE *fp,ULONG rate,ULONG channel, ULONG flags);
442 MIKMODAPI extern SAMPLE *Sample_LoadRawMem(const char *buf, int len, ULONG rate, ULONG channel, ULONG flags);
443 MIKMODAPI extern SAMPLE *Sample_LoadRawGeneric(MREADER*reader,ULONG rate, ULONG channel, ULONG flags);
445 MIKMODAPI extern SAMPLE *Sample_Load(const CHAR*);
446 MIKMODAPI extern SAMPLE *Sample_LoadFP(FILE*);
447 MIKMODAPI extern SAMPLE *Sample_LoadMem(const char *buf, int len);
448 MIKMODAPI extern SAMPLE *Sample_LoadGeneric(MREADER*);
449 MIKMODAPI extern void Sample_Free(SAMPLE*);
450 MIKMODAPI extern SBYTE Sample_Play(SAMPLE*,ULONG,UBYTE);
452 MIKMODAPI extern void Voice_SetVolume(SBYTE,UWORD);
453 MIKMODAPI extern UWORD Voice_GetVolume(SBYTE);
454 MIKMODAPI extern void Voice_SetFrequency(SBYTE,ULONG);
455 MIKMODAPI extern ULONG Voice_GetFrequency(SBYTE);
456 MIKMODAPI extern void Voice_SetPanning(SBYTE,ULONG);
457 MIKMODAPI extern ULONG Voice_GetPanning(SBYTE);
458 MIKMODAPI extern void Voice_Play(SBYTE,SAMPLE*,ULONG);
459 MIKMODAPI extern void Voice_Stop(SBYTE);
460 MIKMODAPI extern BOOL Voice_Stopped(SBYTE);
461 MIKMODAPI extern SLONG Voice_GetPosition(SBYTE);
462 MIKMODAPI extern ULONG Voice_RealVolume(SBYTE);
465 * ========== Internal module representation (UniMod)
469 Instrument definition - for information only, the only field which may be
470 of use in user programs is the name field
473 /* Instrument note count */
474 #define INSTNOTES 120
477 typedef struct ENVPT {
482 /* Envelope point count */
485 /* Instrument structure */
486 typedef struct INSTRUMENT {
490 UWORD samplenumber[INSTNOTES];
491 UBYTE samplenote[INSTNOTES];
494 UBYTE dca; /* duplicate check action */
495 UBYTE dct; /* duplicate check type */
498 SWORD panning; /* instrument-based panning var */
500 UBYTE pitpansep; /* pitch pan separation (0 to 255) */
501 UBYTE pitpancenter; /* pitch pan center (0 to 119) */
502 UBYTE rvolvar; /* random volume varations (0 - 100%) */
503 UBYTE rpanvar; /* random panning varations (0 - 100%) */
505 /* volume envelope */
506 UBYTE volflg; /* bit 0: on 1: sustain 2: loop */
512 ENVPT volenv[ENVPOINTS];
513 /* panning envelope */
514 UBYTE panflg; /* bit 0: on 1: sustain 2: loop */
520 ENVPT panenv[ENVPOINTS];
522 UBYTE pitflg; /* bit 0: on 1: sustain 2: loop */
528 ENVPT pitenv[ENVPOINTS];
538 /* maximum master channels supported */
539 #define UF_MAXCHAN 64
542 #define UF_XMPERIODS 0x0001 /* XM periods / finetuning */
543 #define UF_LINEAR 0x0002 /* LINEAR periods (UF_XMPERIODS must be set) */
544 #define UF_INST 0x0004 /* Instruments are used */
545 #define UF_NNA 0x0008 /* IT: NNA used, set numvoices rather
547 #define UF_S3MSLIDES 0x0010 /* uses old S3M volume slides */
548 #define UF_BGSLIDES 0x0020 /* continue volume slides in the background */
549 #define UF_HIGHBPM 0x0040 /* MED: can use >255 bpm */
550 #define UF_NOWRAP 0x0080 /* XM-type (i.e. illogical) pattern break
552 #define UF_ARPMEM 0x0100 /* IT: need arpeggio memory */
553 #define UF_FT2QUIRKS 0x0200 /* emulate some FT2 replay quirks */
554 #define UF_PANNING 0x0400 /* module uses panning effects or have
555 non-tracker default initial panning */
557 typedef struct MODULE {
558 /* general module information */
559 CHAR* songname; /* name of the song */
560 CHAR* modtype; /* string type of module loaded */
561 CHAR* comment; /* module comments */
563 UWORD flags; /* See module flags above */
564 UBYTE numchn; /* number of module channels */
565 UBYTE numvoices; /* max # voices used for full NNA playback */
566 UWORD numpos; /* number of positions in this song */
567 UWORD numpat; /* number of patterns in this song */
568 UWORD numins; /* number of instruments */
569 UWORD numsmp; /* number of samples */
571 struct INSTRUMENT* instruments; /* all instruments */
572 struct SAMPLE* samples; /* all samples */
574 UBYTE realchn; /* real number of channels used */
575 UBYTE totalchn; /* total number of channels used (incl NNAs) */
577 /* playback settings */
578 UWORD reppos; /* restart position */
579 UBYTE initspeed; /* initial song speed */
580 UWORD inittempo; /* initial song tempo */
581 UBYTE initvolume; /* initial global volume (0 - 128) */
582 UWORD panning[UF_MAXCHAN]; /* panning positions */
583 UBYTE chanvol[UF_MAXCHAN]; /* channel positions */
584 UWORD bpm; /* current beats-per-minute speed */
585 UWORD sngspd; /* current song speed */
586 SWORD volume; /* song volume (0-128) (or user volume) */
588 BOOL extspd; /* extended speed flag (default enabled) */
589 BOOL panflag; /* panning flag (default enabled) */
590 BOOL wrap; /* wrap module ? (default disabled) */
591 BOOL loop; /* allow module to loop ? (default enabled) */
592 BOOL fadeout; /* volume fade out during last pattern */
594 UWORD patpos; /* current row number */
595 SWORD sngpos; /* current song position */
596 ULONG sngtime; /* current song time in 2^-10 seconds */
598 SWORD relspd; /* relative speed factor */
600 /* internal module representation */
601 UWORD numtrk; /* number of tracks */
602 UBYTE** tracks; /* array of numtrk pointers to tracks */
603 UWORD* patterns; /* array of Patterns */
604 UWORD* pattrows; /* array of number of rows for each pattern */
605 UWORD* positions; /* all positions */
607 BOOL forbid; /* if true, no player update! */
608 UWORD numrow; /* number of rows on current pattern */
609 UWORD vbtick; /* tick counter (counts from 0 to sngspd) */
610 UWORD sngremainder;/* used for song time computation */
612 struct MP_CONTROL* control; /* Effects Channel info (size pf->numchn) */
613 struct MP_VOICE* voice; /* Audio Voice information (size md_numchn) */
615 UBYTE globalslide; /* global volume slide rate */
616 UBYTE pat_repcrazy;/* module has just looped to position -1 */
617 UWORD patbrk; /* position where to start a new pattern */
618 UBYTE patdly; /* patterndelay counter (command memory) */
619 UBYTE patdly2; /* patterndelay counter (real one) */
620 SWORD posjmp; /* flag to indicate a jump is needed... */
621 UWORD bpmlimit; /* threshold to detect bpm or speed values */
625 /* This structure is used to query current playing voices status */
626 typedef struct VOICEINFO {
627 INSTRUMENT* i; /* Current channel instrument */
628 SAMPLE* s; /* Current channel sample */
629 SWORD panning; /* panning position */
630 SBYTE volume; /* channel's "global" volume (0..64) */
631 UWORD period; /* period to play the sample at */
632 UBYTE kick; /* if true = sample has been restarted */
636 * ========== Module loaders
641 MIKMODAPI extern CHAR* MikMod_InfoLoader(void);
642 MIKMODAPI extern void MikMod_RegisterAllLoaders(void);
643 MIKMODAPI extern void MikMod_RegisterLoader(struct MLOADER*);
645 MIKMODAPI extern struct MLOADER load_669; /* 669 and Extended-669 (by Tran/Renaissance) */
646 MIKMODAPI extern struct MLOADER load_amf; /* DMP Advanced Module Format (by Otto Chrons) */
647 MIKMODAPI extern struct MLOADER load_asy; /* ASYLUM Music Format 1.0 */
648 MIKMODAPI extern struct MLOADER load_dsm; /* DSIK internal module format */
649 MIKMODAPI extern struct MLOADER load_far; /* Farandole Composer (by Daniel Potter) */
650 MIKMODAPI extern struct MLOADER load_gdm; /* General DigiMusic (by Edward Schlunder) */
651 MIKMODAPI extern struct MLOADER load_gt2; /* Graoumf tracker */
652 MIKMODAPI extern struct MLOADER load_it; /* Impulse Tracker (by Jeffrey Lim) */
653 MIKMODAPI extern struct MLOADER load_imf; /* Imago Orpheus (by Lutz Roeder) */
654 MIKMODAPI extern struct MLOADER load_med; /* Amiga MED modules (by Teijo Kinnunen) */
655 MIKMODAPI extern struct MLOADER load_m15; /* Soundtracker 15-instrument */
656 MIKMODAPI extern struct MLOADER load_mod; /* Standard 31-instrument Module loader */
657 MIKMODAPI extern struct MLOADER load_mtm; /* Multi-Tracker Module (by Renaissance) */
658 MIKMODAPI extern struct MLOADER load_okt; /* Amiga Oktalyzer */
659 MIKMODAPI extern struct MLOADER load_stm; /* ScreamTracker 2 (by Future Crew) */
660 MIKMODAPI extern struct MLOADER load_stx; /* STMIK 0.2 (by Future Crew) */
661 MIKMODAPI extern struct MLOADER load_s3m; /* ScreamTracker 3 (by Future Crew) */
662 MIKMODAPI extern struct MLOADER load_ult; /* UltraTracker (by MAS) */
663 MIKMODAPI extern struct MLOADER load_umx; /* Unreal UMX container of Epic Games */
664 MIKMODAPI extern struct MLOADER load_uni; /* MikMod and APlayer internal module format */
665 MIKMODAPI extern struct MLOADER load_xm; /* FastTracker 2 (by Triton) */
668 * ========== Module player
671 MIKMODAPI extern MODULE* Player_Load(const CHAR*,int,BOOL);
672 MIKMODAPI extern MODULE* Player_LoadFP(FILE*,int,BOOL);
673 MIKMODAPI extern MODULE* Player_LoadMem(const char *buffer,int len,int maxchan,BOOL curious);
674 MIKMODAPI extern MODULE* Player_LoadGeneric(MREADER*,int,BOOL);
675 MIKMODAPI extern CHAR* Player_LoadTitle(const CHAR*);
676 MIKMODAPI extern CHAR* Player_LoadTitleFP(FILE*);
677 MIKMODAPI extern CHAR* Player_LoadTitleMem(const char *buffer,int len);
678 MIKMODAPI extern CHAR* Player_LoadTitleGeneric(MREADER*);
680 MIKMODAPI extern void Player_Free(MODULE*);
681 MIKMODAPI extern void Player_Start(MODULE*);
682 MIKMODAPI extern BOOL Player_Active(void);
683 MIKMODAPI extern void Player_Stop(void);
684 MIKMODAPI extern void Player_TogglePause(void);
685 MIKMODAPI extern BOOL Player_Paused(void);
686 MIKMODAPI extern void Player_NextPosition(void);
687 MIKMODAPI extern void Player_PrevPosition(void);
688 MIKMODAPI extern void Player_SetPosition(UWORD);
689 MIKMODAPI extern BOOL Player_Muted(UBYTE);
690 MIKMODAPI extern void Player_SetVolume(SWORD);
691 MIKMODAPI extern MODULE* Player_GetModule(void);
692 MIKMODAPI extern void Player_SetSpeed(UWORD);
693 MIKMODAPI extern void Player_SetTempo(UWORD);
694 MIKMODAPI extern void Player_Unmute(SLONG,...);
695 MIKMODAPI extern void Player_Mute(SLONG,...);
696 MIKMODAPI extern void Player_ToggleMute(SLONG,...);
697 MIKMODAPI extern int Player_GetChannelVoice(UBYTE);
698 MIKMODAPI extern UWORD Player_GetChannelPeriod(UBYTE);
699 MIKMODAPI extern int Player_QueryVoices(UWORD numvoices, VOICEINFO *vinfo);
700 MIKMODAPI extern int Player_GetRow(void);
701 MIKMODAPI extern int Player_GetOrder(void);
703 typedef void (*MikMod_player_t)(void);
704 typedef void (*MikMod_callback_t)(unsigned char *data, size_t len);
706 MIKMODAPI extern MikMod_player_t MikMod_RegisterPlayer(MikMod_player_t);
708 #define MUTE_EXCLUSIVE 32000
709 #define MUTE_INCLUSIVE 32001
727 /* These ones take effect only after MikMod_Init or MikMod_Reset */
728 #define DMODE_16BITS 0x0001 /* enable 16 bit output */
729 #define DMODE_STEREO 0x0002 /* enable stereo output */
730 #define DMODE_SOFT_SNDFX 0x0004 /* Process sound effects via software mixer */
731 #define DMODE_SOFT_MUSIC 0x0008 /* Process music via software mixer */
732 #define DMODE_HQMIXER 0x0010 /* Use high-quality (slower) software mixer */
733 #define DMODE_FLOAT 0x0020 /* enable float output */
734 /* These take effect immediately. */
735 #define DMODE_SURROUND 0x0100 /* enable surround sound */
736 #define DMODE_INTERP 0x0200 /* enable interpolation */
737 #define DMODE_REVERSE 0x0400 /* reverse stereo */
738 #define DMODE_SIMDMIXER 0x0800 /* enable SIMD mixing */
739 #define DMODE_NOISEREDUCTION 0x1000 /* Low pass filtering */
744 typedef struct MDRIVER {
745 struct MDRIVER* next;
749 UBYTE HardVoiceLimit; /* Limit of hardware mixer voices */
750 UBYTE SoftVoiceLimit; /* Limit of software mixer voices */
753 const CHAR* CmdLineHelp;
755 void (*CommandLine) (const CHAR*);
756 BOOL (*IsPresent) (void);
757 SWORD (*SampleLoad) (struct SAMPLOAD*,int);
758 void (*SampleUnload) (SWORD);
759 ULONG (*FreeSampleSpace) (int);
760 ULONG (*RealSampleLength) (int,struct SAMPLE*);
764 int (*SetNumVoices) (void);
765 int (*PlayStart) (void);
766 void (*PlayStop) (void);
767 void (*Update) (void);
768 void (*Pause) (void);
769 void (*VoiceSetVolume) (UBYTE,UWORD);
770 UWORD (*VoiceGetVolume) (UBYTE);
771 void (*VoiceSetFrequency)(UBYTE,ULONG);
772 ULONG (*VoiceGetFrequency)(UBYTE);
773 void (*VoiceSetPanning) (UBYTE,ULONG);
774 ULONG (*VoiceGetPanning) (UBYTE);
775 void (*VoicePlay) (UBYTE,SWORD,ULONG,ULONG,ULONG,ULONG,UWORD);
776 void (*VoiceStop) (UBYTE);
777 BOOL (*VoiceStopped) (UBYTE);
778 SLONG (*VoiceGetPosition) (UBYTE);
779 ULONG (*VoiceRealVolume) (UBYTE);
782 /* These variables can be changed at ANY time and results will be immediate */
783 MIKMODAPI extern UBYTE md_volume; /* global sound volume (0-128) */
784 MIKMODAPI extern UBYTE md_musicvolume; /* volume of song */
785 MIKMODAPI extern UBYTE md_sndfxvolume; /* volume of sound effects */
786 MIKMODAPI extern UBYTE md_reverb; /* 0 = none; 15 = chaos */
787 MIKMODAPI extern UBYTE md_pansep; /* 0 = mono; 128 == 100% (full left/right) */
789 /* The variables below can be changed at any time, but changes will not be
790 implemented until MikMod_Reset is called. A call to MikMod_Reset may result
791 in a skip or pop in audio (depending on the soundcard driver and the settings
793 MIKMODAPI extern UWORD md_device; /* device */
794 MIKMODAPI extern UWORD md_mixfreq; /* mixing frequency */
795 MIKMODAPI extern UWORD md_mode; /* mode. See DMODE_? flags above */
797 /* The following variable should not be changed! */
798 MIKMODAPI extern MDRIVER* md_driver; /* Current driver in use. */
800 /* Known drivers list */
802 MIKMODAPI extern struct MDRIVER drv_nos; /* no sound */
803 MIKMODAPI extern struct MDRIVER drv_pipe; /* piped output */
804 MIKMODAPI extern struct MDRIVER drv_raw; /* raw file disk writer [music.raw] */
805 MIKMODAPI extern struct MDRIVER drv_stdout; /* output to stdout */
806 MIKMODAPI extern struct MDRIVER drv_wav; /* RIFF WAVE file disk writer [music.wav] */
807 MIKMODAPI extern struct MDRIVER drv_aiff; /* AIFF file disk writer [music.aiff] */
809 MIKMODAPI extern struct MDRIVER drv_ultra; /* Linux Ultrasound driver */
810 MIKMODAPI extern struct MDRIVER drv_sam9407;/* Linux sam9407 driver */
812 MIKMODAPI extern struct MDRIVER drv_AF; /* Dec Alpha AudioFile */
813 MIKMODAPI extern struct MDRIVER drv_ahi; /* Amiga AHI */
814 MIKMODAPI extern struct MDRIVER drv_aix; /* AIX audio device */
815 MIKMODAPI extern struct MDRIVER drv_alsa; /* Advanced Linux Sound Architecture (ALSA) */
816 MIKMODAPI extern struct MDRIVER drv_esd; /* Enlightened sound daemon (EsounD) */
817 MIKMODAPI extern struct MDRIVER drv_pulseaudio; /* PulseAudio */
818 MIKMODAPI extern struct MDRIVER drv_hp; /* HP-UX audio device */
819 MIKMODAPI extern struct MDRIVER drv_nas; /* Network Audio System (NAS) */
820 MIKMODAPI extern struct MDRIVER drv_oss; /* OpenSound System (Linux,FreeBSD...) */
821 MIKMODAPI extern struct MDRIVER drv_openal; /* OpenAL driver */
822 MIKMODAPI extern struct MDRIVER drv_sdl; /* SDL audio driver */
823 MIKMODAPI extern struct MDRIVER drv_sgi; /* SGI audio library */
824 MIKMODAPI extern struct MDRIVER drv_sndio; /* OpenBSD sndio */
825 MIKMODAPI extern struct MDRIVER drv_sun; /* Sun/NetBSD/OpenBSD audio device */
827 MIKMODAPI extern struct MDRIVER drv_dart; /* OS/2 Direct Audio RealTime */
828 MIKMODAPI extern struct MDRIVER drv_os2; /* OS/2 MMPM/2 */
830 MIKMODAPI extern struct MDRIVER drv_ds; /* Win32 DirectSound driver */
831 MIKMODAPI extern struct MDRIVER drv_xaudio2;/* Win32 XAudio2 driver */
832 MIKMODAPI extern struct MDRIVER drv_win; /* Win32 multimedia API driver */
834 MIKMODAPI extern struct MDRIVER drv_mac; /* Macintosh Sound Manager driver */
835 MIKMODAPI extern struct MDRIVER drv_osx; /* MacOS X CoreAudio Driver */
837 MIKMODAPI extern struct MDRIVER drv_dc; /* Dreamcast driver */
838 MIKMODAPI extern struct MDRIVER drv_gp32; /* GP32 Sound driver */
839 MIKMODAPI extern struct MDRIVER drv_psp; /* PlayStation Portable driver */
841 MIKMODAPI extern struct MDRIVER drv_wss; /* DOS WSS driver */
842 MIKMODAPI extern struct MDRIVER drv_sb; /* DOS S/B driver */
844 MIKMODAPI extern struct MDRIVER drv_osles; /* OpenSL ES driver for android */
846 /*========== Virtual channel mixer interface (for user-supplied drivers only) */
848 MIKMODAPI extern int VC_Init(void);
849 MIKMODAPI extern void VC_Exit(void);
850 MIKMODAPI extern void VC_SetCallback(MikMod_callback_t callback);
851 MIKMODAPI extern int VC_SetNumVoices(void);
852 MIKMODAPI extern ULONG VC_SampleSpace(int);
853 MIKMODAPI extern ULONG VC_SampleLength(int,SAMPLE*);
855 MIKMODAPI extern int VC_PlayStart(void);
856 MIKMODAPI extern void VC_PlayStop(void);
858 MIKMODAPI extern SWORD VC_SampleLoad(struct SAMPLOAD*,int);
859 MIKMODAPI extern void VC_SampleUnload(SWORD);
861 MIKMODAPI extern ULONG VC_WriteBytes(SBYTE*,ULONG);
862 MIKMODAPI extern ULONG VC_SilenceBytes(SBYTE*,ULONG);
864 MIKMODAPI extern void VC_VoiceSetVolume(UBYTE,UWORD);
865 MIKMODAPI extern UWORD VC_VoiceGetVolume(UBYTE);
866 MIKMODAPI extern void VC_VoiceSetFrequency(UBYTE,ULONG);
867 MIKMODAPI extern ULONG VC_VoiceGetFrequency(UBYTE);
868 MIKMODAPI extern void VC_VoiceSetPanning(UBYTE,ULONG);
869 MIKMODAPI extern ULONG VC_VoiceGetPanning(UBYTE);
870 MIKMODAPI extern void VC_VoicePlay(UBYTE,SWORD,ULONG,ULONG,ULONG,ULONG,UWORD);
872 MIKMODAPI extern void VC_VoiceStop(UBYTE);
873 MIKMODAPI extern BOOL VC_VoiceStopped(UBYTE);
874 MIKMODAPI extern SLONG VC_VoiceGetPosition(UBYTE);
875 MIKMODAPI extern ULONG VC_VoiceRealVolume(UBYTE);