VisualC/mikmod/include/mikmod.h
changeset 556 2686e67b59fd
parent 555 b92bfb451700
child 557 a55168d8babe
equal deleted inserted replaced
555:b92bfb451700 556:2686e67b59fd
     1 /*	MikMod sound library
       
     2 	(c) 1998, 1999, 2000 Miodrag Vallat and others - see file AUTHORS
       
     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   $Id: mikmod.h.in,v 1.2 2004/06/01 16:43:45 raph Exp $
       
    24 
       
    25   MikMod sound library include file
       
    26 
       
    27 ==============================================================================*/
       
    28 
       
    29 #ifndef _MIKMOD_H_
       
    30 #define _MIKMOD_H_
       
    31 
       
    32 #include <stdio.h>
       
    33 #include <stdlib.h>
       
    34 
       
    35 #ifdef __cplusplus
       
    36 extern "C" {
       
    37 #endif
       
    38 
       
    39 /*
       
    40  * ========== Compiler magic for shared libraries
       
    41  */
       
    42 
       
    43 #if defined WIN32 && defined _DLL
       
    44 #ifdef DLL_EXPORTS
       
    45 #define MIKMODAPI __declspec(dllexport)
       
    46 #else
       
    47 #define MIKMODAPI __declspec(dllimport)
       
    48 #endif
       
    49 #else
       
    50 #define MIKMODAPI
       
    51 #endif
       
    52 
       
    53 /*
       
    54  *	========== Library version
       
    55  */
       
    56 
       
    57 #define LIBMIKMOD_VERSION_MAJOR 3L
       
    58 #define LIBMIKMOD_VERSION_MINOR 1L
       
    59 #define LIBMIKMOD_REVISION      10L
       
    60 
       
    61 #define LIBMIKMOD_VERSION \
       
    62 	((LIBMIKMOD_VERSION_MAJOR<<16)| \
       
    63 	 (LIBMIKMOD_VERSION_MINOR<< 8)| \
       
    64 	 (LIBMIKMOD_REVISION))
       
    65 
       
    66 MIKMODAPI extern long MikMod_GetVersion(void);
       
    67 
       
    68 /*
       
    69  *	========== Platform independent-type definitions
       
    70  */
       
    71 
       
    72 #ifdef WIN32
       
    73 #define WIN32_LEAN_AND_MEAN
       
    74 #include <windows.h>
       
    75 #include <io.h>
       
    76 #include <mmsystem.h>
       
    77 #endif
       
    78 
       
    79 #if defined(__OS2__)||defined(__EMX__)
       
    80 #define INCL_DOSSEMAPHORES
       
    81 #include <os2.h>
       
    82 #else
       
    83 typedef char CHAR;
       
    84 #endif
       
    85 
       
    86 
       
    87 
       
    88 #if defined(__arch64__) || defined(__alpha) || defined(__x86_64) || defined(_LP64)
       
    89 /* 64 bit architectures */
       
    90 
       
    91 typedef signed char     SBYTE;      /* 1 byte, signed */
       
    92 typedef unsigned char   UBYTE;      /* 1 byte, unsigned */
       
    93 typedef signed short    SWORD;      /* 2 bytes, signed */
       
    94 typedef unsigned short  UWORD;      /* 2 bytes, unsigned */
       
    95 typedef signed int      SLONG;      /* 4 bytes, signed */
       
    96 typedef unsigned int    ULONG;      /* 4 bytes, unsigned */
       
    97 typedef int             BOOL;       /* 0=false, <>0 true */
       
    98 
       
    99 #else
       
   100 /* 32 bit architectures */
       
   101 
       
   102 typedef signed char     SBYTE;      /* 1 byte, signed */
       
   103 typedef unsigned char   UBYTE;      /* 1 byte, unsigned */
       
   104 typedef signed short    SWORD;      /* 2 bytes, signed */
       
   105 typedef unsigned short  UWORD;      /* 2 bytes, unsigned */
       
   106 typedef signed long     SLONG;      /* 4 bytes, signed */
       
   107 #if !defined(__OS2__)&&!defined(__EMX__)&&!defined(WIN32)
       
   108 typedef unsigned long   ULONG;      /* 4 bytes, unsigned */
       
   109 typedef int             BOOL;       /* 0=false, <>0 true */
       
   110 #endif
       
   111 #endif
       
   112 
       
   113 /*
       
   114  *	========== Error codes
       
   115  */
       
   116 
       
   117 enum {
       
   118 	MMERR_OPENING_FILE = 1,
       
   119 	MMERR_OUT_OF_MEMORY,
       
   120 	MMERR_DYNAMIC_LINKING,
       
   121 
       
   122 	MMERR_SAMPLE_TOO_BIG,
       
   123 	MMERR_OUT_OF_HANDLES,
       
   124 	MMERR_UNKNOWN_WAVE_TYPE,
       
   125 
       
   126 	MMERR_LOADING_PATTERN,
       
   127 	MMERR_LOADING_TRACK,
       
   128 	MMERR_LOADING_HEADER,
       
   129 	MMERR_LOADING_SAMPLEINFO,
       
   130 	MMERR_NOT_A_MODULE,
       
   131 	MMERR_NOT_A_STREAM,
       
   132 	MMERR_MED_SYNTHSAMPLES,
       
   133 	MMERR_ITPACK_INVALID_DATA,
       
   134 
       
   135 	MMERR_DETECTING_DEVICE,
       
   136 	MMERR_INVALID_DEVICE,
       
   137 	MMERR_INITIALIZING_MIXER,
       
   138 	MMERR_OPENING_AUDIO,
       
   139 	MMERR_8BIT_ONLY,
       
   140 	MMERR_16BIT_ONLY,
       
   141 	MMERR_STEREO_ONLY,
       
   142 	MMERR_ULAW,
       
   143 	MMERR_NON_BLOCK,
       
   144 
       
   145 	MMERR_AF_AUDIO_PORT,
       
   146 
       
   147 	MMERR_AIX_CONFIG_INIT,
       
   148 	MMERR_AIX_CONFIG_CONTROL,
       
   149 	MMERR_AIX_CONFIG_START,
       
   150 
       
   151 	MMERR_GUS_SETTINGS,
       
   152 	MMERR_GUS_RESET,
       
   153 	MMERR_GUS_TIMER,
       
   154 
       
   155 	MMERR_HP_SETSAMPLESIZE,
       
   156 	MMERR_HP_SETSPEED,
       
   157 	MMERR_HP_CHANNELS,
       
   158 	MMERR_HP_AUDIO_OUTPUT,
       
   159 	MMERR_HP_AUDIO_DESC,
       
   160 	MMERR_HP_BUFFERSIZE,
       
   161 
       
   162 	MMERR_OSS_SETFRAGMENT,
       
   163 	MMERR_OSS_SETSAMPLESIZE,
       
   164 	MMERR_OSS_SETSTEREO,
       
   165 	MMERR_OSS_SETSPEED,
       
   166 
       
   167 	MMERR_SGI_SPEED,
       
   168 	MMERR_SGI_16BIT,
       
   169 	MMERR_SGI_8BIT,
       
   170 	MMERR_SGI_STEREO,
       
   171 	MMERR_SGI_MONO,
       
   172 
       
   173 	MMERR_SUN_INIT,
       
   174 
       
   175 	MMERR_OS2_MIXSETUP,
       
   176 	MMERR_OS2_SEMAPHORE,
       
   177 	MMERR_OS2_TIMER,
       
   178 	MMERR_OS2_THREAD,
       
   179 
       
   180 	MMERR_DS_PRIORITY,
       
   181 	MMERR_DS_BUFFER,
       
   182 	MMERR_DS_FORMAT,
       
   183 	MMERR_DS_NOTIFY,
       
   184 	MMERR_DS_EVENT,
       
   185 	MMERR_DS_THREAD,
       
   186 	MMERR_DS_UPDATE,
       
   187 
       
   188 	MMERR_WINMM_HANDLE,
       
   189 	MMERR_WINMM_ALLOCATED,
       
   190 	MMERR_WINMM_DEVICEID,
       
   191 	MMERR_WINMM_FORMAT,
       
   192 	MMERR_WINMM_UNKNOWN,
       
   193 
       
   194 	MMERR_MAC_SPEED,
       
   195 	MMERR_MAC_START,
       
   196 
       
   197 	MMERR_MAX
       
   198 };
       
   199 
       
   200 /*
       
   201  *	========== Error handling
       
   202  */
       
   203 
       
   204 typedef void (MikMod_handler)(void);
       
   205 typedef MikMod_handler *MikMod_handler_t;
       
   206 
       
   207 MIKMODAPI extern int  MikMod_errno;
       
   208 MIKMODAPI extern BOOL MikMod_critical;
       
   209 MIKMODAPI extern char *MikMod_strerror(int);
       
   210 
       
   211 MIKMODAPI extern MikMod_handler_t MikMod_RegisterErrorHandler(MikMod_handler_t);
       
   212 
       
   213 /*
       
   214  *	========== Library initialization and core functions
       
   215  */
       
   216 
       
   217 struct MDRIVER;
       
   218 
       
   219 MIKMODAPI extern void   MikMod_RegisterAllDrivers(void);
       
   220 
       
   221 MIKMODAPI extern CHAR*  MikMod_InfoDriver(void);
       
   222 MIKMODAPI extern void   MikMod_RegisterDriver(struct MDRIVER*);
       
   223 MIKMODAPI extern int    MikMod_DriverFromAlias(CHAR*);
       
   224 
       
   225 MIKMODAPI extern BOOL   MikMod_Init(CHAR*);
       
   226 MIKMODAPI extern void   MikMod_Exit(void);
       
   227 MIKMODAPI extern BOOL   MikMod_Reset(CHAR*);
       
   228 MIKMODAPI extern BOOL   MikMod_SetNumVoices(int,int);
       
   229 MIKMODAPI extern BOOL   MikMod_Active(void);
       
   230 MIKMODAPI extern BOOL   MikMod_EnableOutput(void);
       
   231 MIKMODAPI extern void   MikMod_DisableOutput(void);
       
   232 MIKMODAPI extern void   MikMod_Update(void);
       
   233 
       
   234 MIKMODAPI extern BOOL   MikMod_InitThreads(void);
       
   235 MIKMODAPI extern void   MikMod_Lock(void);
       
   236 MIKMODAPI extern void   MikMod_Unlock(void);
       
   237 
       
   238 /*
       
   239  *	========== Reader, Writer
       
   240  */
       
   241 
       
   242 typedef struct MREADER {
       
   243 	BOOL (*Seek)(struct MREADER*,long,int);
       
   244 	long (*Tell)(struct MREADER*);
       
   245 	BOOL (*Read)(struct MREADER*,void*,size_t);
       
   246 	int  (*Get)(struct MREADER*);
       
   247 	BOOL (*Eof)(struct MREADER*);
       
   248 } MREADER;
       
   249 
       
   250 typedef struct MWRITER {
       
   251 	BOOL (*Seek)(struct MWRITER*,long,int);
       
   252 	long (*Tell)(struct MWRITER*);
       
   253 	BOOL (*Write)(struct MWRITER*,void*,size_t);
       
   254 	BOOL (*Put)(struct MWRITER*,int);
       
   255 } MWRITER;
       
   256 
       
   257 /*
       
   258  *	========== Samples
       
   259  */
       
   260 
       
   261 /* Sample playback should not be interrupted */
       
   262 #define SFX_CRITICAL 1
       
   263 
       
   264 /* Sample format [loading and in-memory] flags: */
       
   265 #define SF_16BITS       0x0001
       
   266 #define SF_STEREO       0x0002
       
   267 #define SF_SIGNED       0x0004
       
   268 #define SF_BIG_ENDIAN   0x0008
       
   269 #define SF_DELTA        0x0010
       
   270 #define SF_ITPACKED		0x0020
       
   271 
       
   272 #define	SF_FORMATMASK	0x003F
       
   273 
       
   274 /* General Playback flags */
       
   275 
       
   276 #define SF_LOOP         0x0100
       
   277 #define SF_BIDI         0x0200
       
   278 #define SF_REVERSE      0x0400
       
   279 #define SF_SUSTAIN      0x0800
       
   280 
       
   281 #define SF_PLAYBACKMASK	0x0C00
       
   282 
       
   283 /* Module-only Playback Flags */
       
   284 
       
   285 #define SF_OWNPAN		0x1000
       
   286 #define SF_UST_LOOP     0x2000
       
   287 
       
   288 #define SF_EXTRAPLAYBACKMASK	0x3000
       
   289 
       
   290 /* Panning constants */
       
   291 #define PAN_LEFT		0
       
   292 #define PAN_HALFLEFT 	64
       
   293 #define PAN_CENTER		128
       
   294 #define PAN_HALFRIGHT	192
       
   295 #define PAN_RIGHT		255
       
   296 #define PAN_SURROUND	512 /* panning value for Dolby Surround */
       
   297 
       
   298 typedef struct SAMPLE {
       
   299 	SWORD  panning;     /* panning (0-255 or PAN_SURROUND) */
       
   300 	ULONG  speed;       /* Base playing speed/frequency of note */
       
   301 	UBYTE  volume;      /* volume 0-64 */
       
   302 	UWORD  inflags;		/* sample format on disk */
       
   303 	UWORD  flags;       /* sample format in memory */
       
   304 	ULONG  length;      /* length of sample (in samples!) */
       
   305 	ULONG  loopstart;   /* repeat position (relative to start, in samples) */
       
   306 	ULONG  loopend;     /* repeat end */
       
   307 	ULONG  susbegin;    /* sustain loop begin (in samples) \  Not Supported */
       
   308 	ULONG  susend;      /* sustain loop end                /      Yet! */
       
   309 
       
   310 	/* Variables used by the module player only! (ignored for sound effects) */
       
   311 	UBYTE  globvol;     /* global volume */
       
   312 	UBYTE  vibflags;    /* autovibrato flag stuffs */
       
   313 	UBYTE  vibtype;     /* Vibratos moved from INSTRUMENT to SAMPLE */
       
   314 	UBYTE  vibsweep;
       
   315 	UBYTE  vibdepth;
       
   316 	UBYTE  vibrate;
       
   317 	CHAR*  samplename;  /* name of the sample */
       
   318 
       
   319 	/* Values used internally only */
       
   320 	UWORD  avibpos;     /* autovibrato pos [player use] */
       
   321 	UBYTE  divfactor;   /* for sample scaling, maintains proper period slides */
       
   322 	ULONG  seekpos;     /* seek position in file */
       
   323 	SWORD  handle;      /* sample handle used by individual drivers */
       
   324 } SAMPLE;
       
   325 
       
   326 /* Sample functions */
       
   327 
       
   328 MIKMODAPI extern SAMPLE *Sample_Load(CHAR*);
       
   329 MIKMODAPI extern SAMPLE *Sample_LoadFP(FILE*);
       
   330 MIKMODAPI extern SAMPLE *Sample_LoadGeneric(MREADER*);
       
   331 MIKMODAPI extern void   Sample_Free(SAMPLE*);
       
   332 MIKMODAPI extern SBYTE  Sample_Play(SAMPLE*,ULONG,UBYTE);
       
   333 
       
   334 MIKMODAPI extern void   Voice_SetVolume(SBYTE,UWORD);
       
   335 MIKMODAPI extern UWORD  Voice_GetVolume(SBYTE);
       
   336 MIKMODAPI extern void   Voice_SetFrequency(SBYTE,ULONG);
       
   337 MIKMODAPI extern ULONG  Voice_GetFrequency(SBYTE);
       
   338 MIKMODAPI extern void   Voice_SetPanning(SBYTE,ULONG);
       
   339 MIKMODAPI extern ULONG  Voice_GetPanning(SBYTE);
       
   340 MIKMODAPI extern void   Voice_Play(SBYTE,SAMPLE*,ULONG);
       
   341 MIKMODAPI extern void   Voice_Stop(SBYTE);
       
   342 MIKMODAPI extern BOOL   Voice_Stopped(SBYTE);
       
   343 MIKMODAPI extern SLONG  Voice_GetPosition(SBYTE);
       
   344 MIKMODAPI extern ULONG  Voice_RealVolume(SBYTE);
       
   345 
       
   346 /*
       
   347  *	========== Internal module representation (UniMod)
       
   348  */
       
   349 
       
   350 /*
       
   351 	Instrument definition - for information only, the only field which may be
       
   352 	of use in user programs is the name field
       
   353 */
       
   354 
       
   355 /* Instrument note count */
       
   356 #define INSTNOTES 120
       
   357 
       
   358 /* Envelope point */
       
   359 typedef struct ENVPT {
       
   360 	SWORD pos;
       
   361 	SWORD val;
       
   362 } ENVPT;
       
   363 
       
   364 /* Envelope point count */
       
   365 #define ENVPOINTS 32
       
   366 
       
   367 /* Instrument structure */
       
   368 typedef struct INSTRUMENT {
       
   369 	CHAR* insname;
       
   370 
       
   371 	UBYTE flags;
       
   372 	UWORD samplenumber[INSTNOTES];
       
   373 	UBYTE samplenote[INSTNOTES];
       
   374 
       
   375 	UBYTE nnatype;
       
   376 	UBYTE dca;              /* duplicate check action */
       
   377 	UBYTE dct;              /* duplicate check type */
       
   378 	UBYTE globvol;
       
   379 	UWORD volfade;
       
   380 	SWORD panning;          /* instrument-based panning var */
       
   381 
       
   382 	UBYTE pitpansep;        /* pitch pan separation (0 to 255) */
       
   383 	UBYTE pitpancenter;     /* pitch pan center (0 to 119) */
       
   384 	UBYTE rvolvar;          /* random volume varations (0 - 100%) */
       
   385 	UBYTE rpanvar;          /* random panning varations (0 - 100%) */
       
   386 
       
   387 	/* volume envelope */
       
   388 	UBYTE volflg;           /* bit 0: on 1: sustain 2: loop */
       
   389 	UBYTE volpts;
       
   390 	UBYTE volsusbeg;
       
   391 	UBYTE volsusend;
       
   392 	UBYTE volbeg;
       
   393 	UBYTE volend;
       
   394 	ENVPT volenv[ENVPOINTS];
       
   395 	/* panning envelope */
       
   396 	UBYTE panflg;           /* bit 0: on 1: sustain 2: loop */
       
   397 	UBYTE panpts;
       
   398 	UBYTE pansusbeg;
       
   399 	UBYTE pansusend;
       
   400 	UBYTE panbeg;
       
   401 	UBYTE panend;
       
   402 	ENVPT panenv[ENVPOINTS];
       
   403 	/* pitch envelope */
       
   404 	UBYTE pitflg;           /* bit 0: on 1: sustain 2: loop */
       
   405 	UBYTE pitpts;
       
   406 	UBYTE pitsusbeg;
       
   407 	UBYTE pitsusend;
       
   408 	UBYTE pitbeg;
       
   409 	UBYTE pitend;
       
   410 	ENVPT pitenv[ENVPOINTS];
       
   411 } INSTRUMENT;
       
   412 
       
   413 struct MP_CONTROL;
       
   414 struct MP_VOICE;
       
   415 
       
   416 /*
       
   417 	Module definition
       
   418 */
       
   419 
       
   420 /* maximum master channels supported */
       
   421 #define UF_MAXCHAN	64
       
   422 
       
   423 /* Module flags */
       
   424 #define UF_XMPERIODS	0x0001 /* XM periods / finetuning */
       
   425 #define UF_LINEAR		0x0002 /* LINEAR periods (UF_XMPERIODS must be set) */
       
   426 #define UF_INST			0x0004 /* Instruments are used */
       
   427 #define UF_NNA			0x0008 /* IT: NNA used, set numvoices rather
       
   428 								  than numchn */
       
   429 #define UF_S3MSLIDES	0x0010 /* uses old S3M volume slides */
       
   430 #define UF_BGSLIDES		0x0020 /* continue volume slides in the background */
       
   431 #define UF_HIGHBPM		0x0040 /* MED: can use >255 bpm */
       
   432 #define UF_NOWRAP		0x0080 /* XM-type (i.e. illogical) pattern break
       
   433 								  semantics */
       
   434 #define UF_ARPMEM		0x0100 /* IT: need arpeggio memory */
       
   435 #define UF_FT2QUIRKS	0x0200 /* emulate some FT2 replay quirks */
       
   436 #define UF_PANNING		0x0400 /* module uses panning effects or have
       
   437 								  non-tracker default initial panning */
       
   438 
       
   439 typedef struct MODULE {
       
   440 	/* general module information */
       
   441 		CHAR*       songname;    /* name of the song */
       
   442 		CHAR*       modtype;     /* string type of module loaded */
       
   443 		CHAR*       comment;     /* module comments */
       
   444 
       
   445 		UWORD       flags;       /* See module flags above */
       
   446 		UBYTE       numchn;      /* number of module channels */
       
   447 		UBYTE       numvoices;   /* max # voices used for full NNA playback */
       
   448 		UWORD       numpos;      /* number of positions in this song */
       
   449 		UWORD       numpat;      /* number of patterns in this song */
       
   450 		UWORD       numins;      /* number of instruments */
       
   451 		UWORD       numsmp;      /* number of samples */
       
   452 struct  INSTRUMENT* instruments; /* all instruments */
       
   453 struct  SAMPLE*     samples;     /* all samples */
       
   454 		UBYTE       realchn;     /* real number of channels used */
       
   455 		UBYTE       totalchn;    /* total number of channels used (incl NNAs) */
       
   456 
       
   457 	/* playback settings */
       
   458 		UWORD       reppos;      /* restart position */
       
   459 		UBYTE       initspeed;   /* initial song speed */
       
   460 		UWORD       inittempo;   /* initial song tempo */
       
   461 		UBYTE       initvolume;  /* initial global volume (0 - 128) */
       
   462 		UWORD       panning[UF_MAXCHAN]; /* panning positions */
       
   463 		UBYTE       chanvol[UF_MAXCHAN]; /* channel positions */
       
   464 		UWORD       bpm;         /* current beats-per-minute speed */
       
   465 		UWORD       sngspd;      /* current song speed */
       
   466 		SWORD       volume;      /* song volume (0-128) (or user volume) */
       
   467 
       
   468 		BOOL        extspd;      /* extended speed flag (default enabled) */
       
   469 		BOOL        panflag;     /* panning flag (default enabled) */
       
   470 		BOOL        wrap;        /* wrap module ? (default disabled) */
       
   471 		BOOL        loop;		 /* allow module to loop ? (default enabled) */
       
   472 		BOOL        fadeout;	 /* volume fade out during last pattern */
       
   473 
       
   474 		UWORD       patpos;      /* current row number */
       
   475 		SWORD       sngpos;      /* current song position */
       
   476 		ULONG       sngtime;     /* current song time in 2^-10 seconds */
       
   477 
       
   478 		SWORD       relspd;      /* relative speed factor */
       
   479 
       
   480 	/* internal module representation */
       
   481 		UWORD       numtrk;      /* number of tracks */
       
   482 		UBYTE**     tracks;      /* array of numtrk pointers to tracks */
       
   483 		UWORD*      patterns;    /* array of Patterns */
       
   484 		UWORD*      pattrows;    /* array of number of rows for each pattern */
       
   485 		UWORD*      positions;   /* all positions */
       
   486 
       
   487 		BOOL        forbid;      /* if true, no player update! */
       
   488 		UWORD       numrow;      /* number of rows on current pattern */
       
   489 		UWORD       vbtick;      /* tick counter (counts from 0 to sngspd) */
       
   490 		UWORD       sngremainder;/* used for song time computation */
       
   491 
       
   492 struct MP_CONTROL*  control;     /* Effects Channel info (size pf->numchn) */
       
   493 struct MP_VOICE*    voice;       /* Audio Voice information (size md_numchn) */
       
   494 
       
   495 		UBYTE       globalslide; /* global volume slide rate */
       
   496 		UBYTE       pat_repcrazy;/* module has just looped to position -1 */
       
   497 		UWORD       patbrk;      /* position where to start a new pattern */
       
   498 		UBYTE       patdly;      /* patterndelay counter (command memory) */
       
   499 		UBYTE       patdly2;     /* patterndelay counter (real one) */
       
   500 		SWORD       posjmp;      /* flag to indicate a jump is needed... */
       
   501 		UWORD		bpmlimit;	 /* threshold to detect bpm or speed values */
       
   502 } MODULE;
       
   503 
       
   504 /*
       
   505  *	========== Module loaders
       
   506  */
       
   507 
       
   508 struct MLOADER;
       
   509 
       
   510 MIKMODAPI extern CHAR*   MikMod_InfoLoader(void);
       
   511 MIKMODAPI extern void    MikMod_RegisterAllLoaders(void);
       
   512 MIKMODAPI extern void    MikMod_RegisterLoader(struct MLOADER*);
       
   513 
       
   514 MIKMODAPI extern struct MLOADER load_669; /* 669 and Extended-669 (by Tran/Renaissance) */
       
   515 MIKMODAPI extern struct MLOADER load_amf; /* DMP Advanced Module Format (by Otto Chrons) */
       
   516 MIKMODAPI extern struct MLOADER load_dsm; /* DSIK internal module format */
       
   517 MIKMODAPI extern struct MLOADER load_far; /* Farandole Composer (by Daniel Potter) */
       
   518 MIKMODAPI extern struct MLOADER load_gdm; /* General DigiMusic (by Edward Schlunder) */
       
   519 MIKMODAPI extern struct MLOADER load_it;  /* Impulse Tracker (by Jeffrey Lim) */
       
   520 MIKMODAPI extern struct MLOADER load_imf; /* Imago Orpheus (by Lutz Roeder) */
       
   521 MIKMODAPI extern struct MLOADER load_med; /* Amiga MED modules (by Teijo Kinnunen) */
       
   522 MIKMODAPI extern struct MLOADER load_m15; /* Soundtracker 15-instrument */
       
   523 MIKMODAPI extern struct MLOADER load_mod; /* Standard 31-instrument Module loader */
       
   524 MIKMODAPI extern struct MLOADER load_mtm; /* Multi-Tracker Module (by Renaissance) */
       
   525 MIKMODAPI extern struct MLOADER load_okt; /* Amiga Oktalyzer */
       
   526 MIKMODAPI extern struct MLOADER load_stm; /* ScreamTracker 2 (by Future Crew) */
       
   527 MIKMODAPI extern struct MLOADER load_stx; /* STMIK 0.2 (by Future Crew) */
       
   528 MIKMODAPI extern struct MLOADER load_s3m; /* ScreamTracker 3 (by Future Crew) */
       
   529 MIKMODAPI extern struct MLOADER load_ult; /* UltraTracker (by MAS) */
       
   530 MIKMODAPI extern struct MLOADER load_uni; /* MikMod and APlayer internal module format */
       
   531 MIKMODAPI extern struct MLOADER load_xm;  /* FastTracker 2 (by Triton) */
       
   532 
       
   533 /*
       
   534  *	========== Module player
       
   535  */
       
   536 
       
   537 MIKMODAPI extern MODULE* Player_Load(CHAR*,int,BOOL);
       
   538 MIKMODAPI extern MODULE* Player_LoadFP(FILE*,int,BOOL);
       
   539 MIKMODAPI extern MODULE* Player_LoadGeneric(MREADER*,int,BOOL);
       
   540 MIKMODAPI extern CHAR*   Player_LoadTitle(CHAR*);
       
   541 MIKMODAPI extern CHAR*   Player_LoadTitleFP(FILE*);
       
   542 MIKMODAPI extern void    Player_Free(MODULE*);
       
   543 MIKMODAPI extern void    Player_Start(MODULE*);
       
   544 MIKMODAPI extern BOOL    Player_Active(void);
       
   545 MIKMODAPI extern void    Player_Stop(void);
       
   546 MIKMODAPI extern void    Player_TogglePause(void);
       
   547 MIKMODAPI extern BOOL    Player_Paused(void);
       
   548 MIKMODAPI extern void    Player_NextPosition(void);
       
   549 MIKMODAPI extern void    Player_PrevPosition(void);
       
   550 MIKMODAPI extern void    Player_SetPosition(UWORD);
       
   551 MIKMODAPI extern BOOL    Player_Muted(UBYTE);
       
   552 MIKMODAPI extern void    Player_SetVolume(SWORD);
       
   553 MIKMODAPI extern MODULE* Player_GetModule(void);
       
   554 MIKMODAPI extern void    Player_SetSpeed(UWORD);
       
   555 MIKMODAPI extern void    Player_SetTempo(UWORD);
       
   556 MIKMODAPI extern void    Player_Unmute(SLONG,...);
       
   557 MIKMODAPI extern void    Player_Mute(SLONG,...);
       
   558 MIKMODAPI extern void    Player_ToggleMute(SLONG,...);
       
   559 MIKMODAPI extern int     Player_GetChannelVoice(UBYTE);
       
   560 MIKMODAPI extern UWORD   Player_GetChannelPeriod(UBYTE);
       
   561 
       
   562 typedef void (MikMod_player)(void);
       
   563 typedef MikMod_player *MikMod_player_t;
       
   564 
       
   565 MIKMODAPI extern MikMod_player_t MikMod_RegisterPlayer(MikMod_player_t);
       
   566 
       
   567 #define MUTE_EXCLUSIVE  32000
       
   568 #define MUTE_INCLUSIVE  32001
       
   569 
       
   570 /*
       
   571  *	========== Drivers
       
   572  */
       
   573 
       
   574 enum {
       
   575 	MD_MUSIC = 0,
       
   576 	MD_SNDFX
       
   577 };
       
   578 
       
   579 enum {
       
   580 	MD_HARDWARE = 0,
       
   581 	MD_SOFTWARE
       
   582 };
       
   583 
       
   584 /* Mixing flags */
       
   585 
       
   586 /* These ones take effect only after MikMod_Init or MikMod_Reset */
       
   587 #define DMODE_16BITS     0x0001 /* enable 16 bit output */
       
   588 #define DMODE_STEREO     0x0002 /* enable stereo output */
       
   589 #define DMODE_SOFT_SNDFX 0x0004 /* Process sound effects via software mixer */
       
   590 #define DMODE_SOFT_MUSIC 0x0008 /* Process music via software mixer */
       
   591 #define DMODE_HQMIXER    0x0010 /* Use high-quality (slower) software mixer */
       
   592 /* These take effect immediately. */
       
   593 #define DMODE_SURROUND   0x0100 /* enable surround sound */
       
   594 #define DMODE_INTERP     0x0200 /* enable interpolation */
       
   595 #define DMODE_REVERSE    0x0400 /* reverse stereo */
       
   596 
       
   597 struct SAMPLOAD;
       
   598 typedef struct MDRIVER {
       
   599 struct MDRIVER* next;
       
   600 	CHAR*       Name;
       
   601 	CHAR*       Version;
       
   602 
       
   603 	UBYTE       HardVoiceLimit; /* Limit of hardware mixer voices */
       
   604 	UBYTE       SoftVoiceLimit; /* Limit of software mixer voices */
       
   605 
       
   606 	CHAR*       Alias;
       
   607 
       
   608 	void        (*CommandLine)      (CHAR*);
       
   609 	BOOL        (*IsPresent)        (void);
       
   610 	SWORD       (*SampleLoad)       (struct SAMPLOAD*,int);
       
   611 	void        (*SampleUnload)     (SWORD);
       
   612 	ULONG       (*FreeSampleSpace)  (int);
       
   613 	ULONG       (*RealSampleLength) (int,struct SAMPLE*);
       
   614 	BOOL        (*Init)             (void);
       
   615 	void        (*Exit)             (void);
       
   616 	BOOL        (*Reset)            (void);
       
   617 	BOOL        (*SetNumVoices)     (void);
       
   618 	BOOL        (*PlayStart)        (void);
       
   619 	void        (*PlayStop)         (void);
       
   620 	void        (*Update)           (void);
       
   621 	void		(*Pause)			(void);
       
   622 	void        (*VoiceSetVolume)   (UBYTE,UWORD);
       
   623 	UWORD       (*VoiceGetVolume)   (UBYTE);
       
   624 	void        (*VoiceSetFrequency)(UBYTE,ULONG);
       
   625 	ULONG       (*VoiceGetFrequency)(UBYTE);
       
   626 	void        (*VoiceSetPanning)  (UBYTE,ULONG);
       
   627 	ULONG       (*VoiceGetPanning)  (UBYTE);
       
   628 	void        (*VoicePlay)        (UBYTE,SWORD,ULONG,ULONG,ULONG,ULONG,UWORD);
       
   629 	void        (*VoiceStop)        (UBYTE);
       
   630 	BOOL        (*VoiceStopped)     (UBYTE);
       
   631 	SLONG       (*VoiceGetPosition) (UBYTE);
       
   632 	ULONG       (*VoiceRealVolume)  (UBYTE);
       
   633 } MDRIVER;
       
   634 
       
   635 /* These variables can be changed at ANY time and results will be immediate */
       
   636 MIKMODAPI extern UBYTE md_volume;      /* global sound volume (0-128) */
       
   637 MIKMODAPI extern UBYTE md_musicvolume; /* volume of song */
       
   638 MIKMODAPI extern UBYTE md_sndfxvolume; /* volume of sound effects */
       
   639 MIKMODAPI extern UBYTE md_reverb;      /* 0 = none;  15 = chaos */
       
   640 MIKMODAPI extern UBYTE md_pansep;      /* 0 = mono;  128 == 100% (full left/right) */
       
   641 
       
   642 /* The variables below can be changed at any time, but changes will not be
       
   643    implemented until MikMod_Reset is called. A call to MikMod_Reset may result
       
   644    in a skip or pop in audio (depending on the soundcard driver and the settings
       
   645    changed). */
       
   646 MIKMODAPI extern UWORD md_device;      /* device */
       
   647 MIKMODAPI extern UWORD md_mixfreq;     /* mixing frequency */
       
   648 MIKMODAPI extern UWORD md_mode;        /* mode. See DMODE_? flags above */
       
   649 
       
   650 /* The following variable should not be changed! */
       
   651 MIKMODAPI extern MDRIVER* md_driver;   /* Current driver in use. */
       
   652 
       
   653 /* Known drivers list */
       
   654 
       
   655 MIKMODAPI extern struct MDRIVER drv_nos;    /* no sound */
       
   656 MIKMODAPI extern struct MDRIVER drv_pipe;   /* piped output */
       
   657 MIKMODAPI extern struct MDRIVER drv_raw;    /* raw file disk writer [music.raw] */
       
   658 MIKMODAPI extern struct MDRIVER drv_stdout; /* output to stdout */
       
   659 MIKMODAPI extern struct MDRIVER drv_wav;    /* RIFF WAVE file disk writer [music.wav] */
       
   660 
       
   661 MIKMODAPI extern struct MDRIVER drv_ultra;  /* Linux Ultrasound driver */
       
   662 MIKMODAPI extern struct MDRIVER drv_sam9407;	/* Linux sam9407 driver */
       
   663 
       
   664 MIKMODAPI extern struct MDRIVER drv_AF;     /* Dec Alpha AudioFile */
       
   665 MIKMODAPI extern struct MDRIVER drv_aix;    /* AIX audio device */
       
   666 MIKMODAPI extern struct MDRIVER drv_alsa;   /* Advanced Linux Sound Architecture (ALSA) */
       
   667 MIKMODAPI extern struct MDRIVER drv_esd;    /* Enlightened sound daemon (EsounD) */
       
   668 MIKMODAPI extern struct MDRIVER drv_hp;     /* HP-UX audio device */
       
   669 MIKMODAPI extern struct MDRIVER drv_oss;    /* OpenSound System (Linux,FreeBSD...) */
       
   670 MIKMODAPI extern struct MDRIVER drv_sgi;    /* SGI audio library */
       
   671 MIKMODAPI extern struct MDRIVER drv_sun;    /* Sun/NetBSD/OpenBSD audio device */
       
   672 
       
   673 MIKMODAPI extern struct MDRIVER drv_dart;   /* OS/2 Direct Audio RealTime */
       
   674 MIKMODAPI extern struct MDRIVER drv_os2;    /* OS/2 MMPM/2 */
       
   675 
       
   676 MIKMODAPI extern struct MDRIVER drv_ds;     /* Win32 DirectSound driver */
       
   677 MIKMODAPI extern struct MDRIVER drv_win;    /* Win32 multimedia API driver */
       
   678 
       
   679 MIKMODAPI extern struct MDRIVER drv_mac;    /* Macintosh Sound Manager driver */
       
   680 
       
   681 /*========== Virtual channel mixer interface (for user-supplied drivers only) */
       
   682 
       
   683 MIKMODAPI extern BOOL  VC_Init(void);
       
   684 MIKMODAPI extern void  VC_Exit(void);
       
   685 MIKMODAPI extern BOOL  VC_SetNumVoices(void);
       
   686 MIKMODAPI extern ULONG VC_SampleSpace(int);
       
   687 MIKMODAPI extern ULONG VC_SampleLength(int,SAMPLE*);
       
   688 
       
   689 MIKMODAPI extern BOOL  VC_PlayStart(void);
       
   690 MIKMODAPI extern void  VC_PlayStop(void);
       
   691 
       
   692 MIKMODAPI extern SWORD VC_SampleLoad(struct SAMPLOAD*,int);
       
   693 MIKMODAPI extern void  VC_SampleUnload(SWORD);
       
   694 
       
   695 MIKMODAPI extern ULONG VC_WriteBytes(SBYTE*,ULONG);
       
   696 MIKMODAPI extern ULONG VC_SilenceBytes(SBYTE*,ULONG);
       
   697 
       
   698 MIKMODAPI extern void  VC_VoiceSetVolume(UBYTE,UWORD);
       
   699 MIKMODAPI extern UWORD VC_VoiceGetVolume(UBYTE);
       
   700 MIKMODAPI extern void  VC_VoiceSetFrequency(UBYTE,ULONG);
       
   701 MIKMODAPI extern ULONG VC_VoiceGetFrequency(UBYTE);
       
   702 MIKMODAPI extern void  VC_VoiceSetPanning(UBYTE,ULONG);
       
   703 MIKMODAPI extern ULONG VC_VoiceGetPanning(UBYTE);
       
   704 MIKMODAPI extern void  VC_VoicePlay(UBYTE,SWORD,ULONG,ULONG,ULONG,ULONG,UWORD);
       
   705 
       
   706 MIKMODAPI extern void  VC_VoiceStop(UBYTE);
       
   707 MIKMODAPI extern BOOL  VC_VoiceStopped(UBYTE);
       
   708 MIKMODAPI extern SLONG VC_VoiceGetPosition(UBYTE);
       
   709 MIKMODAPI extern ULONG VC_VoiceRealVolume(UBYTE);
       
   710 
       
   711 #ifdef __cplusplus
       
   712 }
       
   713 #endif
       
   714 
       
   715 #endif
       
   716 
       
   717 /* ex:set ts=4: */