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 ==============================================================================*/
38 * ========== Compiler magic for shared libraries
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
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 */
52 # define MIKMODAPI __declspec(dllimport) /* using libmikmod dll for windows */
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)
58 # define MIKMODAPI /* using dll or static libmikmod for os/2 */
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")))
72 * ========== Library version
75 #define LIBMIKMOD_VERSION_MAJOR 3L
76 #define LIBMIKMOD_VERSION_MINOR 3L
77 #define LIBMIKMOD_REVISION 10L
79 #define LIBMIKMOD_VERSION \
80 ((LIBMIKMOD_VERSION_MAJOR<<16)| \
81 (LIBMIKMOD_VERSION_MINOR<< 8)| \
84 MIKMODAPI extern long MikMod_GetVersion(void);
87 * ========== Dependency platform headers
91 #ifndef WIN32_LEAN_AND_MEAN
92 #define WIN32_LEAN_AND_MEAN
100 #if defined(__DJGPP__) || defined(MSDOS) || defined(__MSDOS__) || defined(__DOS__)
104 #if defined(__OS2__) || defined(__EMX__)
105 #define INCL_DOSSEMAPHORES
111 #if defined(__MORPHOS__) || defined(__AROS__) || defined(_AMIGA) || defined(__AMIGA__) || defined(__amigaos__) || defined(AMIGAOS)
112 #include <exec/types.h>
113 #define _MIKMOD_AMIGA
117 * ========== Platform independent-type definitions
118 * (pain when it comes to cross-platform maintenance..)
121 #if !(defined(_MIKMOD_OS2) || defined(_MIKMOD_WIN32))
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))
130 /* 1 byte, signed and unsigned: */
131 typedef signed char SBYTE;
132 #ifndef _MIKMOD_AMIGA
133 typedef unsigned char UBYTE;
136 /* 2 bytes, signed and unsigned: */
138 typedef signed short int SWORD;
140 #if !(defined(__LCC__) || defined(_MIKMOD_AMIGA))
141 typedef unsigned short int UWORD;
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;
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;
159 /* make sure types are of correct sizes: */
160 typedef int __mikmod_typetest [
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))
168 && (sizeof(CHAR) == sizeof(char))
172 * ========== Error codes
176 MMERR_OPENING_FILE = 1,
178 MMERR_DYNAMIC_LINKING,
180 MMERR_SAMPLE_TOO_BIG,
181 MMERR_OUT_OF_HANDLES,
182 MMERR_UNKNOWN_WAVE_TYPE,
184 MMERR_LOADING_PATTERN,
186 MMERR_LOADING_HEADER,
187 MMERR_LOADING_SAMPLEINFO,
190 MMERR_MED_SYNTHSAMPLES,
191 MMERR_ITPACK_INVALID_DATA,
193 MMERR_DETECTING_DEVICE,
194 MMERR_INVALID_DEVICE,
195 MMERR_INITIALIZING_MIXER,
205 MMERR_AIX_CONFIG_INIT,
206 MMERR_AIX_CONFIG_CONTROL,
207 MMERR_AIX_CONFIG_START,
213 MMERR_HP_SETSAMPLESIZE,
216 MMERR_HP_AUDIO_OUTPUT,
220 MMERR_OSS_SETFRAGMENT,
221 MMERR_OSS_SETSAMPLESIZE,
247 MMERR_WINMM_ALLOCATED,
248 MMERR_WINMM_DEVICEID,
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,
264 MMERR_DOSWSS_STARTDMA,
265 MMERR_DOSSB_STARTDMA,
267 MMERR_NO_FLOAT32,/* should actually be after MMERR_ULAW or something */
269 MMERR_OPENAL_CREATECTX,
270 MMERR_OPENAL_CTXCURRENT,
271 MMERR_OPENAL_GENBUFFERS,
272 MMERR_OPENAL_GENSOURCES,
274 MMERR_OPENAL_QUEUEBUFFERS,
275 MMERR_OPENAL_UNQUEUEBUFFERS,
276 MMERR_OPENAL_BUFFERDATA,
277 MMERR_OPENAL_GETSOURCE,
278 MMERR_OPENAL_SOURCEPLAY,
279 MMERR_OPENAL_SOURCESTOP,
282 MMERR_ALSA_SETPARAMS,
283 MMERR_ALSA_SETFORMAT,
285 MMERR_ALSA_SETCHANNELS,
286 MMERR_ALSA_BUFFERSIZE,
287 MMERR_ALSA_PCM_START,
288 MMERR_ALSA_PCM_WRITE,
289 MMERR_ALSA_PCM_RECOVER,
291 MMERR_SNDIO_SETPARAMS,
292 MMERR_SNDIO_BADPARAMS,
298 * ========== Error handling
301 typedef void (MikMod_handler)(void);
302 typedef MikMod_handler *MikMod_handler_t;
304 MIKMODAPI extern int MikMod_errno;
305 MIKMODAPI extern BOOL MikMod_critical;
306 MIKMODAPI extern const char *MikMod_strerror(int);
308 MIKMODAPI extern MikMod_handler_t MikMod_RegisterErrorHandler(MikMod_handler_t);
311 * ========== Library initialization and core functions
316 MIKMODAPI extern void MikMod_RegisterAllDrivers(void);
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);
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);
332 MIKMODAPI extern BOOL MikMod_InitThreads(void);
333 MIKMODAPI extern void MikMod_Lock(void);
334 MIKMODAPI extern void MikMod_Unlock(void);
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 */
343 * ========== Reader, Writer
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*);
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);
367 /* Sample playback should not be interrupted */
368 #define SFX_CRITICAL 1
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
378 #define SF_FORMATMASK 0x003F
380 /* General Playback flags */
382 #define SF_LOOP 0x0100
383 #define SF_BIDI 0x0200
384 #define SF_REVERSE 0x0400
385 #define SF_SUSTAIN 0x0800
387 #define SF_PLAYBACKMASK 0x0C00
389 /* Module-only Playback Flags */
391 #define SF_OWNPAN 0x1000
392 #define SF_UST_LOOP 0x2000
394 #define SF_EXTRAPLAYBACKMASK 0x3000
396 /* Panning constants */
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 */
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! */
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 */
423 CHAR* samplename; /* name of the sample */
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*/
434 /* Sample functions */
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);
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);
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);
461 * ========== Internal module representation (UniMod)
465 Instrument definition - for information only, the only field which may be
466 of use in user programs is the name field
469 /* Instrument note count */
470 #define INSTNOTES 120
473 typedef struct ENVPT {
478 /* Envelope point count */
481 /* Instrument structure */
482 typedef struct INSTRUMENT {
486 UWORD samplenumber[INSTNOTES];
487 UBYTE samplenote[INSTNOTES];
490 UBYTE dca; /* duplicate check action */
491 UBYTE dct; /* duplicate check type */
494 SWORD panning; /* instrument-based panning var */
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%) */
501 /* volume envelope */
502 UBYTE volflg; /* bit 0: on 1: sustain 2: loop */
508 ENVPT volenv[ENVPOINTS];
509 /* panning envelope */
510 UBYTE panflg; /* bit 0: on 1: sustain 2: loop */
516 ENVPT panenv[ENVPOINTS];
518 UBYTE pitflg; /* bit 0: on 1: sustain 2: loop */
524 ENVPT pitenv[ENVPOINTS];
534 /* maximum master channels supported */
535 #define UF_MAXCHAN 64
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
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
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 */
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 */
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 */
567 struct INSTRUMENT* instruments; /* all instruments */
568 struct SAMPLE* samples; /* all samples */
570 UBYTE realchn; /* real number of channels used */
571 UBYTE totalchn; /* total number of channels used (incl NNAs) */
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) */
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 */
590 UWORD patpos; /* current row number */
591 SWORD sngpos; /* current song position */
592 ULONG sngtime; /* current song time in 2^-10 seconds */
594 SWORD relspd; /* relative speed factor */
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 */
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 */
608 struct MP_CONTROL* control; /* Effects Channel info (size pf->numchn) */
609 struct MP_VOICE* voice; /* Audio Voice information (size md_numchn) */
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 */
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 */
632 * ========== Module loaders
637 MIKMODAPI extern CHAR* MikMod_InfoLoader(void);
638 MIKMODAPI extern void MikMod_RegisterAllLoaders(void);
639 MIKMODAPI extern void MikMod_RegisterLoader(struct MLOADER*);
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) */
664 * ========== Module player
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*);
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);
699 typedef void (*MikMod_player_t)(void);
700 typedef void (*MikMod_callback_t)(unsigned char *data, size_t len);
702 MIKMODAPI extern MikMod_player_t MikMod_RegisterPlayer(MikMod_player_t);
704 #define MUTE_EXCLUSIVE 32000
705 #define MUTE_INCLUSIVE 32001
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 */
740 typedef struct MDRIVER {
741 struct MDRIVER* next;
745 UBYTE HardVoiceLimit; /* Limit of hardware mixer voices */
746 UBYTE SoftVoiceLimit; /* Limit of software mixer voices */
749 const CHAR* CmdLineHelp;
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*);
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);
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) */
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
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 */
793 /* The following variable should not be changed! */
794 MIKMODAPI extern MDRIVER* md_driver; /* Current driver in use. */
796 /* Known drivers list */
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] */
805 MIKMODAPI extern struct MDRIVER drv_ultra; /* Linux Ultrasound driver */
806 MIKMODAPI extern struct MDRIVER drv_sam9407;/* Linux sam9407 driver */
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 */
823 MIKMODAPI extern struct MDRIVER drv_dart; /* OS/2 Direct Audio RealTime */
824 MIKMODAPI extern struct MDRIVER drv_os2; /* OS/2 MMPM/2 */
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 */
830 MIKMODAPI extern struct MDRIVER drv_mac; /* Macintosh Sound Manager driver */
831 MIKMODAPI extern struct MDRIVER drv_osx; /* MacOS X CoreAudio Driver */
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 */
837 MIKMODAPI extern struct MDRIVER drv_wss; /* DOS WSS driver */
838 MIKMODAPI extern struct MDRIVER drv_sb; /* DOS S/B driver */
840 MIKMODAPI extern struct MDRIVER drv_osles; /* OpenSL ES driver for android */
842 /*========== Virtual channel mixer interface (for user-supplied drivers only) */
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*);
851 MIKMODAPI extern int VC_PlayStart(void);
852 MIKMODAPI extern void VC_PlayStop(void);
854 MIKMODAPI extern SWORD VC_SampleLoad(struct SAMPLOAD*,int);
855 MIKMODAPI extern void VC_SampleUnload(SWORD);
857 MIKMODAPI extern ULONG VC_WriteBytes(SBYTE*,ULONG);
858 MIKMODAPI extern ULONG VC_SilenceBytes(SBYTE*,ULONG);
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);
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);