backporting...
[dosdemo] / libs / midas / midasdll.h
1 /*      midasdll.h
2  *
3  * MIDAS DLL programming interface
4  *
5  * $Id: midasdll.h,v 1.32 1997/08/15 16:48:25 pekangas Exp $
6  *
7  * Copyright 1996,1997 Housemarque Inc.
8  *
9  * This file is part of MIDAS Digital Audio System, and may only be
10  * used, modified and distributed under the terms of the MIDAS
11  * Digital Audio System license, "license.txt". By continuing to use,
12  * modify or distribute this file you indicate that you have
13  * read the license and understand and accept it fully.
14 */
15
16
17 #ifndef __midasdll_h
18 #define __midasdll_h
19
20
21 /* This is a kluge, but necessary as Watcom C sucks: */
22 #ifdef EXPORT_IN_MIDASDLL_H
23
24 #ifdef __WC32__
25     #define _FUNC(x) x __export __stdcall
26     #define MIDAS_CALL __cdecl
27 #else
28     #define _FUNC(x) __declspec(dllexport) x __stdcall
29     #define MIDAS_CALL __cdecl
30 #endif
31
32 #else
33     #if defined(__linux__) || defined(__UNIX__) || defined(__DJGPP__)
34         #define _FUNC(x) x
35         #define MIDAS_CALL
36     #else
37         #ifdef __DOS__
38             #define _FUNC(x) x cdecl
39             #define MIDAS_CALL __cdecl
40         #else
41             #define _FUNC(x) x __stdcall
42             #define MIDAS_CALL __cdecl
43         #endif
44     #endif
45 #endif
46
47
48 #if defined(__WATCOMC__) && defined(__cplusplus)
49 /* Disable to annoying Watcom C++ warnings - I have no idea how to get around
50    these without breaking Visual C compatibility: */
51 #pragma warning 604 9
52 #pragma warning 594 9
53 #endif
54
55
56 /* We'll need to define DWORD, BOOL, TRUE and FALSE if someone hasn't
57    done that before. For now, we'll just assume that if no-one has defined
58    TRUE we need to define everything. There definitions are compatible with
59    windows.h. If something else in your system defines these differently,
60    things should still work OK as long as FALSE is 0, TRUE is nonzero and
61    DWORD is 32-bit. Take care that you don't compare BOOLs like "bool == TRUE"
62    in that case though, just use "bool".
63
64    THIS IS UGLY AND MAY NEED FIXING!
65    ---------------------------------
66 */
67
68 #ifndef TRUE
69 #define TRUE 1
70 #define FALSE 0
71 typedef int BOOL;
72 typedef unsigned long DWORD;
73 #endif /* ifndef TRUE */
74
75
76
77 enum MIDASoptions
78 {
79     MIDAS_OPTION_NONE = 0,
80     MIDAS_OPTION_MIXRATE,
81     MIDAS_OPTION_OUTPUTMODE,
82     MIDAS_OPTION_MIXBUFLEN,
83     MIDAS_OPTION_MIXBUFBLOCKS,
84     MIDAS_OPTION_DSOUND_MODE,
85     MIDAS_OPTION_DSOUND_HWND,
86     MIDAS_OPTION_DSOUND_OBJECT,
87     MIDAS_OPTION_DSOUND_BUFLEN,
88     MIDAS_OPTION_16BIT_ULAW_AUTOCONVERT,
89     MIDAS_OPTION_FILTER_MODE,
90     MIDAS_OPTION_MIXING_MODE,
91     MIDAS_OPTION_DEFAULT_STEREO_SEPARATION,
92     MIDAS_OPTION_FORCE_NO_SOUND
93 };
94
95
96 enum MIDASmodes
97 {
98     MIDAS_MODE_NONE = 0,
99     MIDAS_MODE_MONO = 1,
100     MIDAS_MODE_STEREO = 2,
101     MIDAS_MODE_8BIT = 4,
102     MIDAS_MODE_16BIT = 8,
103     MIDAS_MODE_8BIT_MONO = MIDAS_MODE_8BIT | MIDAS_MODE_MONO,
104     MIDAS_MODE_8BIT_STEREO = MIDAS_MODE_8BIT | MIDAS_MODE_STEREO,
105     MIDAS_MODE_16BIT_MONO = MIDAS_MODE_16BIT | MIDAS_MODE_MONO,
106     MIDAS_MODE_16BIT_STEREO = MIDAS_MODE_16BIT | MIDAS_MODE_STEREO
107 };
108
109
110
111 enum MIDASsampleTypes
112 {
113     MIDAS_SAMPLE_NONE = 0,
114     MIDAS_SAMPLE_8BIT_MONO = 1,
115     MIDAS_SAMPLE_16BIT_MONO = 2,
116     MIDAS_SAMPLE_8BIT_STEREO = 3,
117     MIDAS_SAMPLE_16BIT_STEREO = 4,
118     MIDAS_SAMPLE_ADPCM_MONO = 5,
119     MIDAS_SAMPLE_ADPCM_STEREO = 6,
120     MIDAS_SAMPLE_ULAW_MONO = 7,
121     MIDAS_SAMPLE_ULAW_STEREO = 8
122 };
123
124
125
126 enum MIDASloop
127 {
128     MIDAS_LOOP_NO = 0,
129     MIDAS_LOOP_YES
130 };
131
132
133 enum MIDASpanning
134 {
135     MIDAS_PAN_LEFT = -64,
136     MIDAS_PAN_MIDDLE = 0,
137     MIDAS_PAN_RIGHT = 64,
138     MIDAS_PAN_SURROUND = 0x80
139 };
140
141
142 enum MIDASchannels
143 {
144     MIDAS_CHANNEL_AUTO = 0xFFFF,
145     MIDAS_ILLEGAL_CHANNEL = 0xFFFF
146 };
147
148
149 enum MIDASdsoundModes
150 {
151     MIDAS_DSOUND_DISABLED = 0,
152     MIDAS_DSOUND_STREAM,
153     MIDAS_DSOUND_PRIMARY,
154     MIDAS_DSOUND_FORCE_STREAM
155 };
156
157
158 enum MIDASpositions
159 {
160     MIDAS_POSITION_DEFAULT = 0xFFFFFFFF
161 };
162
163
164
165 enum MIDASfilterModes
166 {
167     MIDAS_FILTER_NONE = 0,
168     MIDAS_FILTER_LESS = 1,
169     MIDAS_FILTER_MORE = 2,
170     MIDAS_FILTER_AUTO = 3
171 };
172
173
174 enum MIDASechoFilterTypes
175 {
176     MIDAS_ECHO_FILTER_NONE = 0,
177     MIDAS_ECHO_FILTER_LOWPASS = 1,
178     MIDAS_ECHO_FILTER_HIGHPASS = 2
179 };
180
181
182 enum MIDASmixingModes
183 {
184     MIDAS_MIX_NORMAL_QUALITY = 0,
185     MIDAS_MIX_HIGH_QUALITY = 1
186 };
187
188
189 enum MIDASsamplePlayStatus
190 {
191     MIDAS_SAMPLE_STOPPED = 0,
192     MIDAS_SAMPLE_PLAYING = 1
193 };
194
195
196 enum MIDASpostProcPosition
197 {
198     MIDAS_POST_PROC_FIRST = 0,
199     MIDAS_POST_PROC_LAST
200 };
201
202
203
204 typedef struct
205 {
206     char        songName[32];
207     unsigned    songLength;
208     unsigned    numPatterns;
209     unsigned    numInstruments;
210     unsigned    numChannels;
211 } MIDASmoduleInfo;
212
213
214
215 typedef struct
216 {
217     char        instName[32];
218 } MIDASinstrumentInfo;
219
220
221
222 typedef struct
223 {
224     unsigned    position;
225     unsigned    pattern;
226     unsigned    row;
227     int         syncInfo;
228     unsigned    songLoopCount;
229 } MIDASplayStatus;
230
231
232 typedef struct
233 {
234     unsigned    delay;                  /* milliseconds, 16.16 fixed point */
235     int         gain;                   /* gain, 16.16 fixed point */
236     int         reverseChannels;        /* reverse channels? */
237     unsigned    filterType;             /* filter type, MIDASechoFilterTypes */
238 } MIDASecho;
239
240
241 typedef struct
242 {
243     int         feedback;               /* feedback, 16.16 fixed point */
244     int         gain;                   /* total gain, 16.16 fixed point */
245     unsigned    numEchoes;              /* number of echoes */
246     MIDASecho   *echoes;                /* the echoes */
247 } MIDASechoSet;
248
249
250 typedef void (MIDAS_CALL *MIDASpostProcFunction)(void *data,
251     unsigned numSamples, void *user);
252
253 typedef struct _MIDASpostProcessor
254 {
255     struct _MIDASpostProcessor *next, *prev; /* reserved */
256     void *userData;                          /* reserved */
257     MIDASpostProcFunction floatMono;
258     MIDASpostProcFunction floatStereo;
259     MIDASpostProcFunction intMono;
260     MIDASpostProcFunction intStereo;
261 } MIDASpostProcessor;
262
263
264
265 typedef void* MIDASmodule;
266 typedef DWORD MIDASmodulePlayHandle;
267 typedef DWORD MIDASsample;
268 typedef DWORD MIDASsamplePlayHandle;
269 typedef void* MIDASstreamHandle;
270 typedef void* MIDASechoHandle;
271
272
273 #ifdef __cplusplus
274 extern "C" {
275 #endif
276
277 _FUNC(int)      MIDASgetLastError(void);
278 _FUNC(char*)    MIDASgetErrorMessage(int errorCode);
279
280 _FUNC(DWORD)    MIDASgetDisplayRefreshRate(void);
281
282 _FUNC(BOOL)     MIDASstartup(void);
283 _FUNC(BOOL)     MIDASdetectSD(void);
284 _FUNC(BOOL)     MIDASdetectSoundCard(void);
285 _FUNC(BOOL)     MIDASconfig(void);
286 _FUNC(BOOL)     MIDASloadConfig(char *fileName);
287 _FUNC(BOOL)     MIDASsaveConfig(char *fileName);
288 _FUNC(BOOL)     MIDASreadConfigRegistry(DWORD key, char *subKey);
289 _FUNC(BOOL)     MIDASwriteConfigRegistry(DWORD key, char *subKey);
290
291 _FUNC(BOOL)     MIDASinit(void);
292 _FUNC(BOOL)     MIDASsetOption(int option, DWORD value);
293 _FUNC(DWORD)    MIDASgetOption(int option);
294 _FUNC(BOOL)     MIDASclose(void);
295 _FUNC(BOOL)     MIDASsuspend(void);
296 _FUNC(BOOL)     MIDASresume(void);
297 _FUNC(BOOL)     MIDASopenChannels(int numChannels);
298 _FUNC(BOOL)     MIDAScloseChannels(void);
299 _FUNC(BOOL)     MIDASsetAmplification(DWORD amplification);
300 _FUNC(BOOL)     MIDASstartBackgroundPlay(DWORD pollRate);
301 _FUNC(BOOL)     MIDASstopBackgroundPlay(void);
302 _FUNC(BOOL)     MIDASpoll(void);
303 _FUNC(void)     MIDASlock(void);
304 _FUNC(void)     MIDASunlock(void);
305 _FUNC(char*)    MIDASgetVersionString(void);
306 _FUNC(BOOL)     MIDASsetTimerCallbacks(DWORD rate, BOOL displaySync,
307                                        void (MIDAS_CALL *preVR)(),
308                                        void (MIDAS_CALL *immVR)(),
309                                        void (MIDAS_CALL *inVR)());
310 _FUNC(BOOL)     MIDASremoveTimerCallbacks(void);
311
312 _FUNC(DWORD)    MIDASallocateChannel(void);
313 _FUNC(BOOL)     MIDASfreeChannel(DWORD channel);
314
315 _FUNC(MIDASmodule) MIDASloadModule(char *fileName);
316 _FUNC(MIDASmodulePlayHandle) MIDASplayModule(MIDASmodule module,
317                                              BOOL loopSong);
318 _FUNC(MIDASmodulePlayHandle) MIDASplayModuleSection(MIDASmodule module,
319                                                     unsigned startPos,
320                                                     unsigned endPos,
321                                                     unsigned restartPos,
322                                                     BOOL loopSong);
323 _FUNC(BOOL)     MIDASstopModule(MIDASmodulePlayHandle playHandle);
324 _FUNC(BOOL)     MIDASfreeModule(MIDASmodule module);
325
326 _FUNC(BOOL)     MIDASgetPlayStatus(MIDASmodulePlayHandle playHandle,
327                                    MIDASplayStatus *status);
328 _FUNC(BOOL)     MIDASsetPosition(MIDASmodulePlayHandle playHandle,
329                                  int newPosition);
330 _FUNC(BOOL)     MIDASsetMusicVolume(MIDASmodulePlayHandle playHandle,
331                                     unsigned volume);
332 _FUNC(BOOL)     MIDASgetModuleInfo(MIDASmodule module, MIDASmoduleInfo *info);
333 _FUNC(BOOL)     MIDASgetInstrumentInfo(MIDASmodule module, int instNum,
334                     MIDASinstrumentInfo *info);
335 _FUNC(BOOL)     MIDASsetMusicSyncCallback(MIDASmodulePlayHandle playHandle,
336                                           void (MIDAS_CALL *callback)
337                                           (unsigned syncInfo,
338                                            unsigned position, unsigned row));
339 _FUNC(BOOL)     MIDASfadeMusicChannel(MIDASmodulePlayHandle playHandle,
340                                       unsigned channel, unsigned fade);
341
342 _FUNC(MIDASsample) MIDASloadRawSample(char *fileName, int sampleType,
343                     int loopSample);
344 _FUNC(MIDASsample) MIDASloadWaveSample(char *fileName, int loopSample);
345 _FUNC(BOOL)         MIDASfreeSample(MIDASsample sample);
346 _FUNC(BOOL)         MIDASallocAutoEffectChannels(unsigned numChannels);
347 _FUNC(BOOL)         MIDASfreeAutoEffectChannels(void);
348 _FUNC(MIDASsamplePlayHandle) MIDASplaySample(MIDASsample sample,
349                         unsigned channel, int priority, unsigned rate,
350                         unsigned volume, int panning);
351 _FUNC(BOOL)     MIDASstopSample(MIDASsamplePlayHandle sample);
352 _FUNC(BOOL)     MIDASsetSampleRate(MIDASsamplePlayHandle sample,
353                     unsigned rate);
354 _FUNC(BOOL)     MIDASsetSampleVolume(MIDASsamplePlayHandle sample,
355                     unsigned volume);
356 _FUNC(BOOL)     MIDASsetSamplePanning(MIDASsamplePlayHandle sample,
357                     int panning);
358 _FUNC(BOOL)     MIDASsetSamplePriority(MIDASsamplePlayHandle sample,
359                     int priority);
360 _FUNC(DWORD)    MIDASgetSamplePlayStatus(MIDASsamplePlayHandle sample);
361
362 _FUNC(MIDASstreamHandle) MIDASplayStreamFile(char *fileName,
363                                              unsigned sampleType,
364                                              unsigned sampleRate,
365                                              unsigned bufferLength,
366                                              int loopStream);
367 _FUNC(BOOL)     MIDASstopStream(MIDASstreamHandle stream);
368
369 _FUNC(MIDASstreamHandle) MIDASplayStreamWaveFile(char *fileName,
370                                                  unsigned bufferLength,
371                                                  int loopStream);
372
373 _FUNC(MIDASstreamHandle) MIDASplayStreamPolling(unsigned sampleType,
374                                                 unsigned sampleRate,
375                                                 unsigned bufferLength);
376 _FUNC(unsigned) MIDASfeedStreamData(MIDASstreamHandle stream,
377                     unsigned char *data, unsigned numBytes, BOOL feedAll);
378
379 _FUNC(BOOL)     MIDASsetStreamRate(MIDASstreamHandle stream, unsigned rate);
380 _FUNC(BOOL)     MIDASsetStreamVolume(MIDASstreamHandle stream,
381                     unsigned volume);
382 _FUNC(BOOL)     MIDASsetStreamPanning(MIDASstreamHandle stream, int panning);
383
384 _FUNC(DWORD)    MIDASgetStreamBytesBuffered(MIDASstreamHandle stream);
385 _FUNC(BOOL)     MIDASpauseStream(MIDASstreamHandle stream);
386 _FUNC(BOOL)     MIDASresumeStream(MIDASstreamHandle stream);
387
388 _FUNC(MIDASechoHandle) MIDASaddEchoEffect(MIDASechoSet *echoSet);
389 _FUNC(BOOL)     MIDASremoveEchoEffect(MIDASechoHandle echoHandle);
390
391 _FUNC(BOOL)     MIDASaddPostProcessor(MIDASpostProcessor *postProc,
392                                       unsigned procPos, void *userData);
393 _FUNC(BOOL)     MIDASremovePostProcessor(MIDASpostProcessor *postProc);
394
395
396
397 #ifdef __cplusplus
398 }
399 #endif
400
401
402
403
404 #endif
405
406
407 /*
408  * $Log: midasdll.h,v $
409  * Revision 1.32  1997/08/15 16:48:25  pekangas
410  * Added user post-processing functions
411  *
412  * Revision 1.31  1997/07/31 16:36:34  pekangas
413  * Fixed to work in Linux again
414  *
415  * Revision 1.30  1997/07/31 14:30:58  pekangas
416  * Added option MIDAS_OPTION_FORCE_NO_SOUND
417  *
418  * Revision 1.29  1997/07/31 10:56:48  pekangas
419  * Renamed from MIDAS Sound System to MIDAS Digital Audio System
420  *
421  * Revision 1.28  1997/07/29 16:51:09  pekangas
422  * Added sample playing status query
423  *
424  * Revision 1.27  1997/07/25 13:49:47  pekangas
425  * Actually added MIDAS_FILTER_AUTO (oops)
426  *
427  * Revision 1.26  1997/07/25 13:48:24  pekangas
428  * Changed MIDAS_OPTION_OVERSAMPLING setting to MIDAS_OPTION_MIXING_MODE
429  * Added automatic filtering
430  * Added MIDASgetOption()
431  *
432  * Revision 1.25  1997/07/11 11:05:54  pekangas
433  * Added new options to the echoes: Each echo now has its own filter setting
434  * (low/high-pass or nothing) and the whole echo set has a common gain.
435  *
436  * Revision 1.24  1997/07/10 18:40:23  pekangas
437  * Added echo effect support
438  *
439  * Revision 1.23  1997/07/09 08:58:00  pekangas
440  * Added default stereo separation
441  *
442  * Revision 1.22  1997/07/08 19:16:44  pekangas
443  * Added Win32 setup functions, save/restore setup from registry, and
444  * fixed WinWave to ignore buffer blocks -setting to be compatible with the
445  * new setup.
446  *
447  * Revision 1.21  1997/06/05 20:18:49  pekangas
448  * Added preliminary support for interpolating mixing (mono only at the
449  * moment)
450  *
451  * Revision 1.20  1997/06/02 00:54:15  jpaana
452  * Changed most __LINUX__ defines to __UNIX__ for generic *nix porting
453  *
454  * Revision 1.19  1997/05/21 17:47:41  pekangas
455  * Changed MIDASfilterTypes to MIDASfilterModes
456  *
457  * Revision 1.18  1997/05/20 20:37:59  pekangas
458  * Added WAVE support to both streams and samples
459  *
460  * Revision 1.17  1997/05/07 17:14:53  pekangas
461  * Added a lot of new thread synchronization code, mainly to minimize the
462  * cases where MIDAS state may be modified when the player thread is active
463  * and vice versa. Added MIDASlock() and MIDASunlock() to the API.
464  *
465  * Revision 1.16  1997/05/03 17:54:02  pekangas
466  * Added optional simple output filtering
467  *
468  * Revision 1.15  1997/05/02 13:19:49  pekangas
469  * Several changes: Added support for non-looping module playback, added
470  * support for playing several modules simultaneously, added module section
471  * playback, added automatic channel allocation and deallocation to stream
472  * playback, simplified automatic effect channel handling and added functions
473  * for allocating and deallocating individiual channels.
474  *
475  * Revision 1.14  1997/04/08 15:48:07  pekangas
476  * Added gmpFadeChannel / MIDASfadeMusicChannel functions
477  *
478  * Revision 1.13  1997/04/07 21:07:51  pekangas
479  * Added the ability to pause/resume streams.
480  * Added functions to query the number of stream bytes buffered
481  *
482  * Revision 1.12  1997/03/09 19:13:01  pekangas
483  * Added the possibility to turn off u-law autoconvert
484  *
485  * Revision 1.11  1997/03/05 16:49:49  pekangas
486  * Added timer functions to DLL, some other minor modifications
487  *
488  * Revision 1.10  1997/02/27 16:03:36  pekangas
489  * Added DJGPP support
490  *
491  * Revision 1.9  1997/02/20 19:49:40  pekangas
492  * Added u-law sample type
493  *
494  * Revision 1.8  1997/02/19 20:45:09  pekangas
495  * Added functions MIDASsuspend() and MIDASresume()
496  *
497  * Revision 1.7  1997/02/12 17:18:37  pekangas
498  * Added MIDASsetAmplification()
499  *
500  * Revision 1.6  1997/02/12 16:28:12  pekangas
501  * Added ADPCM sample type
502  *
503  * Revision 1.5  1997/02/06 20:58:20  pekangas
504  * Added DirectSound support - new files, errors, and global flags
505  *
506  * Revision 1.4  1997/01/16 18:41:59  pekangas
507  * Changed copyright messages to Housemarque
508  *
509  * Revision 1.3  1997/01/16 18:26:27  pekangas
510  * Added numerous new functions
511  *
512  * Revision 1.2  1996/09/28 08:12:40  jpaana
513  * Fixed for Linux
514  *
515  * Revision 1.1  1996/09/25 18:38:12  pekangas
516  * Initial revision
517  *
518 */