OSDN Git Service

wwww
[proj16/16.git] / 16 / v2 / source / ENGINE / AUDIO.H
1 /*\r
2  * $Id: audio.h 1.17 1996/09/25 17:13:02 chasan released $\r
3  *\r
4  * SEAL Synthetic Audio Library API Interface\r
5  *\r
6  * Copyright (C) 1995, 1996 Carlos Hasan. All Rights Reserved.\r
7  *\r
8  */\r
9 \r
10 #ifndef __AUDIO_H\r
11 #define __AUDIO_H\r
12 \r
13 #ifdef __cplusplus\r
14 extern "C" {\r
15 #endif\r
16 \r
17 #ifndef WIN32\r
18 #define AIAPI\r
19 #else\r
20 #define AIAPI __stdcall\r
21 #endif\r
22 \r
23 #ifndef WINAPI\r
24 \r
25 /* atomic data types definitions */\r
26 typedef void            VOID;\r
27 typedef char            CHAR;\r
28 typedef int             INT;\r
29 typedef long            LONG;\r
30 typedef int             BOOL;\r
31 \r
32 typedef unsigned char   BYTE;\r
33 typedef unsigned short  WORD;\r
34 typedef unsigned int    UINT;\r
35 typedef unsigned long   DWORD;\r
36 \r
37 typedef VOID*           LPVOID;\r
38 typedef CHAR*           LPCHAR;\r
39 typedef INT*            LPINT;\r
40 typedef LONG*           LPLONG;\r
41 typedef BOOL*           LPBOOL;\r
42 typedef BYTE*           LPBYTE;\r
43 typedef WORD*           LPWORD;\r
44 typedef UINT*           LPUINT;\r
45 typedef DWORD*          LPDWORD;\r
46 typedef CHAR*           LPSTR;\r
47 typedef DWORD           HANDLE;\r
48 \r
49 /* helper macros */\r
50 #define LOBYTE(s)       ((BYTE)(s))\r
51 #define HIBYTE(s)       ((BYTE)((WORD)(s)>>8))\r
52 #define LOWORD(l)       ((WORD)(l))\r
53 #define HIWORD(l)       ((WORD)((DWORD)(l)>>16))\r
54 #define MAKEWORD(l,h)   ((WORD)(((BYTE)(l))|(((WORD)((BYTE)(h)))<<8)))\r
55 #define MAKELONG(l,h)   ((DWORD)(((WORD)(l))|(((DWORD)((WORD)(h)))<<16)))\r
56 \r
57 #endif\r
58 \r
59 \r
60 /* audio system version number */\r
61 #define AUDIO_SYSTEM_VERSION            0x0101\r
62 \r
63 /* audio capabilities bit fields definitions */\r
64 #define AUDIO_FORMAT_1M08               0x00000001\r
65 #define AUDIO_FORMAT_1S08               0x00000002\r
66 #define AUDIO_FORMAT_1M16               0x00000004\r
67 #define AUDIO_FORMAT_1S16               0x00000008\r
68 #define AUDIO_FORMAT_2M08               0x00000010\r
69 #define AUDIO_FORMAT_2S08               0x00000020\r
70 #define AUDIO_FORMAT_2M16               0x00000040\r
71 #define AUDIO_FORMAT_2S16               0x00000080\r
72 #define AUDIO_FORMAT_4M08               0x00000100\r
73 #define AUDIO_FORMAT_4S08               0x00000200\r
74 #define AUDIO_FORMAT_4M16               0x00000400\r
75 #define AUDIO_FORMAT_4S16               0x00000800\r
76 \r
77 /* audio format bit fields defines for devices and waveforms */\r
78 #define AUDIO_FORMAT_8BITS              0x0000\r
79 #define AUDIO_FORMAT_16BITS             0x0001\r
80 #define AUDIO_FORMAT_LOOP               0x0010\r
81 #define AUDIO_FORMAT_BIDILOOP           0x0020\r
82 #define AUDIO_FORMAT_REVERSE            0x0080\r
83 #define AUDIO_FORMAT_MONO               0x0000\r
84 #define AUDIO_FORMAT_STEREO             0x0100\r
85 #define AUDIO_FORMAT_FILTER             0x8000\r
86 \r
87 /* audio resource limits defines */\r
88 #define AUDIO_MAX_VOICES                32\r
89 #define AUDIO_MAX_SAMPLES               16\r
90 #define AUDIO_MAX_PATCHES               128\r
91 #define AUDIO_MAX_PATTERNS              256\r
92 #define AUDIO_MAX_ORDERS                256\r
93 #define AUDIO_MAX_NOTES                 96\r
94 #define AUDIO_MAX_POINTS                12\r
95 #define AUDIO_MIN_PERIOD                1\r
96 #define AUDIO_MAX_PERIOD                31999\r
97 #define AUDIO_MIN_VOLUME                0x00\r
98 #define AUDIO_MAX_VOLUME                0x40\r
99 #define AUDIO_MIN_PANNING               0x00\r
100 #define AUDIO_MAX_PANNING               0xFF\r
101 #define AUDIO_MIN_POSITION              0x00000000L\r
102 #define AUDIO_MAX_POSITION              0x00100000L\r
103 #define AUDIO_MIN_FREQUENCY             0x00000200L\r
104 #define AUDIO_MAX_FREQUENCY             0x00080000L\r
105 \r
106 /* audio error code defines */\r
107 #define AUDIO_ERROR_NONE                0x0000\r
108 #define AUDIO_ERROR_INVALHANDLE         0x0001\r
109 #define AUDIO_ERROR_INVALPARAM          0x0002\r
110 #define AUDIO_ERROR_NOTSUPPORTED        0x0003\r
111 #define AUDIO_ERROR_BADDEVICEID         0x0004\r
112 #define AUDIO_ERROR_NODEVICE            0x0005\r
113 #define AUDIO_ERROR_DEVICEBUSY          0x0006\r
114 #define AUDIO_ERROR_BADFORMAT           0x0007\r
115 #define AUDIO_ERROR_NOMEMORY            0x0008\r
116 #define AUDIO_ERROR_NODRAMMEMORY        0x0009\r
117 #define AUDIO_ERROR_FILENOTFOUND        0x000A\r
118 #define AUDIO_ERROR_BADFILEFORMAT       0x000B\r
119 #define AUDIO_LAST_ERROR                0x000B\r
120 \r
121 /* audio device identifiers */\r
122 #define AUDIO_DEVICE_NONE               0x0000\r
123 #define AUDIO_DEVICE_MAPPER             0xFFFF\r
124 \r
125 /* audio product identifiers */\r
126 #define AUDIO_PRODUCT_NONE              0x0000\r
127 #define AUDIO_PRODUCT_SB                0x0001\r
128 #define AUDIO_PRODUCT_SB15              0x0002\r
129 #define AUDIO_PRODUCT_SB20              0x0003\r
130 #define AUDIO_PRODUCT_SBPRO             0x0004\r
131 #define AUDIO_PRODUCT_SB16              0x0005\r
132 #define AUDIO_PRODUCT_AWE32             0x0006\r
133 #define AUDIO_PRODUCT_WSS               0x0007\r
134 #define AUDIO_PRODUCT_ESS               0x0008\r
135 #define AUDIO_PRODUCT_GUS               0x0009\r
136 #define AUDIO_PRODUCT_GUSDB             0x000A\r
137 #define AUDIO_PRODUCT_GUSMAX            0x000B\r
138 #define AUDIO_PRODUCT_IWAVE             0x000C\r
139 #define AUDIO_PRODUCT_PAS               0x000D\r
140 #define AUDIO_PRODUCT_PAS16             0x000E\r
141 #define AUDIO_PRODUCT_ARIA              0x000F\r
142 #define AUDIO_PRODUCT_WINDOWS           0x0100\r
143 #define AUDIO_PRODUCT_LINUX             0x0101\r
144 #define AUDIO_PRODUCT_SPARC             0x0102\r
145 #define AUDIO_PRODUCT_SGI               0x0103\r
146 #define AUDIO_PRODUCT_DSOUND            0x0104\r
147 \r
148 /* audio envelope bit fields */\r
149 #define AUDIO_ENVELOPE_ON               0x0001\r
150 #define AUDIO_ENVELOPE_SUSTAIN          0x0002\r
151 #define AUDIO_ENVELOPE_LOOP             0x0004\r
152 \r
153 /* audio pattern bit fields */\r
154 #define AUDIO_PATTERN_PACKED            0x0080\r
155 #define AUDIO_PATTERN_NOTE              0x0001\r
156 #define AUDIO_PATTERN_SAMPLE            0x0002\r
157 #define AUDIO_PATTERN_VOLUME            0x0004\r
158 #define AUDIO_PATTERN_COMMAND           0x0008\r
159 #define AUDIO_PATTERN_PARAMS            0x0010\r
160 \r
161 /* audio module bit fields */\r
162 #define AUDIO_MODULE_AMIGA              0x0000\r
163 #define AUDIO_MODULE_LINEAR             0x0001\r
164 #define AUDIO_MODULE_PANNING            0x8000\r
165 \r
166 #pragma pack(1)\r
167 \r
168 /* audio capabilities structure */\r
169 typedef struct {\r
170     WORD    wProductId;                         /* product identifier */\r
171     CHAR    szProductName[30];                  /* product name */\r
172     DWORD   dwFormats;                          /* formats supported */\r
173 } AUDIOCAPS, *LPAUDIOCAPS;\r
174 \r
175 /* audio format structure */\r
176 typedef struct {\r
177     UINT    nDeviceId;                          /* device identifier */\r
178     WORD    wFormat;                            /* playback format */\r
179     WORD    nSampleRate;                        /* sampling frequency */\r
180 } AUDIOINFO, *LPAUDIOINFO;\r
181 \r
182 /* audio waveform structure */\r
183 typedef struct {\r
184     LPBYTE  lpData;                             /* data pointer */\r
185     DWORD   dwHandle;                           /* waveform handle */\r
186     DWORD   dwLength;                           /* waveform length */\r
187     DWORD   dwLoopStart;                        /* loop start point */\r
188     DWORD   dwLoopEnd;                          /* loop end point */\r
189     WORD    nSampleRate;                        /* sampling rate */\r
190     WORD    wFormat;                            /* format bits */\r
191 } AUDIOWAVE, *LPAUDIOWAVE;\r
192 \r
193 \r
194 /* audio envelope point structure */\r
195 typedef struct {\r
196     WORD    nFrame;                             /* envelope frame */\r
197     WORD    nValue;                             /* envelope value */\r
198 } AUDIOPOINT, *LPAUDIOPOINT;\r
199 \r
200 /* audio envelope structure */\r
201 typedef struct {\r
202     AUDIOPOINT aEnvelope[AUDIO_MAX_POINTS];     /* envelope points */\r
203     BYTE    nPoints;                            /* number of points */\r
204     BYTE    nSustain;                           /* sustain point */\r
205     BYTE    nLoopStart;                         /* loop start point */\r
206     BYTE    nLoopEnd;                           /* loop end point */\r
207     WORD    wFlags;                             /* envelope flags */\r
208     WORD    nSpeed;                             /* envelope speed */\r
209 } AUDIOENVELOPE, *LPAUDIOENVELOPE;\r
210 \r
211 /* audio sample structure */\r
212 typedef struct {\r
213     CHAR    szSampleName[32];                   /* sample name */\r
214     BYTE    nVolume;                            /* default volume */\r
215     BYTE    nPanning;                           /* default panning */\r
216     BYTE    nRelativeNote;                      /* relative note */\r
217     BYTE    nFinetune;                          /* finetune */\r
218     AUDIOWAVE Wave;                             /* waveform handle */\r
219 } AUDIOSAMPLE, *LPAUDIOSAMPLE;\r
220 \r
221 /* audio patch structure */\r
222 typedef struct {\r
223     CHAR    szPatchName[32];                    /* patch name */\r
224     BYTE    aSampleNumber[AUDIO_MAX_NOTES];     /* multi-sample table */\r
225     WORD    nSamples;                           /* number of samples */\r
226     BYTE    nVibratoType;                       /* vibrato type */\r
227     BYTE    nVibratoSweep;                      /* vibrato sweep */\r
228     BYTE    nVibratoDepth;                      /* vibrato depth */\r
229     BYTE    nVibratoRate;                       /* vibrato rate */\r
230     WORD    nVolumeFadeout;                     /* volume fadeout */\r
231     AUDIOENVELOPE Volume;                       /* volume envelope */\r
232     AUDIOENVELOPE Panning;                      /* panning envelope */\r
233     LPAUDIOSAMPLE aSampleTable;                 /* sample table */\r
234 } AUDIOPATCH, *LPAUDIOPATCH;\r
235 \r
236 /* audio pattern structure */\r
237 typedef struct {\r
238     WORD    nPacking;                           /* packing type */\r
239     WORD    nTracks;                            /* number of tracks */\r
240     WORD    nRows;                              /* number of rows */\r
241     WORD    nSize;                              /* data size */\r
242     LPBYTE  lpData;                             /* data pointer */\r
243 } AUDIOPATTERN, *LPAUDIOPATTERN;\r
244 \r
245 /* audio module structure */\r
246 typedef struct {\r
247     CHAR    szModuleName[32];                   /* module name */\r
248     WORD    wFlags;                             /* module flags */\r
249     WORD    nOrders;                            /* number of orders */\r
250     WORD    nRestart;                           /* restart position */\r
251     WORD    nTracks;                            /* number of tracks */\r
252     WORD    nPatterns;                          /* number of patterns */\r
253     WORD    nPatches;                           /* number of patches */\r
254     WORD    nTempo;                             /* initial tempo */\r
255     WORD    nBPM;                               /* initial BPM */\r
256     BYTE    aOrderTable[AUDIO_MAX_ORDERS];      /* order table */\r
257     BYTE    aPanningTable[AUDIO_MAX_VOICES];    /* panning table */\r
258     LPAUDIOPATTERN aPatternTable;               /* pattern table */\r
259     LPAUDIOPATCH aPatchTable;                   /* patch table */\r
260 } AUDIOMODULE, *LPAUDIOMODULE;\r
261 \r
262 /* audio callback function defines */\r
263 typedef VOID (AIAPI* LPFNAUDIOWAVE)(LPBYTE, UINT);\r
264 typedef VOID (AIAPI* LPFNAUDIOTIMER)(VOID);\r
265 typedef VOID (AIAPI* LPFNAUDIOCALLBACK)(BYTE, UINT, UINT);\r
266 \r
267 /* audio handle defines */\r
268 typedef HANDLE  HAC;\r
269 typedef HAC*    LPHAC;\r
270 \r
271 #pragma pack()\r
272 \r
273 \r
274 /* audio interface API prototypes */\r
275 UINT AIAPI AInitialize(VOID);\r
276 UINT AIAPI AGetVersion(VOID);\r
277 UINT AIAPI AGetAudioNumDevs(VOID);\r
278 UINT AIAPI AGetAudioDevCaps(UINT nDeviceId, LPAUDIOCAPS lpCaps);\r
279 UINT AIAPI AGetErrorText(UINT nErrorCode, LPSTR lpText, UINT nSize);\r
280 \r
281 UINT AIAPI APingAudio(LPUINT lpnDeviceId);\r
282 UINT AIAPI AOpenAudio(LPAUDIOINFO lpInfo);\r
283 UINT AIAPI ACloseAudio(VOID);\r
284 UINT AIAPI AUpdateAudio(VOID);\r
285 \r
286 UINT AIAPI AOpenVoices(UINT nVoices);\r
287 UINT AIAPI ACloseVoices(VOID);\r
288 \r
289 UINT AIAPI ASetAudioCallback(LPFNAUDIOWAVE lpfnAudioWave);\r
290 UINT AIAPI ASetAudioTimerProc(LPFNAUDIOTIMER lpfnAudioTimer);\r
291 UINT AIAPI ASetAudioTimerRate(UINT nTimerRate);\r
292 \r
293 LONG AIAPI AGetAudioDataAvail(VOID);\r
294 UINT AIAPI ACreateAudioData(LPAUDIOWAVE lpWave);\r
295 UINT AIAPI ADestroyAudioData(LPAUDIOWAVE lpWave);\r
296 UINT AIAPI AWriteAudioData(LPAUDIOWAVE lpWave, DWORD dwOffset, UINT nCount);\r
297 \r
298 UINT AIAPI ACreateAudioVoice(LPHAC lphVoice);\r
299 UINT AIAPI ADestroyAudioVoice(HAC hVoice);\r
300 \r
301 UINT AIAPI APlayVoice(HAC hVoice, LPAUDIOWAVE lpWave);\r
302 UINT AIAPI APrimeVoice(HAC hVoice, LPAUDIOWAVE lpWave);\r
303 UINT AIAPI AStartVoice(HAC hVoice);\r
304 UINT AIAPI AStopVoice(HAC hVoice);\r
305 \r
306 UINT AIAPI ASetVoicePosition(HAC hVoice, LONG dwPosition);\r
307 UINT AIAPI ASetVoiceFrequency(HAC hVoice, LONG dwFrequency);\r
308 UINT AIAPI ASetVoiceVolume(HAC hVoice, UINT nVolume);\r
309 UINT AIAPI ASetVoicePanning(HAC hVoice, UINT nPanning);\r
310 \r
311 UINT AIAPI AGetVoicePosition(HAC hVoice, LPLONG lpdwPosition);\r
312 UINT AIAPI AGetVoiceFrequency(HAC hVoice, LPLONG lpdwFrequency);\r
313 UINT AIAPI AGetVoiceVolume(HAC hVoice, LPUINT lpnVolume);\r
314 UINT AIAPI AGetVoicePanning(HAC hVoice, LPUINT lpnPanning);\r
315 UINT AIAPI AGetVoiceStatus(HAC hVoice, LPBOOL lpnStatus);\r
316 \r
317 UINT AIAPI APlayModule(LPAUDIOMODULE lpModule);\r
318 UINT AIAPI AStopModule(VOID);\r
319 UINT AIAPI APauseModule(VOID);\r
320 UINT AIAPI AResumeModule(VOID);\r
321 UINT AIAPI ASetModuleVolume(UINT nVolume);\r
322 UINT AIAPI ASetModulePosition(UINT nOrder, UINT nRow);\r
323 UINT AIAPI AGetModuleVolume(LPUINT lpnVolume);\r
324 UINT AIAPI AGetModulePosition(LPUINT pnOrder, LPUINT lpnRow);\r
325 UINT AIAPI AGetModuleStatus(LPBOOL lpnStatus);\r
326 UINT AIAPI ASetModuleCallback(LPFNAUDIOCALLBACK lpfnAudioCallback);\r
327 \r
328 UINT AIAPI ALoadModuleFile(LPSTR lpszFileName,\r
329                 LPAUDIOMODULE* lplpModule, DWORD dwFileOffset);\r
330 UINT AIAPI AFreeModuleFile(LPAUDIOMODULE lpModule);\r
331 \r
332 UINT AIAPI ALoadWaveFile(LPSTR lpszFileName,\r
333                 LPAUDIOWAVE* lplpWave, DWORD dwFileOffset);\r
334 UINT AIAPI AFreeWaveFile(LPAUDIOWAVE lpWave);\r
335 \r
336 #ifdef __cplusplus\r
337 };\r
338 #endif\r
339 \r
340 #endif\r