AUDIO.H
Upload User: nthssl
Upload Date: 2022-04-05
Package Size: 25357k
Code Size: 14k
Category:

OpenCV

Development Platform:

Visual C++

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