Mercurial > ~darius > hgwebdir.cgi > mikmod
comparison include/mikmod.h @ 10:55420dceb8e0
Initial entry of mikmod into the CVS tree.
author | darius |
---|---|
date | Fri, 23 Jan 1998 16:05:11 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
9:990c9dadb348 | 10:55420dceb8e0 |
---|---|
1 | |
2 #ifndef MIKMOD_H | |
3 #define MIKMOD_H | |
4 | |
5 #include "mmio.h" | |
6 | |
7 #ifdef __cplusplus | |
8 extern "C" { | |
9 #endif | |
10 | |
11 | |
12 #define MUTE_EXCLUSIVE 32000 | |
13 #define MUTE_INCLUSIVE 32001 | |
14 | |
15 #define PAN_LEFT 0 | |
16 #define PAN_CENTER 128 | |
17 #define PAN_RIGHT 255 | |
18 #define PAN_SURROUND 512 // panning value for Dolby Surround | |
19 | |
20 | |
21 #define MikMod_RegisterDriver(x) MD_RegisterDriver(&x) | |
22 #define MikMod_RegisterLoader(x) ML_RegisterLoader(&x) | |
23 #define MikMod_RegisterErrorHandler(x) _mm_RegisterErrorHandler(x) | |
24 | |
25 | |
26 // The following #define macros are for retaining API compatiability | |
27 // with the beta version of MikMod 3.0, and are TEMPORARY! They WILL | |
28 // be removed in the future! | |
29 | |
30 #define MD_RegisterPlayer(x) MikMod_RegisterPlayer(x) | |
31 #define MD_Init MikMod_Init | |
32 #define MD_Exit MikMod_Exit | |
33 #define MD_Update MikMod_Update | |
34 #define ML_Free(x) MikMod_FreeSong(x) | |
35 #define MD_SetNumChannels(x,y) MikMod_SetNumVoices(x,y) | |
36 #define MD_SetNumVoices(x,y) MikMod_SetNumVoices(x,y) | |
37 #define MD_PlayStart MikMod_EnableOutput | |
38 #define MD_PlayStop MikMod_DisableOutput | |
39 | |
40 #define MD_VoiceSetVolume(x,y) Voice_SetVolume(x,y) | |
41 #define MD_VoiceSetFrequency(x,y) Voice_SetFrequency(x,y) | |
42 #define MD_VoiceSetPanning(x,y) Voice_SetPanning(x,y) | |
43 #define MD_VoicePlay(x,y,z) Voice_Play(x,y,z) | |
44 #define MD_VoiceStop(x) Voice_Stop(x) | |
45 #define MD_VoiceReleaseSustain(x) Voice_ReleaseSustain(x) | |
46 #define MD_VoiceStopped(x) Voice_Stopped(x) | |
47 #define MD_VoiceGetPosition(x) Voice_GetPosition(x) | |
48 #define MD_VoiceRealVolume(x) Voice_RealVolume(x) | |
49 | |
50 | |
51 #define SFX_CRITICAL 1 | |
52 | |
53 | |
54 /************************************************************************** | |
55 ****** mikmod types: ****************************************************** | |
56 **************************************************************************/ | |
57 | |
58 // Sample format [loading and in-memory] flags: | |
59 #define SF_16BITS 1 | |
60 #define SF_SIGNED 2 | |
61 #define SF_STEREO 4 | |
62 #define SF_DELTA 8 | |
63 #define SF_BIG_ENDIAN 16 | |
64 | |
65 // General Playback flags | |
66 | |
67 #define SF_LOOP 32 | |
68 #define SF_BIDI 64 | |
69 #define SF_SUSTAIN 128 | |
70 #define SF_REVERSE 256 | |
71 | |
72 // Module-only Playback Flags | |
73 | |
74 #define SF_OWNPAN 512 | |
75 #define SF_UST_LOOP 1024 | |
76 | |
77 | |
78 typedef struct SAMPLE | |
79 { ULONG speed; // Base playing speed/frequency of note (Middle C in player) | |
80 UBYTE volume; // volume 0-64 | |
81 UWORD panning; // panning (0-255 or PAN_SURROUND) | |
82 ULONG length; // length of sample (in samples!) | |
83 ULONG loopstart; // repeat position (relative to start, in samples) | |
84 ULONG loopend; // repeat end | |
85 ULONG susbegin; // sustain loop begin (in samples) \ Not Supported | |
86 ULONG susend; // sustain loop end / Yet! | |
87 | |
88 UWORD flags; // sample format in memory | |
89 | |
90 // Variables used by the module player only! (ignored for sound effects) | |
91 | |
92 UBYTE globvol; // global volume | |
93 UBYTE vibflags; // autovibrato flag stuffs | |
94 UBYTE vibtype; // Vibratos moved from INSTRUMENT to SAMPLE | |
95 UBYTE vibsweep; | |
96 UBYTE vibdepth; | |
97 UBYTE vibrate; | |
98 | |
99 CHAR *samplename; // name of the sample | |
100 | |
101 // Values used internally only (not saved in disk formats) | |
102 | |
103 UWORD avibpos; // autovibrato pos [player use] | |
104 UBYTE divfactor; // for sample scaling (maintains proper period slides) | |
105 ULONG seekpos; // seek position in file | |
106 SWORD handle; // sample handle used by individual drivers | |
107 } SAMPLE; | |
108 | |
109 | |
110 | |
111 // --> Struct : SAMPLOAD | |
112 // This is a handle of sorts attached to any sample registered with | |
113 // SL_RegisterSample. Generally, this only need be used or changed by the | |
114 // loaders and drivers of mikmod. | |
115 | |
116 typedef struct SAMPLOAD | |
117 { struct SAMPLOAD *next; | |
118 | |
119 ULONG length; // length of sample (in samples!) | |
120 ULONG loopstart; // repeat position (relative to start, in samples) | |
121 ULONG loopend; // repeat end | |
122 | |
123 UWORD infmt, outfmt; | |
124 int scalefactor; | |
125 SAMPLE *sample; | |
126 FILE *fp; | |
127 } SAMPLOAD; | |
128 | |
129 extern void SL_HalveSample(SAMPLOAD *s); | |
130 extern void SL_Sample8to16(SAMPLOAD *s); | |
131 extern void SL_Sample16to8(SAMPLOAD *s); | |
132 extern void SL_SampleSigned(SAMPLOAD *s); | |
133 extern void SL_SampleUnsigned(SAMPLOAD *s); | |
134 extern BOOL SL_LoadSamples(void); // Returns 1 on error! | |
135 extern SAMPLOAD *SL_RegisterSample(SAMPLE *s, int type, FILE *fp); // Returns 1 on error! | |
136 extern void SL_Load(void *buffer, SAMPLOAD *smp, int length); | |
137 extern BOOL SL_Init(SAMPLOAD *s); | |
138 extern void SL_Exit(SAMPLOAD *s); | |
139 | |
140 | |
141 /************************************************************************** | |
142 ****** Wavload stuff: ***************************************************** | |
143 **************************************************************************/ | |
144 | |
145 SAMPLE *WAV_LoadFP(FILE *fp); | |
146 SAMPLE *WAV_LoadFN(CHAR *filename); | |
147 void WAV_Free(SAMPLE *si); | |
148 | |
149 | |
150 #include "ptform.h" | |
151 | |
152 | |
153 /************************************************************************** | |
154 ****** Driver stuff: ****************************************************** | |
155 **************************************************************************/ | |
156 | |
157 // max. number of handles a driver has to provide. (not strict) | |
158 | |
159 #define MAXSAMPLEHANDLES 384 | |
160 | |
161 | |
162 enum | |
163 { MD_MUSIC = 0, | |
164 MD_SNDFX | |
165 }; | |
166 | |
167 enum | |
168 { MD_HARDWARE = 0, | |
169 MD_SOFTWARE | |
170 }; | |
171 | |
172 | |
173 // possible mixing mode bits: | |
174 // -------------------------- | |
175 // These take effect only after MikMod_Init or MikMod_Reset. | |
176 | |
177 #define DMODE_16BITS 1 // enable 16 bit output | |
178 #define DMODE_SURROUND 2 // enable Dolby surround sound (not yet supported) | |
179 #define DMODE_SOFT_SNDFX 4 // Process sound effects via software mixer (not yet supported) | |
180 #define DMODE_SOFT_MUSIC 8 // Process music via software mixer (not yet supported) | |
181 | |
182 // These take effect immidiately. | |
183 | |
184 #define DMODE_STEREO 16 // enable stereo output | |
185 #define DMODE_REVERSE 32 // reverse stereo | |
186 #define DMODE_INTERP 64 // enable interpolation (not yet supported) | |
187 | |
188 | |
189 // driver structure: | |
190 | |
191 typedef struct MDRIVER | |
192 { struct MDRIVER *next; | |
193 CHAR *Name; | |
194 CHAR *Version; | |
195 UBYTE HardVoiceLimit, // Limit of hardware mixer voices for this driver | |
196 SoftVoiceLimit; // Limit of software mixer voices for this driver | |
197 | |
198 BOOL (*IsPresent) (void); | |
199 SWORD (*SampleLoad) (SAMPLOAD *s, int type, FILE *fp); | |
200 void (*SampleUnLoad) (SWORD handle); | |
201 ULONG (*FreeSampleSpace) (int type); | |
202 ULONG (*RealSampleLength) (int type, SAMPLE *s); | |
203 BOOL (*Init) (void); | |
204 void (*Exit) (void); | |
205 BOOL (*Reset) (void); | |
206 BOOL (*SetNumVoices) (void); | |
207 BOOL (*PlayStart) (void); | |
208 void (*PlayStop) (void); | |
209 void (*Update) (void); | |
210 void (*VoiceSetVolume) (UBYTE voice, UWORD vol); | |
211 void (*VoiceSetFrequency) (UBYTE voice, ULONG frq); | |
212 void (*VoiceSetPanning) (UBYTE voice, ULONG pan); | |
213 void (*VoicePlay) (UBYTE voice, SWORD handle, ULONG start, ULONG size, ULONG reppos, ULONG repend, UWORD flags); | |
214 void (*VoiceStop) (UBYTE voice); | |
215 BOOL (*VoiceStopped) (UBYTE voice); | |
216 void (*VoiceReleaseSustain)(UBYTE voice); | |
217 SLONG (*VoiceGetPosition) (UBYTE voice); | |
218 ULONG (*VoiceRealVolume) (UBYTE voice); | |
219 | |
220 BOOL (*StreamInit) (ULONG speed, UWORD flags); | |
221 void (*StreamExit) (void); | |
222 void (*StreamSetSpeed) (ULONG speed); | |
223 SLONG (*StreamGetPosition) (void); | |
224 void (*StreamLoadFP) (FILE *fp); | |
225 } MDRIVER; | |
226 | |
227 | |
228 // These variables can be changed at ANY time and results | |
229 // will be immidiate: | |
230 | |
231 extern UBYTE md_bpm; // current song / hardware BPM rate | |
232 extern UBYTE md_volume; // Global sound volume (0-128) | |
233 extern UBYTE md_musicvolume; // volume of song | |
234 extern UBYTE md_sndfxvolume; // volume of sound effects | |
235 extern UBYTE md_reverb; // 0 = none; 15 = chaos | |
236 extern UBYTE md_pansep; // 0 = mono; 128 == 100% (full left/right) | |
237 | |
238 | |
239 // The variables below can be changed at any time, but changes will | |
240 // not be implimented until MikMod_Reset is called. A call to | |
241 // MikMod_Reset may result in a skip or pop in audio (depending on | |
242 // the soundcard driver and the settings changed). | |
243 | |
244 extern UWORD md_device; // Device. 0 = autodetect, other # depend on driver register order. | |
245 extern UWORD md_mixfreq; // mixing frequency. Valid 5000 -> 44100 | |
246 extern UWORD md_dmabufsize; // DMA buffer size. Valid 512 -> 32000 | |
247 extern UWORD md_mode; // Mode. See DMODE_? flags above | |
248 | |
249 | |
250 // Variables below can be changed via MD_SetNumVoices at any time. | |
251 // However, a call to MD_SetNumVoicess while the driver | |
252 // is active will cause the sound to skip slightly. | |
253 | |
254 extern UBYTE md_numchn, // number of song + sound effects voices | |
255 md_sngchn, // number of song voices | |
256 md_sfxchn, // number of sound effects voices | |
257 md_hardchn, // number of hardware mixed voices | |
258 md_softchn; // number of software mixed voices | |
259 | |
260 | |
261 // Following variables should not be changed! | |
262 extern MDRIVER *md_driver; // Current driver in use. See MDRIVER struct | |
263 // above for structure info contents. | |
264 | |
265 // This is for use by the hardware drivers only. It points to the | |
266 // registered tickhandler function. | |
267 extern void (*md_player)(void); | |
268 | |
269 | |
270 // main driver prototypes: | |
271 | |
272 extern void MikMod_RegisterAllDrivers(void); | |
273 extern void MikMod_RegisterAllLoaders(void); | |
274 | |
275 extern BOOL MikMod_Init(void); | |
276 extern void MikMod_Exit(void); | |
277 extern BOOL MikMod_Reset(void); | |
278 extern int MikMod_PlaySample(SAMPLE *s, ULONG start, UBYTE flags); | |
279 extern BOOL MikMod_SetNumVoices(int music, int sndfx); | |
280 extern BOOL MikMod_Active(void); | |
281 extern BOOL MikMod_EnableOutput(void); | |
282 extern void MikMod_DisableOutput(void); | |
283 extern void MikMod_RegisterPlayer(void (*plr)(void)); | |
284 extern void MikMod_Update(void); | |
285 | |
286 extern void Voice_SetVolume(int voice, UWORD ivol); | |
287 extern void Voice_SetFrequency(int voice, ULONG frq); | |
288 extern void Voice_SetPanning(int voice, ULONG pan); | |
289 extern void Voice_Play(int voice,SAMPLE *s, ULONG start); | |
290 extern void Voice_Stop(int voice); | |
291 extern void Voice_ReleaseSustain(int voice); | |
292 extern BOOL Voice_Stopped(int voice); | |
293 extern SLONG Voice_GetPosition(int voice); | |
294 extern ULONG Voice_RealVolume(int voice); | |
295 | |
296 extern void MD_InfoDriver(void); | |
297 extern void MD_RegisterDriver(MDRIVER *drv); | |
298 extern SWORD MD_SampleLoad(SAMPLOAD *s, int type, FILE *fp); | |
299 extern void MD_SampleUnLoad(SWORD handle); | |
300 extern void MD_SetBPM(UBYTE bpm); | |
301 extern ULONG MD_SampleSpace(int type); | |
302 extern ULONG MD_SampleLength(int type, SAMPLE *s); | |
303 | |
304 // Declare external drivers: | |
305 | |
306 extern MDRIVER drv_awe; // experimental SB-AWE driver | |
307 extern MDRIVER drv_gus; // gravis ultrasound driver [hardware / software mixing] | |
308 extern MDRIVER drv_gus2; // gravis ultrasound driver [hardware mixing only] | |
309 extern MDRIVER drv_sb; // soundblaster 1.5 / 2.0 DSP driver | |
310 extern MDRIVER drv_sbpro; // soundblaster Pro DSP driver | |
311 extern MDRIVER drv_sb16; // soundblaster 16 DSP driver | |
312 extern MDRIVER drv_ss; // ensoniq soundscape driver | |
313 extern MDRIVER drv_pas; // PAS16 driver | |
314 extern MDRIVER drv_wss; // Windows Sound System driver | |
315 extern MDRIVER drv_nos; // nosound driver | |
316 extern MDRIVER drv_raw; // raw file output driver [music.raw] | |
317 extern MDRIVER drv_wav; // RIFF WAVE file output driver [music.wav] | |
318 | |
319 extern MDRIVER drv_w95; // win95 driver | |
320 extern MDRIVER drv_oss; // linux voxware driver | |
321 extern MDRIVER drv_AF; // Dec Alpha AudioFile driver | |
322 extern MDRIVER drv_sun; // Sun driver | |
323 extern MDRIVER drv_os2; // Os2 driver | |
324 extern MDRIVER drv_hp; // HP-UX /dev/audio driver | |
325 extern MDRIVER drv_aix; // AIX audio-device driver | |
326 extern MDRIVER drv_sgi; // SGI audio-device driver | |
327 extern MDRIVER drv_tim; // timing driver | |
328 extern MDRIVER drv_ultra; // ultra driver for linux | |
329 | |
330 | |
331 /************************************************************************** | |
332 ****** Streaming Audio stuff: ********************************************* | |
333 **************************************************************************/ | |
334 | |
335 | |
336 typedef struct MSTREAM | |
337 { struct MSTREAM *next; | |
338 CHAR *type; | |
339 CHAR *version; | |
340 BOOL (*Init)(void); | |
341 BOOL (*Test)(void); | |
342 BOOL (*Load)(void); | |
343 void (*Cleanup)(void); | |
344 } MSTREAM; | |
345 | |
346 | |
347 extern int stream_bufsize; | |
348 extern FILE *stream_fp; | |
349 extern SLONG stream_seekpos; | |
350 extern SLONG stream_reppos; | |
351 | |
352 | |
353 /************************************************************************** | |
354 ****** Virtual channel stuff: ********************************************* | |
355 **************************************************************************/ | |
356 | |
357 extern BOOL VC_Init(void); | |
358 extern void VC_Exit(void); | |
359 extern BOOL VC_SetNumVoices(void); | |
360 extern ULONG VC_SampleSpace(int type); | |
361 extern ULONG VC_SampleLength(int type, SAMPLE *s); | |
362 | |
363 extern BOOL VC_PlayStart(void); | |
364 extern void VC_PlayStop(void); | |
365 | |
366 extern SWORD VC_SampleLoad(SAMPLOAD *sload, int type, FILE *fp); | |
367 extern void VC_SampleUnload(SWORD handle); | |
368 | |
369 extern void VC_WriteSamples(SBYTE *buf,ULONG todo); | |
370 extern ULONG VC_WriteBytes(SBYTE *buf,ULONG todo); | |
371 extern void VC_SilenceBytes(SBYTE *buf,ULONG todo); | |
372 | |
373 extern void VC_VoiceSetVolume(UBYTE voice, UWORD vol); | |
374 extern void VC_VoiceSetFrequency(UBYTE voice, ULONG frq); | |
375 extern void VC_VoiceSetPanning(UBYTE voice, ULONG pan); | |
376 extern void VC_VoicePlay(UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags); | |
377 | |
378 extern void VC_VoiceStop(UBYTE voice); | |
379 extern BOOL VC_VoiceStopped(UBYTE voice); | |
380 extern void VC_VoiceReleaseSustain(UBYTE voice); | |
381 extern SLONG VC_VoiceGetPosition(UBYTE voice); | |
382 extern ULONG VC_VoiceRealVolume(UBYTE voice); | |
383 | |
384 | |
385 extern BOOL VC2_Init(void); | |
386 extern void VC2_Exit(void); | |
387 extern BOOL VC2_SetNumVoices(void); | |
388 extern ULONG VC2_SampleSpace(int type); | |
389 extern ULONG VC2_SampleLength(int type, SAMPLE *s); | |
390 | |
391 extern BOOL VC2_PlayStart(void); | |
392 extern void VC2_PlayStop(void); | |
393 | |
394 extern SWORD VC2_SampleLoad(SAMPLOAD *sload, int type, FILE *fp); | |
395 extern void VC2_SampleUnload(SWORD handle); | |
396 | |
397 extern void VC2_WriteSamples(SBYTE *buf,ULONG todo); | |
398 extern ULONG VC2_WriteBytes(SBYTE *buf,ULONG todo); | |
399 extern void VC2_SilenceBytes(SBYTE *buf,ULONG todo); | |
400 | |
401 extern void VC2_VoiceSetVolume(UBYTE voice, UWORD vol); | |
402 extern void VC2_VoiceSetFrequency(UBYTE voice, ULONG frq); | |
403 extern void VC2_VoiceSetPanning(UBYTE voice, ULONG pan); | |
404 extern void VC2_VoicePlay(UBYTE voice,SWORD handle,ULONG start,ULONG size,ULONG reppos,ULONG repend,UWORD flags); | |
405 | |
406 extern void VC2_VoiceStop(UBYTE voice); | |
407 extern BOOL VC2_VoiceStopped(UBYTE voice); | |
408 extern void VC2_VoiceReleaseSustain(UBYTE voice); | |
409 extern SLONG VC2_VoiceGetPosition(UBYTE voice); | |
410 | |
411 #ifdef __cplusplus | |
412 } | |
413 #endif | |
414 | |
415 #endif |