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