├── .gitignore ├── LICENSE ├── README.md ├── dllmain.cpp ├── mss ├── mss.h ├── mss32.lib └── mss32_2.lib ├── resource.h ├── vagdec.cpp ├── vagdec.h ├── vbcalls.cpp ├── vbcalls.h ├── vbdec.rc ├── vbdec.sln ├── vbdec.vcxproj └── vbdec.vcxproj.filters /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | # Build results 10 | [Dd]ebug/ 11 | [Dd]ebugPublic/ 12 | [Rr]elease/ 13 | [Nn]ormal/ 14 | [Nn]ightly/ 15 | output/ 16 | symbols/ 17 | x64/ 18 | x86/ 19 | build/ 20 | bld/ 21 | [Bb]in/ 22 | [Oo]bj/ 23 | 24 | # MSTest test Results 25 | [Tt]est[Rr]esult*/ 26 | [Bb]uild[Ll]og.* 27 | 28 | #NUNIT 29 | *.VisualState.xml 30 | TestResult.xml 31 | 32 | *.cso 33 | *_i.c 34 | *_p.c 35 | *_i.h 36 | *.ilk 37 | *.meta 38 | *.obj 39 | *.pch 40 | *.pdb 41 | *.pgc 42 | *.pgd 43 | *.rsp 44 | *.sbr 45 | *.tlb 46 | *.tli 47 | *.tlh 48 | *.tmp 49 | *.tmp_proj 50 | *.log 51 | *.vspscc 52 | *.vssscc 53 | .builds 54 | *.pidb 55 | *.svclog 56 | *.scc 57 | 58 | # Chutzpah Test files 59 | _Chutzpah* 60 | 61 | # Visual C++ cache files 62 | ipch/ 63 | *.aps 64 | *.ncb 65 | *.opensdf 66 | *.sdf 67 | *.db 68 | *.opendb 69 | *.cachefile 70 | 71 | # Visual Studio profiler 72 | *.psess 73 | *.vsp 74 | *.vspx 75 | 76 | # TFS 2012 Local Workspace 77 | $tf/ 78 | 79 | # Guidance Automation Toolkit 80 | *.gpState 81 | 82 | # ReSharper is a .NET coding add-in 83 | _ReSharper*/ 84 | *.[Rr]e[Ss]harper 85 | *.DotSettings.user 86 | 87 | # JustCode is a .NET coding addin-in 88 | .JustCode 89 | 90 | # TeamCity is a build add-in 91 | _TeamCity* 92 | 93 | # DotCover is a Code Coverage Tool 94 | *.dotCover 95 | 96 | # NCrunch 97 | *.ncrunch* 98 | _NCrunch_* 99 | .*crunch*.local.xml 100 | 101 | # MightyMoose 102 | *.mm.* 103 | AutoTest.Net/ 104 | 105 | # Web workbench (sass) 106 | .sass-cache/ 107 | 108 | # Installshield output folder 109 | [Ee]xpress/ 110 | 111 | # DocProject is a documentation generator add-in 112 | DocProject/buildhelp/ 113 | DocProject/Help/*.HxT 114 | DocProject/Help/*.HxC 115 | DocProject/Help/*.hhc 116 | DocProject/Help/*.hhk 117 | DocProject/Help/*.hhp 118 | DocProject/Help/Html2 119 | DocProject/Help/html 120 | 121 | # Click-Once directory 122 | publish/ 123 | 124 | # Publish Web Output 125 | *.[Pp]ublish.xml 126 | *.azurePubxml 127 | 128 | # NuGet Packages Directory 129 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 130 | #packages/* 131 | ## TODO: If the tool you use requires repositories.config, also uncomment the next line 132 | #!packages/repositories.config 133 | 134 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 135 | # This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented) 136 | !packages/build/ 137 | 138 | # Windows Azure Build Output 139 | csx/ 140 | *.build.csdef 141 | 142 | # Windows Store app package directory 143 | AppPackages/ 144 | 145 | # Others 146 | sql/ 147 | *.Cache 148 | ClientBin/ 149 | [Ss]tyle[Cc]op.* 150 | ~$* 151 | *~ 152 | *.dbmdl 153 | *.dbproj.schemaview 154 | *.pfx 155 | *.publishsettings 156 | node_modules/ 157 | 158 | # RIA/Silverlight projects 159 | Generated_Code/ 160 | 161 | # Backup & report files from converting an old project file to a newer 162 | # Visual Studio version. Backup files are not needed, because we have git ;-) 163 | _UpgradeReport_Files/ 164 | Backup*/ 165 | UpgradeLog*.XML 166 | UpgradeLog*.htm 167 | 168 | # SQL Server files 169 | App_Data/*.mdf 170 | App_Data/*.ldf 171 | 172 | # Business Intelligence projects 173 | *.rdl.data 174 | *.bim.layout 175 | *.bim_*.settings 176 | 177 | # Microsoft Fakes 178 | FakesAssemblies/ 179 | 180 | # ========================= 181 | # Windows detritus 182 | # ========================= 183 | 184 | # Windows image file caches 185 | Thumbs.db 186 | ehthumbs.db 187 | 188 | # Folder config file 189 | Desktop.ini 190 | 191 | # Recycle Bin used on file shares 192 | $RECYCLE.BIN/ 193 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Adrian Zdanowicz (Silent) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VBdec 2 | VB codec for Miles Sound System used in GTA III and GTA Vice City. 3 | 4 | ## Credits 5 | Decoding based on Vice City Radio VB to WAV decoder: 6 | http://www.tinyted.net/eddie/decode.html 7 | -------------------------------------------------------------------------------- /dllmain.cpp: -------------------------------------------------------------------------------- 1 | #include "vagdec.h" 2 | #include "vbcalls.h" 3 | 4 | #define WIN32_LEAN_AND_MEAN 5 | #define NOMINMAX 6 | #include 7 | 8 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved) 9 | { 10 | //UNREFERENCED_PARAMETER(hModule); 11 | UNREFERENCED_PARAMETER(lpReserved); 12 | 13 | switch ( reason ) 14 | { 15 | case DLL_PROCESS_ATTACH: 16 | RegisterVAGInterface(); 17 | AttachVBCallbacks(); 18 | break; 19 | case DLL_PROCESS_DETACH: 20 | UnRegisterVAGInterface(); 21 | break; 22 | } 23 | return TRUE; 24 | } -------------------------------------------------------------------------------- /mss/mss.h: -------------------------------------------------------------------------------- 1 | //############################################################################ 2 | //## ## 3 | //## Miles Sound System ## 4 | //## ## 5 | //## MSS.H: Miles Sound System main header file ## 6 | //## ## 7 | //## Version 1.00 of 15-Feb-95: Initial, derived from AIL.H V3.02 ## 8 | //## 1.01 of 19-Jun-95: Added various functions for V3.03 release ## 9 | //## 1.02 of 22-Nov-95: C++ typedef problem fixed, declspecs added ## 10 | //## 1.03 of 15-Feb-96: Changes for 16 bit callbacks and multiple ## 11 | //## 16 bit DLL loads (JKR) ## 12 | //## 1.04 of 2-Nov-97: Changes made to handle DLS in future ## 13 | //## versions ## 14 | //## 1.05 of 1-Jan-98: Massive changes for version 4.0 ## 15 | //## 1.06 of 17-Sep-98: Massive changes for version 5.0 ## 16 | //## 1.07 of 2-Feb-99: Changes for new input API ## 17 | //## 1.08 of 8-Feb-99: Changes for new filter helper functions ## 18 | //## ## 19 | //## Author: John Miles ## 20 | //## ## 21 | //############################################################################ 22 | //## ## 23 | //## Contact RAD Game Tools at 425-893-4300 for technical support. ## 24 | //## ## 25 | //############################################################################ 26 | 27 | #ifndef MSS_VERSION 28 | 29 | #define MSS_VERSION "6.1a" 30 | #define MSS_MAJOR_VERSION 6 31 | #define MSS_MINOR_VERSION 1 32 | #define MSS_SUB_VERSION 1 33 | #define MSS_VERSION_DATE "06-Mar-01" 34 | 35 | #define MSS_COPYRIGHT "Copyright (C) 1991-2001, RAD Game Tools, Inc." 36 | 37 | #endif 38 | 39 | #ifndef MSS_H 40 | #define MSS_H 41 | 42 | // IS_DOS for DOS 43 | // IS_WINDOWS for Windows or Win32s 44 | // IS_WIN32 for Win32s 45 | // IS_WIN16 for Windows 46 | // IS_32 for 32-bit DOS or Win32s 47 | // IS_16 for 16-bit Windows 48 | // IS_LE for little endian (PCs) 49 | // IS_BE for big endian (Macs) 50 | // IS_X86 for Intel 51 | // IS_MAC for Mac 52 | // IS_PPC for PPC Mac 53 | // IS_68K for 68K Mac 54 | 55 | 56 | #ifdef IS_DOS 57 | #undef IS_DOS 58 | #endif 59 | 60 | #ifdef IS_WINDOWS 61 | #undef IS_WINDOWS 62 | #endif 63 | 64 | #ifdef IS_WIN32 65 | #undef IS_WIN32 66 | #endif 67 | 68 | #ifdef IS_WIN16 69 | #undef IS_WIN16 70 | #endif 71 | 72 | #ifdef IS_32 73 | #undef IS_32 74 | #endif 75 | 76 | #ifdef IS_16 77 | #undef IS_16 78 | #endif 79 | 80 | #ifdef IS_LE 81 | #undef IS_LE 82 | #endif 83 | 84 | #ifdef IS_BE 85 | #undef IS_BE 86 | #endif 87 | 88 | #ifdef IS_X86 89 | #undef IS_X86 90 | #endif 91 | 92 | #ifdef IS_MAC 93 | #undef IS_MAC 94 | #endif 95 | 96 | #ifdef IS_PPC 97 | #undef IS_PPC 98 | #endif 99 | 100 | #ifdef IS_68K 101 | #undef IS_68K 102 | #endif 103 | 104 | #ifdef __DOS__ 105 | #define IS_DOS 106 | #define IS_32 107 | #define IS_LE 108 | #define IS_X86 109 | #else 110 | #ifdef _WIN32 111 | #define IS_WINDOWS 112 | #define IS_WIN32 113 | #define IS_32 114 | #define IS_LE 115 | #define IS_X86 116 | #else 117 | #ifdef WIN32 118 | #define IS_WINDOWS 119 | #define IS_WIN32 120 | #define IS_32 121 | #define IS_LE 122 | #define IS_X86 123 | #else 124 | #ifdef __NT__ 125 | #define IS_WINDOWS 126 | #define IS_WIN32 127 | #define IS_32 128 | #define IS_LE 129 | #define IS_X86 130 | #else 131 | #ifdef __WIN32__ 132 | #define IS_WINDOWS 133 | #define IS_WIN32 134 | #define IS_32 135 | #define IS_LE 136 | #define IS_X86 137 | #else 138 | #ifdef _WINDOWS 139 | #define IS_WINDOWS 140 | #define IS_WIN16 141 | #define IS_16 142 | #define IS_LE 143 | #define IS_X86 144 | #else 145 | #ifdef _WINDLL 146 | #define IS_WINDOWS 147 | #define IS_WIN16 148 | #define IS_16 149 | #define IS_LE 150 | #define IS_X86 151 | #else 152 | #ifdef WINDOWS 153 | #define IS_WINDOWS 154 | #define IS_WIN16 155 | #define IS_16 156 | #define IS_LE 157 | #define IS_X86 158 | #else 159 | #ifdef __WINDOWS__ 160 | #define IS_WINDOWS 161 | #define IS_WIN16 162 | #define IS_16 163 | #define IS_LE 164 | #define IS_X86 165 | #else 166 | #ifdef _Windows 167 | #define IS_WINDOWS 168 | #define IS_WIN16 169 | #define IS_16 170 | #define IS_LE 171 | #define IS_X86 172 | #else 173 | #if defined(macintosh) || defined(__powerc) || defined(powerc) || defined(__POWERPC__) || defined(__MC68K__) 174 | #define IS_MAC 175 | #define IS_32 176 | #define IS_BE 177 | #if defined(__powerc) || defined(powerc) || defined(__POWERPC__) 178 | #define IS_PPC 179 | #else 180 | #if defined(__MC68K__) 181 | #define IS_68K 182 | #endif 183 | #endif 184 | #endif 185 | #endif 186 | #endif 187 | #endif 188 | #endif 189 | #endif 190 | #endif 191 | #endif 192 | #endif 193 | #endif 194 | #endif 195 | 196 | #if (!defined(IS_LE) && !defined(IS_BE)) 197 | #error MSS.H did not detect your platform. Define __DOS__, _WINDOWS, WIN32, or macintosh. 198 | #endif 199 | 200 | 201 | #if defined(_PUSHPOP_SUPPORTED) || PRAGMA_STRUCT_PACKPUSH 202 | #pragma pack(push,1) 203 | #else 204 | #pragma pack(1) 205 | #endif 206 | 207 | #ifdef __cplusplus 208 | extern "C" { 209 | #endif 210 | 211 | #ifdef IS_DOS 212 | 213 | #define AILCALLBACK __pascal 214 | #define AILEXPORT cdecl 215 | #define DXDEC extern 216 | #define DXDEF 217 | #define AILCALL cdecl 218 | #define FAR 219 | #define HIWORD(ptr) (((U32)ptr)>>16) 220 | #define LOWORD(ptr) ((U16)((U32)ptr)) 221 | 222 | #define FOURCC U32 223 | 224 | #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ 225 | ((U32)(U8)(ch0) | ((U32)(U8)(ch1) << 8) | \ 226 | ((U32)(U8)(ch2) << 16) | ((U32)(U8)(ch3) << 24 )) 227 | 228 | #define mmioFOURCC(w,x,y,z) MAKEFOURCC(w,x,y,z) 229 | 230 | #define AILLIBCALLBACK __pascal 231 | 232 | #define MSS_MAIN_DEF 233 | 234 | #define MSS_REDIST_DIR_NAME "DOS" 235 | 236 | #define MSS_DIR_SEP "\\" 237 | #define MSS_DIR_UP ".." MSS_DIR_SEP 238 | #define MSS_DIR_UP_TWO MSS_DIR_UP MSS_DIR_UP 239 | 240 | #else 241 | 242 | #ifdef IS_WINDOWS 243 | 244 | #define AILLIBCALLBACK WINAPI 245 | 246 | #ifndef WIN32_LEAN_AND_MEAN 247 | #define WIN32_LEAN_AND_MEAN 248 | #endif 249 | 250 | #ifndef WIN32_EXTRA_LEAN 251 | #define WIN32_EXTRA_LEAN 252 | #endif 253 | 254 | #ifndef STRICT 255 | #define STRICT 256 | #endif 257 | 258 | #include 259 | #include 260 | 261 | #define MSS_MAIN_DEF __cdecl 262 | 263 | // 264 | // If compiling MSS DLL, use __declspec(dllexport) for both 265 | // declarations and definitions 266 | // 267 | // If compiling MSS16 library or application, use "extern" in declarations 268 | // and nothing in definitions 269 | // 270 | 271 | #ifdef IS_WIN32 272 | 273 | #define AILEXPORT WINAPI 274 | 275 | #ifdef BUILD_MSS 276 | #define DXDEC __declspec(dllexport) 277 | #define DXDEF __declspec(dllexport) 278 | #else 279 | 280 | #if 1 /*def __BORLANDC__*/ 281 | #define DXDEC extern 282 | #define DXDEF 283 | #else 284 | #define DXDEC __declspec(dllimport) 285 | #endif 286 | 287 | #endif 288 | 289 | #define MSSDLLNAME "MSS32.DLL" 290 | #define MSS_REDIST_DIR_NAME "WIN32" 291 | 292 | #define MSS_DIR_SEP "\\" 293 | #define MSS_DIR_UP ".." MSS_DIR_SEP 294 | #define MSS_DIR_UP_TWO MSS_DIR_UP MSS_DIR_UP 295 | 296 | #else 297 | 298 | #define AILEXPORT __export WINAPI 299 | 300 | #define DXDEC extern 301 | #define DXDEF 302 | 303 | #define MSSDLLNAME "MSS16.DLL" 304 | #define MSS_REDIST_DIR_NAME "WIN16" 305 | 306 | #define MSS_DIR_SEP "\\" 307 | #define MSS_DIR_UP ".." MSS_DIR_SEP 308 | #define MSS_DIR_UP_TWO MSS_DIR_UP MSS_DIR_UP 309 | 310 | #endif 311 | 312 | #define AILCALL WINAPI 313 | #define AILCALLBACK AILEXPORT 314 | 315 | typedef LPVOID AILLPDIRECTSOUND; 316 | typedef LPVOID AILLPDIRECTSOUNDBUFFER; 317 | 318 | #else 319 | 320 | #ifdef IS_MAC 321 | 322 | #include 323 | #include 324 | #include 325 | #include // needed for GetResource, ReleaseResource 326 | 327 | #define FAR 328 | 329 | #define AILLIBCALLBACK //pascal 330 | #define AILCALL //pascal 331 | #define AILEXPORT //pascal 332 | #define AILCALLBACK //pascal 333 | 334 | #ifdef BUILD_MSS 335 | #define DXDEC __declspec(export) 336 | #define DXDEF 337 | #else 338 | #define DXDEC extern 339 | #define DXDEF 340 | #endif 341 | 342 | #define MSS_REDIST_DIR_NAME "MAC" 343 | 344 | #define MSS_DIR_SEP ":" 345 | #define MSS_DIR_UP ":" MSS_DIR_SEP 346 | #define MSS_DIR_UP_TWO MSS_DIR_UP MSS_DIR_SEP 347 | 348 | #define HIWORD(ptr) (((U32)ptr)>>16) 349 | #define LOWORD(ptr) ((U16)((U32)ptr)) 350 | 351 | #define FOURCC U32 352 | 353 | #ifndef MAKEFOURCC 354 | #define MAKEFOURCC(ch0, ch1, ch2, ch3) \ 355 | (((U32)(U8)(ch0) << 24) | ((U32)(U8)(ch1) << 16) | \ 356 | ((U32)(U8)(ch2) << 8) | ((U32)(U8)(ch3) )) 357 | #endif 358 | 359 | #define mmioFOURCC(w,x,y,z) MAKEFOURCC(w,x,y,z) 360 | 361 | #define MSS_MAIN_DEF 362 | 363 | #endif 364 | 365 | #endif 366 | 367 | #endif 368 | 369 | #ifndef NULL 370 | #define NULL 0 371 | #endif 372 | 373 | // 374 | // Misc. constant definitions 375 | // 376 | 377 | #define MAX_DRVRS 16 // Max. # of simultaneous drivers 378 | #define MAX_TIMERS 16 // Max. # of simultaneous timers 379 | #define MAX_NOTES 32 // Max # of notes "on" 380 | #define FOR_NEST 4 // # of nested XMIDI FOR loops 381 | #define NUM_CHANS 16 // # of possible MIDI channels 382 | #define MAX_W_VOICES 16 // Max virtual wave synth voice cnt 383 | #define MAX_W_ENTRIES 512 // 512 wave library entries max. 384 | #ifdef IS_MAC 385 | #define MAX_INSTR 150 // Max # of instruments 128 + 32 386 | #endif 387 | 388 | #define MIN_CHAN ( 1-1) // Min channel recognized (0-based) 389 | #define MAX_CHAN (16-1) // Max channel recognized 390 | #define MIN_LOCK_CHAN ( 2-1) // Min channel available for locking 391 | #define MAX_LOCK_CHAN ( 9-1) // Max channel available for locking 392 | #define PERCUSS_CHAN (10-1) // Percussion channel (no locking) 393 | 394 | #define AIL_MAX_FILE_HEADER_SIZE 4096 // AIL_set_named_sample_file() requires at least 4K 395 | // of data or the entire file image, whichever is less, 396 | // to determine sample format 397 | #define DIG_F_16BITS_MASK 1 398 | #define DIG_F_STEREO_MASK 2 399 | #define DIG_F_ADPCM_MASK 4 400 | 401 | #define DIG_F_MONO_8 0 // PCM data formats 402 | #define DIG_F_MONO_16 (DIG_F_16BITS_MASK) 403 | #define DIG_F_STEREO_8 (DIG_F_STEREO_MASK) 404 | #define DIG_F_STEREO_16 (DIG_F_STEREO_MASK|DIG_F_16BITS_MASK) 405 | #define DIG_F_ADPCM_MONO_16 (DIG_F_ADPCM_MASK |DIG_F_16BITS_MASK) 406 | #define DIG_F_ADPCM_STEREO_16 (DIG_F_ADPCM_MASK |DIG_F_16BITS_MASK|DIG_F_STEREO_MASK) 407 | #define DIG_F_USING_ASI 16 408 | 409 | #define DIG_PCM_SIGN 0x0001 // (obsolete) 410 | #define DIG_PCM_ORDER 0x0002 411 | 412 | #define DIG_PCM_POLARITY 0x0004 // PCM flags used by driver hardware 413 | #define DIG_PCM_SPLIT 0x0008 414 | #define DIG_BUFFER_SERVICE 0x0010 415 | #define DIG_DUAL_DMA 0x0020 416 | #define DIG_RECORDING_SUPPORTED 0x8000 417 | 418 | #define WAVE_FORMAT_PCM 1 419 | #define WAVE_FORMAT_IMA_ADPCM 0x0011 420 | 421 | #ifdef IS_DOS 422 | 423 | #define AIL3DIG 0 // .DIG driver 424 | #define AIL3MDI 1 // .MDI driver 425 | 426 | #define DIG_DETECT_8_BIT_ONLY 0x0001 // Detect 8-bit DMA only 427 | #define DIG_DETECT_16_BIT_ONLY 0x0002 // Detect 16-bit DMA only 428 | #define DIG_DETECT_8_AND_16_BITS 0x0003 // Detect both 8- and 16-bit DMA 429 | 430 | #define DRV_INIT 0x300 // Functions common to .MDI and .DIG 431 | #define DRV_GET_INFO 0x301 // drivers 432 | #define DRV_SERVE 0x302 433 | #define DRV_PARSE_ENV 0x303 434 | #define DRV_VERIFY_IO 0x304 435 | #define DRV_INIT_DEV 0x305 436 | #define DRV_SHUTDOWN_DEV 0x306 437 | 438 | #define DIG_HW_VOLUME 0x400 // .DIG driver functions 439 | #define DIG_START_P_CMD 0x401 440 | #define DIG_STOP_P_REQ 0x402 441 | #define DIG_START_R_CMD 0x403 442 | #define DIG_STOP_R_REQ 0x404 443 | #define DIG_VSE 0x405 444 | 445 | #define MDI_HW_VOLUME 0x500 // .MDI driver functions 446 | #define MDI_INIT_INS_MGR 0x501 447 | #define MDI_MIDI_XMIT 0x502 448 | #define MDI_INSTALL_T_SET 0x503 449 | #define MDI_GET_T_STATUS 0x504 450 | #define MDI_PROT_UNPROT_T 0x505 451 | #define MDI_VSE 0x506 452 | 453 | #else 454 | 455 | // 456 | // Pass to AIL_midiOutOpen for NULL MIDI driver 457 | // 458 | 459 | #define MIDI_NULL_DRIVER ((U32)(S32)-2) 460 | 461 | #endif 462 | 463 | 464 | // 465 | // Non-specific XMIDI/MIDI controllers and event types 466 | // 467 | 468 | #define SYSEX_BYTE 105 469 | #define PB_RANGE 106 470 | #define CHAN_MUTE 107 471 | #define CALLBACK_PFX 108 472 | #define SEQ_BRANCH 109 473 | #define CHAN_LOCK 110 474 | #define CHAN_PROTECT 111 475 | #define VOICE_PROTECT 112 476 | #define TIMBRE_PROTECT 113 477 | #define PATCH_BANK_SEL 114 478 | #define INDIRECT_C_PFX 115 479 | #define FOR_LOOP 116 480 | #define NEXT_LOOP 117 481 | #define CLEAR_BEAT_BAR 118 482 | #define CALLBACK_TRIG 119 483 | #define SEQ_INDEX 120 484 | 485 | #define GM_BANK_MSB 0 486 | #define MODULATION 1 487 | #define DATA_MSB 6 488 | #define PART_VOLUME 7 489 | #define PANPOT 10 490 | #define EXPRESSION 11 491 | #define GM_BANK_LSB 32 492 | #define DATA_LSB 38 493 | #define SUSTAIN 64 494 | #define REVERB 91 495 | #define CHORUS 93 496 | #define RPN_LSB 100 497 | #define RPN_MSB 101 498 | #define RESET_ALL_CTRLS 121 499 | #define ALL_NOTES_OFF 123 500 | 501 | #define EV_NOTE_OFF 0x80 502 | #define EV_NOTE_ON 0x90 503 | #define EV_POLY_PRESS 0xa0 504 | #define EV_CONTROL 0xb0 505 | #define EV_PROGRAM 0xc0 506 | #define EV_CHAN_PRESS 0xd0 507 | #define EV_PITCH 0xe0 508 | #define EV_SYSEX 0xf0 509 | #define EV_ESC 0xf7 510 | #define EV_META 0xff 511 | 512 | #define META_EOT 0x2f 513 | #define META_TEMPO 0x51 514 | #define META_TIME_SIG 0x58 515 | 516 | // 517 | // SAMPLE.system_data[] usage 518 | // 519 | 520 | #define SSD_EOD_CALLBACK 0 // Application end-of-data callback if not NULL 521 | #define VOC_BLK_PTR 1 // Pointer to current block 522 | #define VOC_REP_BLK 2 // Pointer to beginning of repeat loop block 523 | #define VOC_N_REPS 3 // # of iterations left in repeat loop 524 | #define VOC_MARKER 4 // Marker to search for, or -1 if all 525 | #define VOC_MARKER_FOUND 5 // Desired marker found if 1, else 0 526 | #define SSD_RELEASE 6 // Release sample handle upon termination if >0 527 | #ifdef IS_WINDOWS 528 | #define SSD_EOD_CB_WIN32S 7 // Application end-of-data callback is in Win32s 529 | #else 530 | #define SSD_TEMP 7 // Temporary storage location for general use 531 | #endif 532 | 533 | // 534 | // Timer status values 535 | // 536 | 537 | #define AILT_FREE 0 // Timer handle is free for allocation 538 | #define AILT_STOPPED 1 // Timer is stopped 539 | #define AILT_RUNNING 2 // Timer is running 540 | 541 | // 542 | // SAMPLE.status flag values 543 | // 544 | 545 | #define SMP_FREE 0x0001 // Sample is available for allocation 546 | 547 | #define SMP_DONE 0x0002 // Sample has finished playing, or has 548 | // never been started 549 | 550 | #define SMP_PLAYING 0x0004 // Sample is playing 551 | 552 | #define SMP_STOPPED 0x0008 // Sample has been stopped 553 | 554 | #define SMP_PLAYINGBUTRELEASED 0x0010 // Sample is playing, but digital handle 555 | // has been temporarily released 556 | 557 | 558 | 559 | // 560 | // SEQUENCE.status flag values 561 | // 562 | 563 | #define SEQ_FREE 0x0001 // Sequence is available for allocation 564 | 565 | #define SEQ_DONE 0x0002 // Sequence has finished playing, or has 566 | // never been started 567 | 568 | #define SEQ_PLAYING 0x0004 // Sequence is playing 569 | 570 | #define SEQ_STOPPED 0x0008 // Sequence has been stopped 571 | 572 | #define SEQ_PLAYINGBUTRELEASED 0x0010 // Sequence is playing, but MIDI handle 573 | // has been temporarily released 574 | 575 | #ifdef IS_DOS 576 | 577 | // 578 | // MIDI driver types 579 | // 580 | 581 | #define MDIDRVRTYPE_GM 0 // General MIDI driver (Roland-compatible) 582 | #define MDIDRVRTYPE_FM_2 1 // 2-operator FM MIDI driver (OPL2) 583 | #define MDIDRVRTYPE_FM_4 2 // 4-operator FM MIDI driver (OPL3) 584 | #define MDIDRVRTYPE_SPKR 3 // Tandy or PC speaker "beep" driver 585 | 586 | // 587 | // .INI installation result codes 588 | // 589 | 590 | #define AIL_INIT_SUCCESS 0 // Driver installed successfully 591 | #define AIL_NO_INI_FILE 1 // No MDI.INI or DIG.INI file exists 592 | #define AIL_INIT_FAILURE 2 // Driver could not be initialized 593 | 594 | #ifdef __BORLANDC__ 595 | 596 | #ifndef REALPTR 597 | #define REALPTR(x) ((void *) (U32) ((((U32) (x))>>16<<4) + ((x) & 0xffff) \ 598 | - AIL_sel_base(_DS))) 599 | #endif 600 | 601 | #else 602 | 603 | #ifndef REALPTR 604 | #define REALPTR(x) ((void *) (U32) ((((U32) (x))>>16<<4) + ((x) & 0xffff))) 605 | #endif 606 | 607 | #endif 608 | 609 | #else 610 | 611 | #ifdef IS_WINDOWS 612 | 613 | // 614 | // AIL_set_direct_buffer_control() command values 615 | // 616 | 617 | #define AILDS_RELINQUISH 0 // App returns control of secondary buffer 618 | #define AILDS_SEIZE 1 // App takes control of secondary buffer 619 | #define AILDS_SEIZE_LOOP 2 // App wishes to loop the secondary buffer 620 | 621 | #endif 622 | 623 | #endif 624 | 625 | // 626 | // General type definitions for portability 627 | // 628 | 629 | #ifndef C8 630 | #define C8 char 631 | #endif 632 | 633 | #ifndef U8 634 | #define U8 unsigned char 635 | #endif 636 | 637 | #ifndef S8 638 | #define S8 signed char 639 | #endif 640 | 641 | #ifndef U16 642 | #define U16 unsigned short 643 | #endif 644 | 645 | #ifndef S16 646 | #define S16 signed short 647 | #endif 648 | 649 | #ifndef U32 650 | #define U32 unsigned long 651 | #endif 652 | 653 | #ifndef S32 654 | #define S32 signed long 655 | #endif 656 | 657 | #ifndef F32 658 | #define F32 float 659 | #endif 660 | 661 | #ifndef F64 662 | #define F64 double 663 | #endif 664 | 665 | 666 | #ifndef REALFAR 667 | #define REALFAR unsigned long 668 | #endif 669 | 670 | #ifndef FILE_ERRS 671 | #define FILE_ERRS 672 | 673 | #define AIL_NO_ERROR 0 674 | #define AIL_IO_ERROR 1 675 | #define AIL_OUT_OF_MEMORY 2 676 | #define AIL_FILE_NOT_FOUND 3 677 | #define AIL_CANT_WRITE_FILE 4 678 | #define AIL_CANT_READ_FILE 5 679 | #define AIL_DISK_FULL 6 680 | 681 | #endif 682 | 683 | #define MIN_VAL 0 684 | #define NOM_VAL 1 685 | #define MAX_VAL 2 686 | 687 | #ifndef YES 688 | #define YES 1 689 | #endif 690 | 691 | #ifndef NO 692 | #define NO 0 693 | #endif 694 | 695 | #ifndef TRUE 696 | #define TRUE 1 697 | #endif 698 | 699 | #ifndef FALSE 700 | #define FALSE 0 701 | #endif 702 | 703 | // 704 | // Preference names and default values 705 | // 706 | 707 | #define DIG_RESAMPLING_TOLERANCE 0 708 | #define DEFAULT_DRT 131 // Resampling triggered at +/- 0.2% 709 | 710 | #define DIG_MIXER_CHANNELS 1 711 | #define DEFAULT_DMC 64 // 64 allocatable SAMPLE structures 712 | 713 | #define DIG_DEFAULT_VOLUME 2 714 | #define DEFAULT_DDV 127 // Default sample volume = 127 (0-127) 715 | 716 | #define MDI_SERVICE_RATE 3 717 | #define DEFAULT_MSR 120 // XMIDI sequencer timing = 120 Hz 718 | 719 | #define MDI_SEQUENCES 4 720 | #define DEFAULT_MS 8 // 8 sequence handles/driver 721 | 722 | #define MDI_DEFAULT_VOLUME 5 723 | #define DEFAULT_MDV 127 // Default sequence volume = 127 (0-127) 724 | 725 | #define MDI_QUANT_ADVANCE 6 726 | #define DEFAULT_MQA 1 // Beat/bar count +1 interval 727 | 728 | #define MDI_ALLOW_LOOP_BRANCHING 7 729 | #define DEFAULT_ALB NO // Branches cancel XMIDI FOR loops 730 | 731 | #define MDI_DEFAULT_BEND_RANGE 8 732 | #define DEFAULT_MDBR 2 // Default pitch-bend range = 2 733 | 734 | #ifdef IS_X86 735 | 736 | #define MDI_DOUBLE_NOTE_OFF 9 737 | #define DEFAULT_MDNO NO // For stuck notes on SB daughterboards 738 | 739 | #endif 740 | 741 | #define DIG_ENABLE_RESAMPLE_FILTER 31 // Enable resampling filter by 742 | #define DEFAULT_DERF YES // default 743 | 744 | #define DIG_DECODE_BUFFER_SIZE 32 // 2K decode buffer size by default 745 | #define DEFAULT_DDBS 2048 746 | 747 | #if defined(IS_WINDOWS) || defined(IS_MAC) 748 | 749 | #define MDI_SYSEX_BUFFER_SIZE 10 750 | #define DEFAULT_MSBS 1536 // Default sysex buffer = 1536 bytes 751 | 752 | #define DIG_OUTPUT_BUFFER_SIZE 11 753 | #define DEFAULT_DOBS 49152 // 48K output buffer size 754 | 755 | #define AIL_MM_PERIOD 12 756 | #define DEFAULT_AMP 5 // Default MM timer period = 5 msec. 757 | 758 | #endif 759 | 760 | #ifdef IS_WINDOWS 761 | 762 | #define DIG_DS_FRAGMENT_SIZE 34 763 | #define DEFAULT_DDFS 8 // Use 8 millisecond buffer fragments with DirectSound if MSS mixer in use 764 | 765 | #define DIG_DS_FRAGMENT_CNT 35 766 | #define DEFAULT_DDFC 96 // Use 96 buffer fragments with DirectSound if MSS mixer in use 767 | 768 | #define DIG_DS_MIX_FRAGMENT_CNT 42 769 | #define DEFAULT_DDMFC 8 // Mix ahead 8 buffer fragments 770 | 771 | #define DIG_DS_USE_PRIMARY 36 772 | #define DEFAULT_DDUP NO // Mix into secondary DirectSound buffer by default 773 | 774 | #define DIG_DS_DSBCAPS_CTRL3D 37 775 | #define DEFAULT_DDDC NO // Do not use DSBCAPS_CTRL3D by default 776 | 777 | #define DIG_DS_CREATION_HANDLER 38 778 | #define DEFAULT_DDCH NULL // Use DirectSoundCreate() by default 779 | 780 | #define AIL_TIMERS 13 781 | #define DEFAULT_AT 16 // 16 allocatable HTIMER handles 782 | 783 | #define DIG_MAX_CHAIN_ELEMENT_SIZE 14 784 | #define DEFAULT_MCES 8192 // max of 8192 bytes/waveOut buffer 785 | 786 | #define DIG_MIN_CHAIN_ELEMENT_TIME 45 787 | #define DEFAULT_MCET 100 // 100 milliseconds buffers 788 | 789 | #define DIG_USE_WAVEOUT 15 790 | #define DEFAULT_DUW NO // Use DirectSound by default 791 | 792 | #define DIG_DS_SECONDARY_SIZE 16 793 | #define DEFAULT_DDSS (32*1024L) // Must be 2^n -- use 32K by default 794 | 795 | #define DIG_DS_SAMPLE_CEILING 17 796 | #define DEFAULT_DDSC 44100 // Allow up to 44 kHz samples 797 | 798 | #define AIL_LOCK_PROTECTION 18 799 | #define DEFAULT_ALP NO // Don't suspend foreground thread by default 800 | 801 | #define AIL_WIN32S_CALLBACK_SIZE 19 802 | #define DEFAULT_WCS 4096 // Size of callback data in bytes 803 | 804 | #define AIL_MUTEX_PROTECTION 44 805 | #define DEFAULT_AMPR YES // Lock each call into Miles with a mutex 806 | 807 | #else 808 | 809 | #ifdef IS_DOS 810 | 811 | #define DIG_SERVICE_RATE 10 812 | #define DEFAULT_DSR 200 // DMA buffer-polling rate = 200 Hz 813 | 814 | #define DIG_HARDWARE_SAMPLE_RATE 11 815 | #define DEFAULT_DHSR NOM_VAL // Use nominal sample rate by default 816 | 817 | #define DIG_DMA_RESERVE 12 818 | #define DEFAULT_DDR 32768 // Reserve 32K real-mode mem for DMA 819 | 820 | #define DIG_LATENCY 13 821 | #define DEFAULT_DL 100 // Half-buffer size in ms = 100 822 | 823 | #define DIG_USE_STEREO 14 824 | #define DEFAULT_DUS NO // Use mono output only 825 | 826 | #define DIG_USE_16_BITS 15 827 | #define DEFAULT_DU16 NO // Use 8-bit output by default 828 | 829 | #define DIG_ALLOW_16_BIT_DMA 16 830 | #define DEFAULT_DA16DMA YES // OK to use 16-bit DMA if necessary 831 | 832 | #define DIG_SS_LOCK 17 833 | #define DEFAULT_DSL NO // Don't disable IRQs while mixing 834 | 835 | #define AIL_SCAN_FOR_HARDWARE 18 836 | #define DEFAULT_ASH YES // Scan for I/O settings if necessary 837 | 838 | #define AIL_ALLOW_VDM_EXECUTION 19 839 | #define DEFAULT_AVE YES // Allow Windows "DOS box" execution 840 | 841 | #endif 842 | 843 | #endif 844 | 845 | // ---------------------------------- 846 | // DLS Preference names and default values 847 | // Unless otherwise specified, values must be established 848 | // BEFORE calling DLSMSSOpen()! 849 | // ---------------------------------- 850 | 851 | #define DLS_TIMEBASE 20 852 | #define DEFAULT_DTB 120 // 120 intervals/second by default 853 | 854 | #define DLS_VOICE_LIMIT 21 855 | #define DEFAULT_DVL 24 // 24 voices supported 856 | 857 | #define DLS_BANK_SELECT_ALIAS 22 858 | #define DEFAULT_DBSA NO // Do not treat controller 114 as bank 859 | 860 | #define DLS_STREAM_BOOTSTRAP 23 // Don't submit first stream buffer 861 | #define DEFAULT_DSB YES // until at least 2 available 862 | 863 | #define DLS_VOLUME_BOOST 24 864 | #define DEFAULT_DVB 0 // Boost final volume by 0 dB 865 | 866 | #define DLS_ENABLE_FILTERING 25 // Filtering = on by default 867 | #define DEFAULT_DEF YES // (may be changed at any time) 868 | 869 | #ifdef IS_X86 870 | 871 | #define AIL_ENABLE_MMX_SUPPORT 27 // Enable MMX support if present 872 | #define DEFAULT_AEMS YES // (may be changed at any time) 873 | 874 | #endif 875 | 876 | #define DLS_GM_PASSTHROUGH 28 // Pass unrecognized traffic on to 877 | #define DEFAULT_DGP YES // default GM driver layer 878 | // (may be changed at any time) 879 | 880 | #define DLS_ADPCM_TO_ASI_THRESHOLD 39 // Size in samples to switch to ASI 881 | #define DEFAULT_DATAT 32768 882 | 883 | // 884 | // Add'l platform-independent prefs 885 | // 886 | 887 | #define DIG_REVERB_BUFFER_SIZE 40 888 | #define DEFAULT_DRBS 0 // No reverb support by default 889 | 890 | #define DIG_INPUT_LATENCY 41 // Use >= 250-millisecond input buffers if 891 | #define DEFAULT_DIL 250 // explicit size request cannot be satisfied 892 | 893 | #ifdef IS_WINDOWS 894 | 895 | #define DIG_USE_WAVEIN 43 896 | #define DEFAULT_DUWI YES // Use waveIn for input by default 897 | 898 | #endif 899 | 900 | #define N_PREFS 46 // # of preference types 901 | 902 | typedef struct _AILSOUNDINFO { 903 | S32 format; 904 | void const FAR* data_ptr; 905 | U32 data_len; 906 | U32 rate; 907 | S32 bits; 908 | S32 channels; 909 | U32 samples; 910 | U32 block_size; 911 | void const FAR* initial_ptr; 912 | } AILSOUNDINFO; 913 | 914 | 915 | // for multi-processor machines 916 | 917 | #ifdef IS_WIN32 918 | 919 | #ifdef BUILD_MSS 920 | 921 | #define MSSLockedIncrement(var) _asm { lock inc [var] } 922 | #define MSSLockedDecrement(var) _asm { lock dec [var] } 923 | 924 | static void __MSSLockedIncrementAddr(void * addr) 925 | { 926 | _asm 927 | { 928 | mov eax,[addr] 929 | lock inc dword ptr [eax] 930 | } 931 | } 932 | 933 | static void __MSSLockedDecrementAddr(void * addr) 934 | { 935 | _asm { 936 | mov eax,[addr] 937 | lock dec dword ptr [eax] 938 | } 939 | } 940 | 941 | #define MSSLockedIncrementPtr(var) __MSSLockedIncrementAddr(&(var)) 942 | #define MSSLockedDecrementPtr(var) __MSSLockedDecrementAddr(&(var)) 943 | 944 | #else 945 | 946 | #define MSSLockedIncrement(var) (++var) 947 | #define MSSLockedDecrement(var) (--var) 948 | 949 | #define MSSLockedIncrementPtr(var) (++var) 950 | #define MSSLockedDecrementPtr(var) (--var) 951 | 952 | #endif 953 | 954 | #else 955 | #define MSSLockedIncrement(var) (++var) 956 | #define MSSLockedDecrement(var) (--var) 957 | 958 | #define MSSLockedIncrementPtr(var) (++var) 959 | #define MSSLockedDecrementPtr(var) (--var) 960 | #endif 961 | 962 | #ifndef RIB_H // RIB.H contents included if RIB.H not already included 963 | 964 | // #include "rib.h" 965 | 966 | #define RIB_H 967 | #define ARY_CNT(x) (sizeof((x)) / sizeof((x)[0])) 968 | 969 | // ---------------------------------- 970 | // RIB data types 971 | // ---------------------------------- 972 | 973 | typedef S32 RIBRESULT; 974 | 975 | #define RIB_NOERR 0 // Success -- no error 976 | #define RIB_NOT_ALL_AVAILABLE 1 // Some requested functions/attribs not available 977 | #define RIB_NOT_FOUND 2 // Resource not found 978 | #define RIB_OUT_OF_MEM 3 // Out of system RAM 979 | 980 | // 981 | // Handle to interface provider 982 | // 983 | 984 | typedef U32 HPROVIDER; 985 | 986 | // 987 | // Handle representing token used to obtain attribute or preference 988 | // data from RIB provider 989 | // 990 | 991 | typedef U32 HATTRIB; 992 | 993 | // 994 | // Handle representing an enumerated interface entry 995 | // 996 | // RIB_enumerate_interface() returns 1 if valid next entry found, else 997 | // 0 if end of list reached 998 | // 999 | 1000 | typedef U32 HINTENUM; 1001 | #define HINTENUM_FIRST 0 1002 | 1003 | // 1004 | // Handle representing an enumerated provider entry 1005 | // 1006 | // RIB_enumerate_providers() returns 1 if valid next entry found, else 1007 | // 0 if end of list reached 1008 | // 1009 | 1010 | typedef U32 HPROENUM; 1011 | #define HPROENUM_FIRST 0 1012 | 1013 | // 1014 | // Data types for RIB attributes and preferences 1015 | // 1016 | 1017 | typedef enum 1018 | { 1019 | RIB_NONE = 0, // No type 1020 | RIB_CUSTOM, // Used for pointers to application-specific structures 1021 | RIB_DEC, // Used for 32-bit integer values to be reported in decimal 1022 | RIB_HEX, // Used for 32-bit integer values to be reported in hex 1023 | RIB_FLOAT, // Used for 32-bit single-precision FP values 1024 | RIB_PERCENT, // Used for 32-bit single-precision FP values to be reported as percentages 1025 | RIB_BOOL, // Used for Boolean-constrained integer values to be reported as TRUE or FALSE 1026 | RIB_STRING // Used for pointers to null-terminated ASCII strings 1027 | } 1028 | RIB_DATA_SUBTYPE; 1029 | 1030 | // 1031 | // RIB_ENTRY_TYPE structure, used to register an interface or request one 1032 | // 1033 | 1034 | typedef enum 1035 | { 1036 | RIB_FUNCTION = 0, 1037 | RIB_ATTRIBUTE, // Attribute: read-only data type used for status/info communication 1038 | RIB_PREFERENCE // Preference: read/write data type used to control behavior 1039 | } 1040 | RIB_ENTRY_TYPE; 1041 | 1042 | // 1043 | // RIB_INTERFACE_ENTRY, used to represent a function or data entry in an 1044 | // interface 1045 | // 1046 | 1047 | typedef struct 1048 | { 1049 | RIB_ENTRY_TYPE type; // See list above 1050 | C8 FAR *entry_name; // Name of desired function or attribute 1051 | U32 token; // Function pointer or attribute token 1052 | RIB_DATA_SUBTYPE subtype; // Data (attrib or preference) subtype 1053 | } 1054 | RIB_INTERFACE_ENTRY; 1055 | 1056 | // 1057 | // Standard RAD Interface Broker provider identification attributes 1058 | // 1059 | 1060 | #define PROVIDER_NAME (-100) // RIB_STRING name of decoder 1061 | #define PROVIDER_VERSION (-101) // RIB_HEX BCD version number 1062 | 1063 | // 1064 | // Standard function to obtain provider attributes (see PROVIDER_ defines 1065 | // above) 1066 | // 1067 | // Each provider of a searchable interface must export this function 1068 | // 1069 | 1070 | typedef U32 (AILCALL FAR *PROVIDER_QUERY_ATTRIBUTE) (HATTRIB index); 1071 | 1072 | // 1073 | // Macros to simplify interface registrations/requests for functions, 1074 | // attributes, and preferences 1075 | // 1076 | 1077 | #define FN(entry_name) { RIB_FUNCTION, #entry_name, (U32) &(entry_name), RIB_NONE } 1078 | #define REG_FN(entry_name) { RIB_FUNCTION, #entry_name, (U32) &(entry_name), RIB_NONE } 1079 | 1080 | #define AT(entry_name,ID) { RIB_ATTRIBUTE, (entry_name), (U32) &(ID), RIB_NONE } 1081 | #define REG_AT(entry_name,ID,subtype) { RIB_ATTRIBUTE, (entry_name), (U32) (ID), subtype } 1082 | 1083 | #define PR(entry_name,ID) { RIB_PREFERENCE, (entry_name), (U32) &(ID), RIB_NONE } 1084 | #define REG_PR(entry_name,ID,subtype) { RIB_PREFERENCE, (entry_name), (U32) (ID), subtype } 1085 | 1086 | #define RIB_register(x,y,z) RIB_register_interface (HPROVIDER(x), y, ARY_CNT(z), z) 1087 | #define RIB_unregister(x,y,z) RIB_unregister_interface(HPROVIDER(x), y, ARY_CNT(z), z) 1088 | #define RIB_unregister_all(x) RIB_unregister_interface(HPROVIDER(x), NULL, 0, NULL) 1089 | #define RIB_free_libraries() RIB_free_provider_library(HPROVIDER(NULL)); 1090 | #define RIB_request(x,y,z) RIB_request_interface (x, y, ARY_CNT(z), z) 1091 | 1092 | // ---------------------------------- 1093 | // Standard RIB API prototypes 1094 | // ---------------------------------- 1095 | 1096 | DXDEC HPROVIDER AILCALL RIB_alloc_provider_handle (U32 module); 1097 | DXDEC void AILCALL RIB_free_provider_handle (HPROVIDER provider); 1098 | 1099 | DXDEC HPROVIDER AILCALL RIB_load_provider_library (C8 const FAR *filename); 1100 | DXDEC void AILCALL RIB_free_provider_library (HPROVIDER provider); 1101 | 1102 | DXDEC HPROVIDER AILCALL RIB_provider_library_handle (void); 1103 | 1104 | DXDEC RIBRESULT AILCALL RIB_register_interface (HPROVIDER provider, 1105 | C8 const FAR *interface_name, 1106 | S32 entry_count, 1107 | RIB_INTERFACE_ENTRY const FAR *rlist); 1108 | 1109 | DXDEC RIBRESULT AILCALL RIB_unregister_interface (HPROVIDER provider, 1110 | C8 const FAR *interface_name, 1111 | S32 entry_count, 1112 | RIB_INTERFACE_ENTRY const FAR *rlist); 1113 | 1114 | DXDEC RIBRESULT AILCALL RIB_request_interface (HPROVIDER provider, 1115 | C8 const FAR *interface_name, 1116 | S32 entry_count, 1117 | RIB_INTERFACE_ENTRY FAR *rlist); 1118 | 1119 | DXDEC RIBRESULT AILCALL RIB_request_interface_entry (HPROVIDER provider, 1120 | C8 const FAR *interface_name, 1121 | RIB_ENTRY_TYPE entry_type, 1122 | C8 const FAR *entry_name, 1123 | U32 FAR *token); 1124 | 1125 | DXDEC S32 AILCALL RIB_enumerate_interface (HPROVIDER provider, 1126 | C8 FAR *interface_name, 1127 | RIB_ENTRY_TYPE type, 1128 | HINTENUM FAR *next, 1129 | RIB_INTERFACE_ENTRY FAR *dest); 1130 | 1131 | DXDEC S32 AILCALL RIB_enumerate_providers (C8 FAR *interface_name, 1132 | HPROENUM FAR *next, 1133 | HPROVIDER FAR *dest); 1134 | 1135 | DXDEC C8 FAR * AILCALL RIB_type_string (U32 data, 1136 | RIB_DATA_SUBTYPE subtype); 1137 | 1138 | DXDEC HPROVIDER AILCALL RIB_find_file_provider (C8 const FAR *interface_name, 1139 | C8 const FAR *attribute_name, 1140 | C8 const FAR *file_suffix); 1141 | 1142 | DXDEC HPROVIDER AILCALL RIB_find_provider (C8 const FAR *interface_name, 1143 | C8 const FAR *attribute_name, 1144 | C8 const FAR *attribute_value); 1145 | 1146 | DXDEC HPROVIDER AILCALL RIB_find_files_provider (C8 const FAR *interface_name, 1147 | C8 const FAR *attribute_name_1, 1148 | C8 const FAR *file_suffix_1, 1149 | C8 const FAR *attribute_name_2, 1150 | C8 const FAR *file_suffix_2); 1151 | 1152 | DXDEC HPROVIDER AILCALL RIB_find_file_dec_provider (C8 const FAR *interface_name, 1153 | C8 const FAR *attribute_name_1, 1154 | U32 attribute_value_1, 1155 | C8 const FAR *attribute_name_2, 1156 | C8 const FAR *file_suffix_2); 1157 | 1158 | DXDEC S32 AILCALL RIB_load_application_providers 1159 | (C8 const FAR *filespec); 1160 | 1161 | DXDEC void AILCALL RIB_set_provider_user_data (HPROVIDER provider, 1162 | U32 index, 1163 | S32 value); 1164 | 1165 | DXDEC S32 AILCALL RIB_provider_user_data (HPROVIDER provider, 1166 | U32 index); 1167 | 1168 | DXDEC void AILCALL RIB_set_provider_system_data 1169 | (HPROVIDER provider, 1170 | U32 index, 1171 | S32 value); 1172 | 1173 | DXDEC S32 AILCALL RIB_provider_system_data (HPROVIDER provider, 1174 | U32 index); 1175 | 1176 | DXDEC C8 FAR * AILCALL RIB_error (void); 1177 | 1178 | #endif 1179 | 1180 | #ifndef MSS_ASI_VERSION // MSSASI.H contents included if MSSASI.H not already included 1181 | 1182 | // #include "mssasi.h" 1183 | 1184 | #define AIL_ASI_VERSION 1 1185 | #define AIL_ASI_REVISION 0 1186 | 1187 | // 1188 | // Handle to stream being managed by ASI codec 1189 | // 1190 | 1191 | typedef S32 HASISTREAM; 1192 | 1193 | // 1194 | // ASI result codes 1195 | // 1196 | 1197 | typedef S32 ASIRESULT; 1198 | 1199 | #define ASI_NOERR 0 // Success -- no error 1200 | #define ASI_NOT_ENABLED 1 // ASI not enabled 1201 | #define ASI_ALREADY_STARTED 2 // ASI already started 1202 | #define ASI_INVALID_PARAM 3 // Invalid parameters used 1203 | #define ASI_INTERNAL_ERR 4 // Internal error in ASI driver 1204 | #define ASI_OUT_OF_MEM 5 // Out of system RAM 1205 | #define ASI_ERR_NOT_IMPLEMENTED 6 // Feature not implemented 1206 | #define ASI_NOT_FOUND 7 // ASI supported device not found 1207 | #define ASI_NOT_INIT 8 // ASI not initialized 1208 | #define ASI_CLOSE_ERR 9 // ASI not closed correctly 1209 | 1210 | // ---------------------------------- 1211 | // Application-provided ASI callbacks 1212 | // ---------------------------------- 1213 | 1214 | // 1215 | // AILASIFETCHCB: Called by ASI to obtain data from stream source 1216 | // 1217 | // offset normally will be either 0 at the first call made by the codec 1218 | // or -1 to specify a continuous stream, except when ASI_stream_seek() 1219 | // is called to restart the stream codec at a new stream offset. In this 1220 | // case, the application must execute the seek operation on the ASI codec's 1221 | // behalf. 1222 | // 1223 | // In response to this callback, the application should read the requested 1224 | // data and copy it to the specified destination buffer, returning the number 1225 | // of bytes copied (which can be less than bytes_requested if the end of 1226 | // the stream is reached). 1227 | // 1228 | 1229 | typedef S32 (AILCALLBACK FAR * AILASIFETCHCB) (U32 user, // User value passed to ASI_open_stream() 1230 | void FAR *dest, // Location to which stream data should be copied by app 1231 | S32 bytes_requested, // # of bytes requested by ASI codec 1232 | S32 offset); // If not -1, application should seek to this point in stream 1233 | 1234 | //############################################################################ 1235 | //## ## 1236 | //## Interface "ASI codec" ## 1237 | //## ## 1238 | //############################################################################ 1239 | 1240 | // 1241 | // Initialize ASI stream codec 1242 | // 1243 | // No other ASI functions may be called outside an ASI_startup() / 1244 | // ASI_shutdown() pair, except for the standard RIB function 1245 | // PROVIDER_query_attribute(). All provider attributes must be accessible 1246 | // without starting up the codec. 1247 | // 1248 | 1249 | typedef ASIRESULT (AILCALL FAR *ASI_STARTUP)(void); 1250 | 1251 | // 1252 | // Shut down ASI codec 1253 | // 1254 | 1255 | typedef ASIRESULT (AILCALL FAR * ASI_SHUTDOWN)(void); 1256 | 1257 | // 1258 | // Return codec error message, or NULL if no errors have occurred since 1259 | // last call 1260 | // 1261 | // The ASI error text state is global to all streams 1262 | // 1263 | 1264 | typedef C8 FAR * (AILCALL FAR * ASI_ERROR)(void); 1265 | 1266 | //############################################################################ 1267 | //## ## 1268 | //## Interface "ASI stream" ## 1269 | //## ## 1270 | //############################################################################ 1271 | 1272 | // 1273 | // Open a stream, returning handle to stream 1274 | // 1275 | 1276 | typedef HASISTREAM (AILCALL FAR *ASI_STREAM_OPEN) (U32 user, // User value passed to fetch callback 1277 | AILASIFETCHCB fetch_CB, // Source data fetch handler 1278 | U32 total_size); // Total size for %-done calculations (0=unknown) 1279 | 1280 | // 1281 | // Translate data in stream, returning # of bytes actually decoded or encoded 1282 | // 1283 | // Any number of bytes may be requested. Requesting more data than is 1284 | // available in the codec's internal buffer will cause the AILASIFETCHCB 1285 | // handler to be called to fetch more data from the stream. 1286 | // 1287 | 1288 | typedef S32 (AILCALL FAR *ASI_STREAM_PROCESS) (HASISTREAM stream, // Handle of stream 1289 | void FAR *buffer, // Destination for processed data 1290 | S32 buffer_size); // # of bytes to return in buffer 1291 | 1292 | // 1293 | // Restart stream decoding process at new offset 1294 | // 1295 | // Relevant for decoders only 1296 | // 1297 | // Seek destination is given as offset in bytes from beginning of stream 1298 | // 1299 | // At next ASI_stream_process() call, decoder will seek to the closest possible 1300 | // point in the stream which occurs at or after the specified position 1301 | // 1302 | // This function has no effect for decoders which do not support random 1303 | // seeks on a given stream type 1304 | // 1305 | // Warning: some decoders may need to implement seeking by reparsing 1306 | // the entire stream up to the specified offset, through multiple calls 1307 | // to the data-fetch callback. This operation may be extremely 1308 | // time-consuming on large files or slow network connections. 1309 | // 1310 | // A stream_offset value of -1 may be used to inform the decoder that the 1311 | // application has changed the input stream offset on its own, e.g. for a 1312 | // double-buffering application where the ASI decoder is not accessing the 1313 | // stream directly. ASI decoders should respond to this by flushing all 1314 | // internal buffers and resynchronizing themselves to the data stream. 1315 | // 1316 | 1317 | typedef ASIRESULT (AILCALL FAR *ASI_STREAM_SEEK) (HASISTREAM stream, 1318 | S32 stream_offset); 1319 | 1320 | // 1321 | // Retrieve an ASI stream attribute or preference value by index 1322 | // 1323 | 1324 | typedef S32 (AILCALL FAR *ASI_STREAM_ATTRIBUTE) (HASISTREAM stream, 1325 | HATTRIB attrib); 1326 | 1327 | // 1328 | // Set an ASI stream preference value by index 1329 | // 1330 | 1331 | typedef S32 (AILCALL FAR *ASI_STREAM_SET_PREFERENCE) (HASISTREAM stream, 1332 | HATTRIB preference, 1333 | void const FAR * value); 1334 | 1335 | // 1336 | // Close stream, freeing handle and all internally-allocated resources 1337 | // 1338 | 1339 | typedef ASIRESULT (AILCALL FAR *ASI_STREAM_CLOSE) (HASISTREAM stream); 1340 | 1341 | #endif 1342 | 1343 | //############################################################################ 1344 | //## ## 1345 | //## Interface "MSS 3D audio services" ## 1346 | //## ## 1347 | //############################################################################ 1348 | 1349 | // 1350 | // 3D positioning services 1351 | // 1352 | 1353 | 1354 | typedef struct h3DPOBJECT 1355 | { 1356 | U32 junk; 1357 | } h3DPOBJECT; 1358 | 1359 | typedef h3DPOBJECT FAR * H3DPOBJECT; 1360 | typedef H3DPOBJECT H3DSAMPLE; 1361 | 1362 | // 1363 | // M3D result codes 1364 | // 1365 | 1366 | typedef S32 M3DRESULT; 1367 | 1368 | #define M3D_NOERR 0 // Success -- no error 1369 | #define M3D_NOT_ENABLED 1 // M3D not enabled 1370 | #define M3D_ALREADY_STARTED 2 // M3D already started 1371 | #define M3D_INVALID_PARAM 3 // Invalid parameters used 1372 | #define M3D_INTERNAL_ERR 4 // Internal error in M3D driver 1373 | #define M3D_OUT_OF_MEM 5 // Out of system RAM 1374 | #define M3D_ERR_NOT_IMPLEMENTED 6 // Feature not implemented 1375 | #define M3D_NOT_FOUND 7 // M3D supported device not found 1376 | #define M3D_NOT_INIT 8 // M3D not initialized 1377 | #define M3D_CLOSE_ERR 9 // M3D not closed correctly 1378 | 1379 | 1380 | typedef void (AILCALLBACK FAR* AIL3DSAMPLECB) (H3DSAMPLE sample); 1381 | 1382 | typedef M3DRESULT (AILCALL FAR *M3D_STARTUP)(void); 1383 | 1384 | typedef M3DRESULT (AILCALL FAR *M3D_SHUTDOWN)(void); 1385 | 1386 | typedef C8 FAR * (AILCALL FAR *M3D_ERROR)(void); 1387 | 1388 | typedef S32 (AILCALL FAR *M3D_SET_PROVIDER_PREFERENCE)(HATTRIB preference, 1389 | void const FAR * value); 1390 | 1391 | typedef M3DRESULT (AILCALL FAR * M3D_ACTIVATE)(S32 enable); 1392 | 1393 | typedef H3DSAMPLE (AILCALL FAR * M3D_ALLOCATE_3D_SAMPLE_HANDLE)(void); 1394 | 1395 | 1396 | typedef void (AILCALL FAR * M3D_RELEASE_3D_SAMPLE_HANDLE)(H3DSAMPLE samp); 1397 | 1398 | 1399 | typedef void (AILCALL FAR * M3D_START_3D_SAMPLE)(H3DSAMPLE samp); 1400 | 1401 | 1402 | typedef void (AILCALL FAR * M3D_STOP_3D_SAMPLE)(H3DSAMPLE samp); 1403 | 1404 | 1405 | typedef void (AILCALL FAR * M3D_RESUME_3D_SAMPLE)(H3DSAMPLE samp); 1406 | 1407 | typedef void (AILCALL FAR * M3D_END_3D_SAMPLE)(H3DSAMPLE samp); 1408 | 1409 | typedef S32 (AILCALL FAR * M3D_SET_3D_SAMPLE_DATA)(H3DSAMPLE samp, 1410 | AILSOUNDINFO const FAR *info); 1411 | 1412 | typedef void (AILCALL FAR * M3D_SET_3D_SAMPLE_VOLUME)(H3DSAMPLE samp, 1413 | S32 volume); 1414 | 1415 | typedef void (AILCALL FAR * M3D_SET_3D_SAMPLE_PLAYBACK_RATE)(H3DSAMPLE samp, 1416 | S32 playback_rate); 1417 | 1418 | typedef void (AILCALL FAR * M3D_SET_3D_SAMPLE_OFFSET)(H3DSAMPLE samp, 1419 | U32 offset); 1420 | 1421 | 1422 | typedef void (AILCALL FAR * M3D_SET_3D_SAMPLE_LOOP_COUNT)(H3DSAMPLE samp, 1423 | U32 loops); 1424 | 1425 | typedef void (AILCALL FAR * M3D_SET_3D_SAMPLE_LOOP_BLOCK)(H3DSAMPLE S, 1426 | S32 loop_start_offset, 1427 | S32 loop_end_offset); 1428 | 1429 | typedef U32 (AILCALL FAR * M3D_3D_SAMPLE_STATUS)(H3DSAMPLE samp); 1430 | 1431 | typedef U32 (AILCALL FAR * M3D_3D_SAMPLE_ATTRIBUTE)(H3DSAMPLE samp, HATTRIB index); 1432 | 1433 | typedef S32 (AILCALL FAR * M3D_3D_SET_SAMPLE_PREFERENCE)(H3DSAMPLE samp, HATTRIB preference, void const FAR * value); 1434 | 1435 | typedef S32 (AILCALL FAR * M3D_3D_SAMPLE_VOLUME)(H3DSAMPLE samp); 1436 | 1437 | typedef S32 (AILCALL FAR * M3D_3D_SAMPLE_PLAYBACK_RATE)(H3DSAMPLE samp); 1438 | 1439 | typedef U32 (AILCALL FAR * M3D_3D_SAMPLE_OFFSET)(H3DSAMPLE samp); 1440 | 1441 | typedef U32 (AILCALL FAR * M3D_3D_SAMPLE_LENGTH)(H3DSAMPLE samp); 1442 | 1443 | typedef U32 (AILCALL FAR * M3D_3D_SAMPLE_LOOP_COUNT)(H3DSAMPLE samp); 1444 | 1445 | typedef void (AILCALL FAR * M3D_SET_3D_SAMPLE_DISTANCES)(H3DSAMPLE samp, 1446 | F32 max_dist, 1447 | F32 min_dist); 1448 | 1449 | 1450 | typedef void (AILCALL FAR * M3D_3D_SAMPLE_DISTANCES)(H3DSAMPLE samp, 1451 | F32 FAR * max_dist, 1452 | F32 FAR * min_dist); 1453 | 1454 | typedef S32 (AILCALL FAR * M3D_ACTIVE_3D_SAMPLE_COUNT)(void); 1455 | 1456 | typedef H3DPOBJECT (AILCALL FAR * M3D_3D_OPEN_LISTENER)(void); 1457 | 1458 | typedef void (AILCALL FAR * M3D_3D_CLOSE_LISTENER)(H3DPOBJECT listener); 1459 | 1460 | typedef H3DPOBJECT (AILCALL FAR * M3D_3D_OPEN_OBJECT)(void); 1461 | 1462 | typedef void (AILCALL FAR * M3D_3D_CLOSE_OBJECT)(H3DPOBJECT obj); 1463 | 1464 | typedef void (AILCALL FAR * M3D_SET_3D_POSITION)(H3DPOBJECT obj, 1465 | F32 X, 1466 | F32 Y, 1467 | F32 Z); 1468 | 1469 | typedef void (AILCALL FAR * M3D_SET_3D_VELOCITY)(H3DPOBJECT obj, 1470 | F32 dX_per_ms, 1471 | F32 dY_per_ms, 1472 | F32 dZ_per_ms, 1473 | F32 magnitude); 1474 | 1475 | typedef void (AILCALL FAR * M3D_SET_3D_VELOCITY_VECTOR)(H3DPOBJECT obj, 1476 | F32 dX_per_ms, 1477 | F32 dY_per_ms, 1478 | F32 dZ_per_ms); 1479 | 1480 | typedef void (AILCALL FAR * M3D_SET_3D_ORIENTATION)(H3DPOBJECT obj, 1481 | F32 X_face, 1482 | F32 Y_face, 1483 | F32 Z_face, 1484 | F32 X_up, 1485 | F32 Y_up, 1486 | F32 Z_up); 1487 | 1488 | typedef void (AILCALL FAR * M3D_3D_POSITION)(H3DPOBJECT obj, 1489 | F32 FAR *X, 1490 | F32 FAR *Y, 1491 | F32 FAR *Z); 1492 | 1493 | typedef void (AILCALL FAR * M3D_3D_VELOCITY)(H3DPOBJECT obj, 1494 | F32 FAR *dX_per_ms, 1495 | F32 FAR *dY_per_ms, 1496 | F32 FAR *dZ_per_ms); 1497 | 1498 | typedef void (AILCALL FAR * M3D_3D_ORIENTATION)(H3DPOBJECT obj, 1499 | F32 FAR *X_face, 1500 | F32 FAR *Y_face, 1501 | F32 FAR *Z_face, 1502 | F32 FAR *X_up, 1503 | F32 FAR *Y_up, 1504 | F32 FAR *Z_up); 1505 | 1506 | typedef void (AILCALL FAR * M3D_3D_UPDATE_POSITION)(H3DPOBJECT obj, 1507 | F32 dt_milliseconds); 1508 | 1509 | typedef void (AILCALL FAR * M3D_3D_AUTO_UPDATE_POSITION)(H3DPOBJECT obj, 1510 | S32 enable); 1511 | 1512 | typedef S32 (AILCALL FAR * M3D_3D_ROOM_TYPE)(void); 1513 | typedef void (AILCALL FAR * M3D_SET_3D_ROOM_TYPE)(S32 EAX_room_type); 1514 | typedef S32 (AILCALL FAR * M3D_3D_SPEAKER_TYPE)(void); 1515 | typedef void (AILCALL FAR * M3D_SET_3D_SPEAKER_TYPE)(S32 speaker_type); 1516 | typedef void (AILCALL FAR * M3D_SET_3D_SAMPLE_OBSTRUCTION)(H3DSAMPLE samp, F32 obstruction); 1517 | typedef void (AILCALL FAR * M3D_SET_3D_SAMPLE_OCCLUSION)(H3DSAMPLE samp, F32 occlusion); 1518 | typedef void (AILCALL FAR * M3D_SET_3D_SAMPLE_EFFECTS_LEVEL)(H3DSAMPLE samp, F32 effects_level); 1519 | typedef F32 (AILCALL FAR * M3D_3D_SAMPLE_OBSTRUCTION)(H3DSAMPLE samp); 1520 | typedef F32 (AILCALL FAR * M3D_3D_SAMPLE_OCCLUSION)(H3DSAMPLE samp); 1521 | typedef F32 (AILCALL FAR * M3D_3D_SAMPLE_EFFECTS_LEVEL)(H3DSAMPLE samp); 1522 | 1523 | typedef AIL3DSAMPLECB (AILCALL FAR * M3D_SET_3D_EOS)(H3DSAMPLE client,H3DSAMPLE samp,AIL3DSAMPLECB cb); 1524 | 1525 | typedef void (AILCALL FAR * M3D_SET_3D_SAMPLE_CONE)(H3DSAMPLE samp, F32 inner_angle, F32 outer_angle, S32 outer_volume); 1526 | typedef void (AILCALL FAR * M3D_3D_SAMPLE_CONE)(H3DSAMPLE samp, F32 FAR* inner_angle, F32 FAR* outer_angle, S32 FAR* outer_volume); 1527 | 1528 | //############################################################################ 1529 | //## ## 1530 | //## Interface "MSS mixer services" ## 1531 | //## ## 1532 | //############################################################################ 1533 | 1534 | // 1535 | // Operation flags used by mixer module 1536 | // 1537 | 1538 | #define M_DEST_STEREO 1 // Set to enable stereo mixer output 1539 | #define M_SRC_16 2 // Set to enable mixing of 16-bit samples 1540 | #define M_FILTER 4 // Set to enable filtering when resampling 1541 | #define M_SRC_STEREO 8 // Set to enable mixing of stereo input samples 1542 | #define M_VOL_SCALING 16 // Set to enable volume scalars other than 2047 1543 | #define M_RESAMPLE 32 // Set to enable playback ratios other than 65536 1544 | #define M_ORDER 64 // Set to reverse L/R stereo order for sample 1545 | 1546 | #ifdef IS_32 1547 | 1548 | // 1549 | // Initialize mixer 1550 | // 1551 | // No other mixer functions may be called outside a MIXER_startup() / 1552 | // MIXER_shutdown() pair, except for the standard RIB function 1553 | // PROVIDER_query_attribute(). All provider attributes must be accessible 1554 | // without starting up the module. 1555 | // 1556 | 1557 | typedef void (AILCALL FAR *MIXER_STARTUP)(void); 1558 | 1559 | // 1560 | // Shut down mixer 1561 | // 1562 | 1563 | typedef void (AILCALL FAR *MIXER_SHUTDOWN)(void); 1564 | 1565 | // 1566 | // Flush mixer buffer 1567 | // 1568 | 1569 | typedef void (AILCALL FAR *MIXER_FLUSH) (S32 FAR *dest, 1570 | S32 len, 1571 | S32 FAR *reverb_buffer, 1572 | S32 reverb_level 1573 | #ifdef IS_X86 1574 | ,U32 MMX_available 1575 | #endif 1576 | ); 1577 | 1578 | // 1579 | // Perform audio mixing operation 1580 | // 1581 | 1582 | typedef void (AILCALL FAR *MIXER_MERGE) (void const FAR * FAR *src, 1583 | U32 FAR *src_fract, 1584 | void const FAR *src_end, 1585 | S32 FAR * FAR *dest, 1586 | void FAR *dest_end, 1587 | S32 FAR *left_val, 1588 | S32 FAR *right_val, 1589 | S32 playback_ratio, 1590 | S32 scale_left, 1591 | S32 scale_right, 1592 | U32 operation 1593 | #ifdef IS_X86 1594 | ,U32 MMX_available 1595 | #endif 1596 | ); 1597 | 1598 | // 1599 | // Translate mixer buffer contents to final output format 1600 | // 1601 | 1602 | #ifdef IS_MAC 1603 | 1604 | typedef void (AILCALL FAR *MIXER_COPY) (void const FAR *src, 1605 | S32 src_len, 1606 | void FAR *dest, 1607 | U32 operation, 1608 | U32 big_endian_output); 1609 | #else 1610 | 1611 | typedef void (AILCALL FAR *MIXER_COPY) (void const FAR *src, 1612 | S32 src_len, 1613 | void FAR *dest, 1614 | U32 operation, 1615 | U32 MMX_available); 1616 | #endif 1617 | #else 1618 | 1619 | // 1620 | // Initialize mixer 1621 | // 1622 | // No other mixer functions may be called outside a MIXER_startup() / 1623 | // MIXER_shutdown() pair, except for the standard RIB function 1624 | // PROVIDER_query_attribute(). All provider attributes must be accessible 1625 | // without starting up the module. 1626 | // 1627 | 1628 | typedef void (AILCALL FAR *MIXER_STARTUP)(void); 1629 | 1630 | // 1631 | // Shut down mixer 1632 | // 1633 | 1634 | typedef void (AILCALL FAR *MIXER_SHUTDOWN)(void); 1635 | 1636 | // 1637 | // Flush mixer buffer 1638 | // 1639 | 1640 | typedef void (AILCALL FAR *MIXER_FLUSH) (S32 FAR *dest, 1641 | S32 len, 1642 | S32 FAR *reverb_buffer, 1643 | S32 reverb_level, 1644 | U32 MMX_available); 1645 | 1646 | // 1647 | // Perform audio mixing operation 1648 | // 1649 | 1650 | typedef void (AILCALL FAR *MIXER_MERGE) (U32 src_sel, 1651 | U32 dest_sel, 1652 | U32 FAR *src_fract, 1653 | U32 FAR *src_offset, 1654 | U32 FAR *dest_offset, 1655 | U32 src_end_offset, 1656 | U32 dest_end_offset, 1657 | S32 FAR *left_val, 1658 | S32 FAR *right_val, 1659 | S32 playback_ratio, 1660 | S32 scale_both, 1661 | U32 operation); 1662 | 1663 | // 1664 | // Translate mixer buffer contents to final output format 1665 | // 1666 | 1667 | typedef void (AILCALL FAR *MIXER_COPY) (void const FAR *src, 1668 | S32 src_len, 1669 | void FAR *dest, 1670 | U32 operation, 1671 | U32 MMX_available); 1672 | #endif 1673 | 1674 | // 1675 | // Type definitions 1676 | // 1677 | 1678 | struct _DIG_DRIVER; 1679 | 1680 | struct _MDI_DRIVER; 1681 | 1682 | typedef struct _DIG_DRIVER FAR * HDIGDRIVER; // Handle to digital driver 1683 | 1684 | typedef struct _MDI_DRIVER FAR * HMDIDRIVER; // Handle to XMIDI driver 1685 | 1686 | typedef struct _SAMPLE FAR * HSAMPLE; // Handle to sample 1687 | 1688 | typedef struct _SEQUENCE FAR * HSEQUENCE; // Handle to sequence 1689 | 1690 | typedef S32 HTIMER; // Handle to timer 1691 | 1692 | 1693 | #ifdef IS_DOS 1694 | 1695 | // 1696 | // Type definitions 1697 | // 1698 | 1699 | typedef struct // I/O parameters structure 1700 | { 1701 | S16 IO; 1702 | S16 IRQ; 1703 | S16 DMA_8_bit; 1704 | S16 DMA_16_bit; 1705 | S32 IO_reserved[4]; 1706 | } 1707 | IO_PARMS; 1708 | 1709 | typedef struct // Standard MSS 3.X VDI driver header 1710 | { 1711 | S8 ID[8]; // "AIL3xxx" ID string, followed by ^Z 1712 | 1713 | U32 driver_version; 1714 | 1715 | REALFAR common_IO_configurations; 1716 | U16 num_IO_configurations; 1717 | 1718 | REALFAR environment_string; 1719 | 1720 | IO_PARMS IO; 1721 | 1722 | S16 service_rate; 1723 | 1724 | U16 busy; 1725 | 1726 | U16 driver_num; // Driver number 1727 | 1728 | U16 this_ISR; // Offset of INT 66H dispatcher 1729 | REALFAR prev_ISR; // Pointer to previous INT 66H ISR 1730 | 1731 | S8 scratch[128]; // Shared scratch workspace 1732 | 1733 | S8 dev_name[80]; // Device name (VDI version >= 1.12 only) 1734 | } 1735 | VDI_HDR; 1736 | 1737 | typedef struct 1738 | { 1739 | U16 minimum_physical_sample_rate; 1740 | U16 nominal_physical_sample_rate; 1741 | U16 maximum_physical_sample_rate; 1742 | 1743 | U16 minimum_DMA_half_buffer_size; 1744 | U16 maximum_DMA_half_buffer_size; 1745 | 1746 | U32 flags; 1747 | } 1748 | DIG_MODE; 1749 | 1750 | typedef struct 1751 | { 1752 | U8 format_supported[16]; 1753 | DIG_MODE format_data[16]; 1754 | } 1755 | DIG_DDT; 1756 | 1757 | typedef struct 1758 | { 1759 | REALFAR DMA_buffer_A; 1760 | REALFAR DMA_buffer_B; 1761 | S16 active_buffer; 1762 | } 1763 | DIG_DST; 1764 | 1765 | typedef struct 1766 | { 1767 | REALFAR library_environment; 1768 | REALFAR GTL_suffix; 1769 | 1770 | U16 num_voices; 1771 | 1772 | U16 max_melodic_channel; 1773 | U16 min_melodic_channel; 1774 | U16 percussion_channel; 1775 | } 1776 | MDI_DDT; 1777 | 1778 | typedef struct 1779 | { 1780 | S8 library_directory[128]; 1781 | S8 GTL_filename[128]; 1782 | 1783 | S8 MIDI_data[512]; 1784 | } 1785 | MDI_DST; 1786 | 1787 | typedef struct // Initialization file structure 1788 | { 1789 | char device_name[128]; // Device name 1790 | char driver_name[128]; // Driver filename 1791 | IO_PARMS IO; // I/O parameters for driver 1792 | } 1793 | AIL_INI; 1794 | 1795 | typedef struct // Handle to driver 1796 | { 1797 | REALFAR seg; // Seg:off pointer to driver (off=0) 1798 | U32 sel; // Selector for driver (off=0) 1799 | void *buf; // Protected-mode pointer to driver 1800 | U32 size; // Size of driver image 1801 | VDI_HDR *VHDR; // Pointer to driver header (same as buf) 1802 | S32 type; // AIL3DIG or AIL3MDI (see below) 1803 | 1804 | S32 initialized; // 1 if hardware successfully init'd, else 0 1805 | 1806 | S32 PM_ISR; // -1 if no PM ISR hooked, else IRQ # 1807 | 1808 | HTIMER server; // DRV_SERVE periodic timer, if requested 1809 | 1810 | // Vector to high-level destructor, if any 1811 | 1812 | void (AILCALL *destructor)(HDIGDRIVER); 1813 | 1814 | // High-level descriptor (DIG_ or MDI_DRIVER) 1815 | void *descriptor; 1816 | } 1817 | AIL_DRIVER; 1818 | 1819 | typedef struct // VDI interface register structure 1820 | { 1821 | S16 AX; 1822 | S16 BX; 1823 | S16 CX; 1824 | S16 DX; 1825 | S16 SI; 1826 | S16 DI; 1827 | } 1828 | VDI_CALL; 1829 | 1830 | #endif 1831 | 1832 | // 1833 | // Function pointer types 1834 | // 1835 | 1836 | typedef void (AILCALLBACK FAR* AILINCB) (void const FAR *data, S32 len, U32 user_data); 1837 | 1838 | typedef void (AILCALLBACK FAR* AILTIMERCB) (U32 user); 1839 | 1840 | typedef void (AILCALLBACK FAR* AILSAMPLECB) (HSAMPLE sample); 1841 | 1842 | typedef S32 (AILCALLBACK FAR* AILEVENTCB) (HMDIDRIVER hmi,HSEQUENCE seq,S32 status,S32 data_1,S32 data_2); 1843 | 1844 | typedef S32 (AILCALLBACK FAR* AILTIMBRECB) (HMDIDRIVER hmi,S32 bank,S32 patch); 1845 | 1846 | typedef S32 (AILCALLBACK FAR* AILPREFIXCB) (HSEQUENCE seq,S32 log,S32 data); 1847 | 1848 | typedef void (AILCALLBACK FAR* AILTRIGGERCB) (HSEQUENCE seq,S32 log,S32 data); 1849 | 1850 | typedef void (AILCALLBACK FAR* AILBEATCB) (HMDIDRIVER hmi,HSEQUENCE seq,S32 beat,S32 measure); 1851 | 1852 | typedef void (AILCALLBACK FAR* AILSEQUENCECB) (HSEQUENCE seq); 1853 | 1854 | // 1855 | // Handle to sample and driver being managed by pipeline filter 1856 | // 1857 | 1858 | typedef S32 HSAMPLESTATE; 1859 | typedef S32 HDRIVERSTATE; 1860 | 1861 | // 1862 | // Digital pipeline stages 1863 | // 1864 | // These are the points at which external modules may be installed into 1865 | // a given HSAMPLE or HDIGDRIVER's processing pipeline 1866 | // 1867 | 1868 | typedef enum 1869 | { 1870 | DP_ASI_DECODER=0, // Must be "ASI codec stream" provider 1871 | DP_FILTER, // Must be "MSS pipeline filter" provider 1872 | DP_MERGE, // Must be "MSS mixer" provider 1873 | N_SAMPLE_STAGES, // Placeholder for end of list (= # of valid stages) 1874 | SAMPLE_ALL_STAGES // Used to signify all pipeline stages, for shutdown 1875 | } 1876 | SAMPLESTAGE; 1877 | 1878 | typedef enum 1879 | { 1880 | DP_FLUSH = 0, // Must be "MSS mixer" provider 1881 | DP_DEFAULT_FILTER, // Must be "MSS pipeline filter" provider (sets the default) 1882 | DP_DEFAULT_MERGE, // Must be "MSS mixer" provider (sets the default) 1883 | DP_COPY, // Must be "MSS mixer" provider 1884 | N_DIGDRV_STAGES, // Placeholder for end of list (= # of valid stages) 1885 | DIGDRV_ALL_STAGES // Used to signify all pipeline stages, for shutdown 1886 | } 1887 | DIGDRVSTAGE; 1888 | 1889 | typedef struct 1890 | { 1891 | ASI_STREAM_OPEN ASI_stream_open; 1892 | ASI_STREAM_PROCESS ASI_stream_process; 1893 | ASI_STREAM_SEEK ASI_stream_seek; 1894 | ASI_STREAM_CLOSE ASI_stream_close; 1895 | ASI_STREAM_ATTRIBUTE ASI_stream_attribute; 1896 | ASI_STREAM_SET_PREFERENCE ASI_stream_set_preference; 1897 | 1898 | HATTRIB INPUT_BIT_RATE; 1899 | HATTRIB INPUT_SAMPLE_RATE; 1900 | HATTRIB INPUT_BITS; 1901 | HATTRIB INPUT_CHANNELS; 1902 | HATTRIB OUTPUT_BIT_RATE; 1903 | HATTRIB OUTPUT_SAMPLE_RATE; 1904 | HATTRIB OUTPUT_BITS; 1905 | HATTRIB OUTPUT_CHANNELS; 1906 | HATTRIB POSITION; 1907 | HATTRIB PERCENT_DONE; 1908 | HATTRIB MIN_INPUT_BLOCK_SIZE; 1909 | HATTRIB RAW_RATE; 1910 | HATTRIB RAW_BITS; 1911 | HATTRIB RAW_CHANNELS; 1912 | HATTRIB REQUESTED_RATE; 1913 | HATTRIB REQUESTED_BITS; 1914 | HATTRIB REQUESTED_CHANS; 1915 | 1916 | HASISTREAM stream; 1917 | } 1918 | ASISTAGE; 1919 | 1920 | typedef struct 1921 | { 1922 | MIXER_FLUSH MSS_mixer_flush; 1923 | MIXER_MERGE MSS_mixer_merge; 1924 | MIXER_COPY MSS_mixer_copy; 1925 | } 1926 | MIXSTAGE; 1927 | 1928 | typedef struct 1929 | { 1930 | struct _FLTPROVIDER FAR *provider; 1931 | HSAMPLESTATE sample_state; 1932 | } 1933 | FLTSTAGE; 1934 | 1935 | typedef struct 1936 | { 1937 | S32 active; // Pass-through if 0, active if 1 1938 | HPROVIDER provider; 1939 | 1940 | union 1941 | { 1942 | ASISTAGE ASI; 1943 | MIXSTAGE MIX; 1944 | FLTSTAGE FLT; 1945 | } 1946 | TYPE; 1947 | } 1948 | DPINFO; 1949 | 1950 | // 1951 | // Other data types 1952 | // 1953 | 1954 | typedef struct _AIL_INPUT_INFO // Input descriptor type 1955 | { 1956 | U32 device_ID; // DS LPGUID or wave device ID 1957 | U32 hardware_format; // e.g., DIG_F_STEREO_16 1958 | U32 hardware_rate; // e.g., 22050 1959 | AILINCB callback; // Callback function to receive incoming data 1960 | S32 buffer_size; // Maximum # of bytes to be passed to callback (-1 to use DIG_INPUT_LATENCY) 1961 | U32 user_data; // this is a user defined value 1962 | } 1963 | AIL_INPUT_INFO; 1964 | 1965 | typedef struct _AILTIMER // Timer instance 1966 | { 1967 | U32 status; 1968 | AILTIMERCB callback; 1969 | U32 user; 1970 | 1971 | S32 elapsed; 1972 | S32 value; 1973 | S32 callingCT; // Calling EXE's task number (16 bit only) 1974 | S32 callingDS; // Calling EXE's DS (used in 16 bit only) 1975 | S32 IsWin32s; // Is this a Win32s callback 1976 | } AILTIMERSTR; 1977 | 1978 | typedef struct _ADPCMDATATAG 1979 | { 1980 | U32 blocksize; 1981 | U32 extrasamples; 1982 | U32 blockleft; 1983 | U32 step; 1984 | U32 savesrc; 1985 | U32 sample; 1986 | U32 destend; 1987 | U32 srcend; 1988 | U32 samplesL; 1989 | U32 samplesR; 1990 | U16 moresamples[16]; 1991 | } ADPCMDATA; 1992 | 1993 | typedef struct _SAMPLE // Sample instance 1994 | { 1995 | char tag[4]; // HSAM 1996 | 1997 | HDIGDRIVER driver; // Driver for playback 1998 | 1999 | U32 status; // SMP_ flags: _FREE, _DONE, _PLAYING 2000 | 2001 | void const FAR *start[2]; // Sample buffer address (W) 2002 | U32 len [2]; // Sample buffer size in bytes (W) 2003 | U32 pos [2]; // Index to next byte (R/W) 2004 | U32 done [2]; // Nonzero if buffer with len=0 sent by app 2005 | S32 reset_ASI [2]; // Reset the ASI decoder at the end of the buffer 2006 | 2007 | U32 src_fract; // Fractional part of source address 2008 | S32 left_val; // Mixer source value from end of last buffer 2009 | S32 right_val; // Mixer source value from end of last buffer 2010 | 2011 | S32 current_buffer; // Buffer # active (0/1) 2012 | S32 last_buffer; // Last active buffer (for double-buffering) 2013 | S32 starved; // Buffer stream has run out of data 2014 | 2015 | S32 loop_count; // # of cycles-1 (1=one-shot, 0=indefinite) 2016 | S32 loop_start; // Starting offset of loop block (0=SOF) 2017 | S32 loop_end; // End offset of loop block (-1=EOF) 2018 | 2019 | S32 format; // DIG_F format (8/16 bits, mono/stereo) 2020 | U32 flags; // DIG_PCM_SIGN / DIG_PCM_ORDER (stereo only) 2021 | 2022 | S32 playback_rate; // Playback rate in hertz 2023 | 2024 | S32 volume; // Sample volume 0-127 2025 | S32 pan; // Mono panpot/stereo balance (0=L ... 127=R) 2026 | 2027 | S32 left_scale; // Left/mono volume scalar 0-2047 2028 | S32 right_scale; // Right volume scalar 0-2047 2029 | 2030 | S32 service_type; // 1 if single-buffered; 2 if streamed 2031 | 2032 | AILSAMPLECB SOB; // Start-of-block callback function 2033 | AILSAMPLECB EOB; // End-of-buffer callback function 2034 | AILSAMPLECB EOS; // End-of-sample callback function 2035 | 2036 | S32 user_data [8]; // Miscellaneous user data 2037 | S32 system_data[8]; // Miscellaneous system data 2038 | 2039 | ADPCMDATA adpcm; 2040 | 2041 | #ifdef IS_WINDOWS 2042 | 2043 | S32 SOB_IsWin32s; // Is this a Win32s callback 2044 | S32 EOB_IsWin32s; // Is this a Win32s callback 2045 | S32 EOS_IsWin32s; // Is this a Win32s callback 2046 | 2047 | // 2048 | // DirectSound-specific data 2049 | // 2050 | 2051 | S32 secondary_buffer; // Secondary buffer index 2052 | 2053 | S32 service_interval; // Service sample every n ms 2054 | S32 service_tick; // Current service countdown value 2055 | S32 buffer_segment_size; // Buffer segment size to fill 2056 | 2057 | S32 prev_segment; // Previous segment # (0...n) 2058 | S32 prev_cursor; // Previous play cursor location 2059 | 2060 | S32 bytes_remaining; // # of bytes left to play (if not -1) 2061 | 2062 | S32 direct_control; // 1 if app controls buffer, 0 if MSS 2063 | 2064 | #endif 2065 | 2066 | S32 doeob; // Flags to trigger callbacks 2067 | S32 dosob; 2068 | S32 doeos; 2069 | 2070 | // 2071 | // Sample pipeline stages 2072 | // 2073 | 2074 | DPINFO pipeline[N_SAMPLE_STAGES]; 2075 | 2076 | // 2077 | // Reverb parms 2078 | // 2079 | 2080 | F32 reverb_level; // Level [0.0, 1.0] 2081 | F32 reverb_reflect_time; // Reflect time in milliseconds 2082 | F32 reverb_decay_time; // Decay time [0.1, 20.0] 2083 | S32 base_scale; // Original 12-bit volume scalar 2084 | } 2085 | SAMPLE; 2086 | 2087 | #if defined(IS_WINDOWS) || defined(IS_MAC) 2088 | 2089 | DXDEC U32 AILCALL AIL_get_timer_highest_delay (void); 2090 | 2091 | DXDEC void AILCALL AIL_serve(void); 2092 | 2093 | #ifdef IS_MAC 2094 | 2095 | typedef void * LPSTR; 2096 | 2097 | #define WHDR_DONE 0 2098 | 2099 | typedef struct _WAVEIN 2100 | { 2101 | long temp; 2102 | } * HWAVEIN; 2103 | 2104 | typedef struct _WAVEHDR 2105 | { 2106 | S32 dwFlags; 2107 | S32 dwBytesRecorded; 2108 | S32 dwUser; 2109 | S32 temp; 2110 | void * lpData; 2111 | S32 dwBufferLength; 2112 | S32 longdwLoops; 2113 | S32 dwLoops; 2114 | void * lpNext; 2115 | U32 * reserved; 2116 | 2117 | } WAVEHDR, * LPWAVEHDR; 2118 | 2119 | #endif 2120 | 2121 | typedef struct _DIG_INPUT_DRIVER FAR *HDIGINPUT; // Handle to digital input driver 2122 | 2123 | typedef struct _DIG_INPUT_DRIVER // Handle to digital input driver 2124 | { 2125 | C8 tag[4]; // HDIN 2126 | 2127 | HTIMER background_timer; // Background timer handle 2128 | 2129 | AIL_INPUT_INFO info; // Input device descriptor 2130 | 2131 | S32 input_enabled; // 1 if enabled, 0 if not 2132 | 2133 | #ifndef IS_MAC 2134 | 2135 | U32 callback_user; // Callback user value 2136 | 2137 | // 2138 | // Provider-independent data 2139 | // 2140 | 2141 | U32 DMA_size; // Size of each DMA sub-buffer in bytes 2142 | void FAR *DMA[2]; // Simulated DMA buffers 2143 | 2144 | U8 silence; // Silence value for current format (0 or 128) 2145 | 2146 | S32 device_active; // 1 if buffers submittable, 0 if not 2147 | 2148 | // 2149 | // waveOut-specific data 2150 | // 2151 | 2152 | HWAVEIN hWaveIn; // Handle to wave input device 2153 | volatile WAVEHDR wavehdr[2]; // Handles to wave headers 2154 | 2155 | #else 2156 | Boolean timer_started; 2157 | Boolean locked; 2158 | Boolean enter_lock; 2159 | U32 saved_period; 2160 | 2161 | void* my_vars; 2162 | 2163 | // 2164 | // Input related 2165 | // 2166 | 2167 | U32 input_buffer_size; 2168 | char * input_buffers[2]; 2169 | 2170 | // 2171 | // Mix related 2172 | // 2173 | 2174 | char * build_buffer; 2175 | U32 build_buffer_size; 2176 | 2177 | // 2178 | // Output related 2179 | // 2180 | struct 2181 | { 2182 | S8 * buffer; 2183 | S8 * buffer_end; 2184 | 2185 | U32 size; 2186 | S8 * right_margine; 2187 | S8 * current_head; 2188 | S8 * current_tail; 2189 | } output_buffer; 2190 | 2191 | S32 mix_operation; 2192 | S32 playback_ratio; 2193 | U32 src_fract; 2194 | S8 * current_head; 2195 | S32 left_val; 2196 | S32 right_val; 2197 | 2198 | U32 stored_sample_size; 2199 | U32 stored_number_of_channels; 2200 | 2201 | U32 last_rw_delta; 2202 | U32 period; 2203 | 2204 | #endif 2205 | } 2206 | DIG_INPUT_DRIVER; 2207 | 2208 | #endif 2209 | 2210 | typedef struct _DIG_DRIVER // Handle to digital audio driver 2211 | { 2212 | char tag[4]; // HDIG 2213 | 2214 | HTIMER backgroundtimer; // Background timer handle 2215 | 2216 | S32 quiet; // # of consecutive quiet sample periods 2217 | 2218 | S32 n_active_samples; // # of samples being processed 2219 | 2220 | S32 master_volume; // Master sample volume 0-127 2221 | 2222 | S32 DMA_rate; // Hardware sample rate 2223 | S32 hw_format; // DIG_F code in use 2224 | U32 hw_mode_flags; // DIG_PCM_ flags for mode in use 2225 | 2226 | S32 channels_per_sample; // # of channels per sample (1 or 2) 2227 | S32 bytes_per_channel; // # of bytes per channel (1 or 2) 2228 | S32 channels_per_buffer; // # of channels per half-buffer 2229 | S32 samples_per_buffer; // # of samples per half-buffer 2230 | 2231 | S32 playing; // Playback active if non-zero 2232 | 2233 | #ifdef IS_MAC 2234 | U32 n_samples_allocated; 2235 | U32 n_samples_used; 2236 | U32 n_samples_played; 2237 | SAMPLE *samples; // Pointer to SAMPLEs 2238 | 2239 | HDIGDRIVER next; // Pointer to next HDIGDRIVER in use 2240 | U32 reset_works; // TRUE if OK to do waveOutReset 2241 | U32 request_reset; // If nonzero, do waveOutReset ASAP 2242 | S32 released; // has the sound manager been released? 2243 | 2244 | ExtSoundHeader sound_header; 2245 | SndChannelPtr sound_channel; 2246 | SndCallBackUPP global_callback; 2247 | Ptr buffers[2]; 2248 | Boolean loaded[2]; 2249 | U32 work_buffer; 2250 | U32 play_buffer; 2251 | U32 load_pos; 2252 | U32 load_size; 2253 | Boolean load; 2254 | U32 start_time; 2255 | void* background_processor; 2256 | 2257 | #else 2258 | HSAMPLE samples; // Pointer to list of SAMPLEs 2259 | #endif 2260 | 2261 | S32 n_samples; // # of SAMPLEs 2262 | 2263 | S32 build_size; // # of bytes in build buffer 2264 | S32 FAR *build_buffer; // Build buffer (4 * samples_per_buffer) 2265 | 2266 | S32 system_data[8]; // Miscellaneous system data 2267 | 2268 | S32 buffer_size; // Size of each output buffer 2269 | 2270 | #ifdef IS_WINDOWS 2271 | 2272 | // 2273 | // waveOut-specific interface data 2274 | // 2275 | 2276 | HWAVEOUT hWaveOut; // Wave output driver 2277 | 2278 | U32 reset_works; // TRUE if OK to do waveOutReset 2279 | U32 request_reset; // If nonzero, do waveOutReset ASAP 2280 | 2281 | LPWAVEHDR first; // Pointer to first WAVEHDR in chain 2282 | S32 n_buffers; // # of output WAVEHDRs in chain 2283 | 2284 | LPWAVEHDR volatile FAR *return_list; // Circular list of returned WAVEHDRs 2285 | S32 volatile return_head; // Head of WAVEHDR list (insertion point) 2286 | S32 volatile return_tail; // Tail of WAVEHDR list (retrieval point) 2287 | 2288 | 2289 | U32 deviceid; // id from waveout open 2290 | PCMWAVEFORMAT wformat; // format from waveout open 2291 | 2292 | // 2293 | // DirectSound-specific interface data 2294 | // 2295 | 2296 | U32 guid; // The guid id of the ds driver 2297 | AILLPDIRECTSOUND pDS; // DirectSound output driver (don't 2298 | // use with Smacker directly anymore!) 2299 | 2300 | U32 ds_priority; // priority opened with 2301 | 2302 | S32 emulated_ds; // is ds emulated or not? 2303 | AILLPDIRECTSOUNDBUFFER lppdsb; // primary buffer or null 2304 | 2305 | U32 dsHwnd; // HWND used with DirectSound 2306 | 2307 | AILLPDIRECTSOUNDBUFFER FAR * lpbufflist; // List of pointers to secondary buffers 2308 | HSAMPLE FAR *samp_list; // HSAMPLE associated with each buffer 2309 | S32 FAR *sec_format; // DIG_F_ format for secondary buffer 2310 | S32 max_buffs; // Max. allowable # of secondary buffers 2311 | 2312 | // 2313 | // Misc. data 2314 | // 2315 | 2316 | S32 released; // has the sound manager been released? 2317 | 2318 | U32 foreground_timer; // Foreground timer handle 2319 | 2320 | HDIGDRIVER next; // Pointer to next HDIGDRIVER in use 2321 | S32 callingCT; // Calling EXE's task number (16 bit only) 2322 | S32 callingDS; // Calling EXE's DS (used in 16 bit only) 2323 | 2324 | // 2325 | // Vars for waveOut emulation 2326 | // 2327 | 2328 | S32 DS_initialized; 2329 | 2330 | AILLPDIRECTSOUNDBUFFER DS_sec_buff; // Secondary buffer (or NULL if none) 2331 | AILLPDIRECTSOUNDBUFFER DS_out_buff; // Output buffer (may be sec or prim) 2332 | S32 DS_buffer_size; // Size of entire output buffer 2333 | 2334 | S32 DS_frag_cnt; // Total fragment count and size, and 2335 | S32 DS_frag_size; // last fragment occupied by play cursor 2336 | S32 DS_last_frag; 2337 | S32 DS_last_write; 2338 | S32 DS_last_timer; 2339 | S32 DS_skip_time; 2340 | 2341 | S32 DS_use_default_format; // 1 to force use of default DS primary buffer format 2342 | 2343 | #else 2344 | 2345 | #ifdef IS_DOS 2346 | 2347 | // must be first in the DOS section 2348 | void *DMA[2]; // Protected-mode pointers to half-buffers 2349 | // (note that DMA[0] may != DMA_buf) 2350 | 2351 | 2352 | REALFAR DMA_seg; // Seg:off pointer to DMA buffers (off=0) 2353 | U32 DMA_sel; // Selector for DMA buffers (off=0) 2354 | void *DMA_buf; // Protected-mode pointer to DMA buffers 2355 | 2356 | S16 *buffer_flag; // Protected-mode pointer to buffer flag 2357 | S32 last_buffer; // Last active buffer flag value in driver 2358 | 2359 | AIL_DRIVER *drvr; // Base driver descriptor 2360 | 2361 | DIG_DDT *DDT; // Protected-mode pointer to DDT 2362 | DIG_DST *DST; // Protected-mode pointer to DST 2363 | 2364 | #endif 2365 | 2366 | #endif 2367 | 2368 | #ifdef IS_X86 2369 | S32 use_MMX; // Use MMX with this driver if TRUE 2370 | #endif 2371 | 2372 | void FAR *decode_buffer; // Buffer used by optional ASI pipeline decoder 2373 | S32 decode_buffer_size; // # of bytes in decode buffer 2374 | 2375 | U32 us_count; 2376 | U32 ms_count; 2377 | U32 last_ms_polled; 2378 | U32 last_percent; 2379 | 2380 | // 2381 | // Digital driver pipeline stages 2382 | // 2383 | 2384 | DPINFO pipeline[N_DIGDRV_STAGES]; 2385 | 2386 | // 2387 | // Reverb buffer 2388 | // 2389 | 2390 | S32 FAR *reverb_buffer; 2391 | S32 reverb_buffer_size; 2392 | S32 reverb_buffer_position; 2393 | 2394 | #ifdef IS_WINDOWS 2395 | S32 no_wom_done; // don't process WOM_DONEs on this driver 2396 | U32 wom_done_buffers; 2397 | #endif 2398 | } 2399 | DIG_DRIVER; 2400 | 2401 | typedef struct // MIDI status log structure 2402 | { 2403 | S32 program [NUM_CHANS]; // Program Change 2404 | S32 pitch_l [NUM_CHANS]; // Pitch Bend LSB 2405 | S32 pitch_h [NUM_CHANS]; // Pitch Bend MSB 2406 | 2407 | S32 c_lock [NUM_CHANS]; // Channel Lock 2408 | S32 c_prot [NUM_CHANS]; // Channel Lock Protection 2409 | S32 c_mute [NUM_CHANS]; // Channel Mute 2410 | S32 c_v_prot [NUM_CHANS]; // Voice Protection 2411 | S32 bank [NUM_CHANS]; // Patch Bank Select 2412 | S32 gm_bank_l [NUM_CHANS]; // GM Bank Select 2413 | S32 gm_bank_m [NUM_CHANS]; // GM Bank Select 2414 | S32 indirect [NUM_CHANS]; // ICA indirect controller value 2415 | S32 callback [NUM_CHANS]; // Callback Trigger 2416 | 2417 | S32 mod [NUM_CHANS]; // Modulation 2418 | S32 vol [NUM_CHANS]; // Volume 2419 | S32 pan [NUM_CHANS]; // Panpot 2420 | S32 exp [NUM_CHANS]; // Expression 2421 | S32 sus [NUM_CHANS]; // Sustain 2422 | S32 reverb [NUM_CHANS]; // Reverb 2423 | S32 chorus [NUM_CHANS]; // Chorus 2424 | 2425 | S32 bend_range[NUM_CHANS]; // Bender Range (data MSB, RPN 0 assumed) 2426 | 2427 | S32 RPN_L [NUM_CHANS]; // RPN # LSB 2428 | S32 RPN_M [NUM_CHANS]; // RPN # MSB 2429 | } 2430 | CTRL_LOG; 2431 | 2432 | typedef struct _SEQUENCE // XMIDI sequence state table 2433 | { 2434 | char tag[4]; // HSEQ 2435 | 2436 | HMDIDRIVER driver; // Driver for playback 2437 | 2438 | U32 status; // SEQ_ flags 2439 | 2440 | void const FAR *TIMB; // XMIDI IFF chunk pointers 2441 | void const FAR *RBRN; 2442 | void const FAR *EVNT; 2443 | 2444 | U8 const FAR *EVNT_ptr; // Current event pointer 2445 | 2446 | U8 FAR *ICA; // Indirect Controller Array 2447 | 2448 | AILPREFIXCB prefix_callback; // XMIDI Callback Prefix handler 2449 | AILTRIGGERCB trigger_callback; // XMIDI Callback Trigger handler 2450 | AILBEATCB beat_callback; // XMIDI beat/bar change handler 2451 | AILSEQUENCECB EOS; // End-of-sequence callback function 2452 | 2453 | S32 loop_count; // 0=one-shot, -1=indefinite, ... 2454 | 2455 | S32 interval_count; // # of intervals until next event 2456 | S32 interval_num; // # of intervals since start 2457 | 2458 | S32 volume; // Sequence volume 0-127 2459 | S32 volume_target; // Target sequence volume 0-127 2460 | S32 volume_accum; // Accumulated volume period 2461 | S32 volume_period; // Period for volume stepping 2462 | 2463 | S32 tempo_percent; // Relative tempo percentage 0-100 2464 | S32 tempo_target; // Target tempo 0-100 2465 | S32 tempo_accum; // Accumulated tempo period 2466 | S32 tempo_period; // Period for tempo stepping 2467 | S32 tempo_error; // Error counter for tempo DDA 2468 | 2469 | S32 beat_count; // Sequence playback position 2470 | S32 measure_count; 2471 | 2472 | S32 time_numerator; // Sequence timing data 2473 | S32 time_fraction; 2474 | S32 beat_fraction; 2475 | S32 time_per_beat; 2476 | 2477 | void const FAR *FOR_ptrs[FOR_NEST]; // Loop stack 2478 | S32 FOR_loop_count [FOR_NEST]; 2479 | 2480 | S32 chan_map [NUM_CHANS]; // Physical channel map for sequence 2481 | 2482 | CTRL_LOG shadow; // Controller values for sequence 2483 | 2484 | S32 note_count; // # of notes "on" 2485 | 2486 | S32 note_chan [MAX_NOTES]; // Channel for queued note (-1=free) 2487 | S32 note_num [MAX_NOTES]; // Note # for queued note 2488 | S32 note_time [MAX_NOTES]; // Remaining duration in intervals 2489 | 2490 | S32 user_data [8]; // Miscellaneous user data 2491 | S32 system_data[8]; // Miscellaneous system data 2492 | 2493 | #ifdef IS_WINDOWS 2494 | S32 PREFIX_IsWin32s; // Is this a Win32s callback 2495 | S32 TRIGGER_IsWin32s; // Is this a Win32s callback 2496 | S32 BEAT_IsWin32s; // Is this a Win32s callback 2497 | S32 EOS_IsWin32s; // Is this a Win32s callback 2498 | #endif 2499 | } SEQUENCE; 2500 | 2501 | #ifdef IS_MAC 2502 | 2503 | struct MIDIHDR; 2504 | struct MIDIOUT; 2505 | typedef struct MIDIOUT* HMIDIOUT; 2506 | 2507 | #endif 2508 | 2509 | typedef struct _MDI_DRIVER // Handle to XMIDI driver 2510 | { 2511 | char tag[4]; // HMDI 2512 | 2513 | HTIMER timer; // XMIDI quantization timer 2514 | S32 interval_time; // XMIDI quantization timer interval in uS 2515 | 2516 | S32 disable; // > 0 to disable XMIDI service 2517 | 2518 | HSEQUENCE sequences; // Pointer to list of SEQUENCEs 2519 | S32 n_sequences; // # of SEQUENCEs 2520 | 2521 | S32 lock [NUM_CHANS]; // 1 if locked, 2 if protected, else 0 2522 | HSEQUENCE locker[NUM_CHANS]; // HSEQUENCE which locked channel 2523 | HSEQUENCE owner [NUM_CHANS]; // HSEQUENCE which owned locked channel 2524 | HSEQUENCE user [NUM_CHANS]; // Last sequence to use channel 2525 | S32 state [NUM_CHANS]; // Lock state prior to being locked 2526 | 2527 | S32 notes [NUM_CHANS]; // # of active notes in channel 2528 | 2529 | AILEVENTCB event_trap; // MIDI event trap callback function 2530 | AILTIMBRECB timbre_trap; // Timbre request callback function 2531 | 2532 | S32 master_volume; // Master XMIDI note volume 0-127 2533 | 2534 | S32 system_data[8]; // Miscellaneous system data 2535 | 2536 | #if defined(IS_WINDOWS) || defined(IS_MAC) 2537 | 2538 | S32 released; // has the hmidiout handle been released 2539 | U32 deviceid; // ID of the MIDI device 2540 | U8 FAR *sysdata; // SysEx buffer 2541 | 2542 | #endif 2543 | 2544 | #ifdef IS_WINDOWS 2545 | 2546 | S32 EVENT_IsWin32s; // Is this a Win32s callback 2547 | S32 TIMBRE_IsWin32s; // Is this a Win32s callback 2548 | 2549 | MIDIHDR FAR *mhdr; // SysEx header 2550 | 2551 | HMDIDRIVER next; // Pointer to next HMDIDRIVER in use 2552 | S32 callingCT; // Calling EXE's task number (16 bit only) 2553 | S32 callingDS; // Calling EXE's DS (used in 16 bit only) 2554 | 2555 | HMIDIOUT hMidiOut; // MIDI output driver 2556 | 2557 | #else 2558 | 2559 | #ifdef IS_DOS 2560 | 2561 | S32 message_count; // MIDI message count 2562 | S32 offset; // MIDI buffer offset 2563 | 2564 | AIL_DRIVER *drvr; // Base driver descriptor 2565 | 2566 | MDI_DDT *DDT; // Protected-mode pointer to DDT 2567 | MDI_DST *DST; // Protected-mode pointer to DST 2568 | #else 2569 | #ifdef IS_MAC 2570 | struct MIDIHDR FAR *mhdr; // SysEx header 2571 | HMDIDRIVER next; // Pointer to next HMDIDRIVER in use 2572 | HMIDIOUT hMidiOut; // MIDI output driver 2573 | U32 last_us_time; 2574 | long period_counter; 2575 | long current_period_sum; 2576 | #endif 2577 | #endif 2578 | 2579 | #endif 2580 | 2581 | } 2582 | MDI_DRIVER; 2583 | 2584 | typedef struct // XMIDI TIMB IFF chunk 2585 | { 2586 | S8 name[4]; 2587 | 2588 | U8 msb; 2589 | U8 lsb; 2590 | U8 lsb2; 2591 | U8 lsb3; 2592 | 2593 | U16 n_entries; 2594 | 2595 | U16 timbre[1]; 2596 | } 2597 | TIMB_chunk; 2598 | 2599 | typedef struct // XMIDI RBRN IFF entry 2600 | { 2601 | S16 bnum; 2602 | U32 offset; 2603 | } 2604 | RBRN_entry; 2605 | 2606 | typedef struct // Wave library entry 2607 | { 2608 | S32 bank; // XMIDI bank, MIDI patch for sample 2609 | S32 patch; 2610 | 2611 | S32 root_key; // Root MIDI note # for sample (or -1) 2612 | 2613 | U32 file_offset; // Offset of wave data from start-of-file 2614 | U32 size; // Size of wave sample in bytes 2615 | 2616 | S32 format; // DIG_F format (8/16 bits, mono/stereo) 2617 | U32 flags; // DIG_PCM_SIGN / DIG_PCM_ORDER (stereo) 2618 | S32 playback_rate; // Playback rate in hertz 2619 | } 2620 | WAVE_ENTRY; 2621 | 2622 | typedef struct // Virtual "wave synthesizer" descriptor 2623 | { 2624 | HMDIDRIVER mdi; // MIDI driver for use with synthesizer 2625 | HDIGDRIVER dig; // Digital driver for use with synthesizer 2626 | 2627 | WAVE_ENTRY FAR *library; // Pointer to wave library 2628 | 2629 | AILEVENTCB prev_event_fn; // Previous MIDI event trap function 2630 | AILTIMBRECB prev_timb_fn; // Previous timbre request trap function 2631 | 2632 | CTRL_LOG controls; // MIDI controller states 2633 | 2634 | WAVE_ENTRY FAR *wave [NUM_CHANS];// Pointer to WAVE_ENTRY for each channel 2635 | 2636 | HSAMPLE S [MAX_W_VOICES]; // List of HSAMPLE voices 2637 | S32 n_voices; // Actual # of voices allocated to synth 2638 | 2639 | S32 chan [MAX_W_VOICES]; // MIDI channel for each voice, or -1 2640 | S32 note [MAX_W_VOICES]; // MIDI note number for voice 2641 | S32 root [MAX_W_VOICES]; // MIDI root note for voice 2642 | S32 rate [MAX_W_VOICES]; // Playback rate for voice 2643 | S32 vel [MAX_W_VOICES]; // MIDI note velocity for voice 2644 | U32 time [MAX_W_VOICES]; // Timestamp for voice 2645 | 2646 | U32 event; // Event counter for LRU timestamps 2647 | } 2648 | WAVE_SYNTH; 2649 | 2650 | typedef WAVE_SYNTH FAR * HWAVESYNTH;// Handle to virtual wave synthesizer 2651 | 2652 | // 2653 | // Handle to thread which called AIL_startup() 2654 | // 2655 | // This thread is suspended by MSS callback threads, to simulate DOS-style 2656 | // interrupt handler behavior 2657 | // 2658 | 2659 | #ifdef IS_WIN32 2660 | 2661 | extern HANDLE hAppThread; 2662 | 2663 | #endif 2664 | 2665 | // 2666 | // Background flag for timers 2667 | // 2668 | 2669 | extern volatile S32 AIL_bkgnd_flag; 2670 | 2671 | // 2672 | // Global preference array 2673 | // 2674 | 2675 | extern S32 AIL_preference [N_PREFS]; 2676 | 2677 | // 2678 | // DIG_DRIVER list 2679 | // 2680 | 2681 | extern HDIGDRIVER DIG_first; 2682 | 2683 | // 2684 | // MDI_DRIVER list 2685 | // 2686 | 2687 | extern HMDIDRIVER MDI_first; 2688 | 2689 | // 2690 | // Miscellaneous system services 2691 | // 2692 | 2693 | #define FILE_READ_WITH_SIZE ((void FAR*)(S32)-1) 2694 | 2695 | #ifndef NO_OLD_SYS_FUNCTIONS 2696 | 2697 | #define MEM_alloc_lock AIL_mem_alloc_lock 2698 | #define MEM_free_lock AIL_mem_free_lock 2699 | #define FILE_error AIL_file_error 2700 | #define FILE_size AIL_file_size 2701 | #define FILE_read AIL_file_read 2702 | #define FILE_write AIL_file_write 2703 | 2704 | #ifdef IS_DOS 2705 | 2706 | #define MEM_alloc AIL_mem_alloc 2707 | #define MEM_free AIL_mem_free 2708 | #define MEM_use_malloc AIL_mem_use_malloc 2709 | #define MEM_use_free AIL_mem_use_free 2710 | #define MEM_alloc_DOS AIL_mem_alloc_DOS 2711 | #define MEM_free_DOS AIL_mem_free_DOS 2712 | #define VMM_lock_range AIL_vmm_lock_range 2713 | #define VMM_unlock_range AIL_vmm_unlock_range 2714 | #define VMM_lock AIL_vmm_lock 2715 | #define VMM_unlock AIL_vmm_unlock 2716 | 2717 | #endif 2718 | 2719 | #endif 2720 | 2721 | extern S32 AILCALLBACK DP_ASI_DECODER_callback(U32 user, 2722 | void FAR *dest, 2723 | S32 bytes_requested, 2724 | S32 offset); 2725 | 2726 | DXDEC void FAR * AILCALL AIL_mem_alloc_lock(U32 size); 2727 | DXDEC void AILCALL AIL_mem_free_lock (void FAR *ptr); 2728 | 2729 | DXDEC S32 AILCALL AIL_file_error (void); 2730 | 2731 | DXDEC S32 AILCALL AIL_file_size (char const FAR *filename); 2732 | 2733 | DXDEC void FAR * AILCALL AIL_file_read (char const FAR *filename, 2734 | void FAR *dest); 2735 | 2736 | DXDEC S32 AILCALL AIL_file_write (char const FAR *filename, 2737 | void const FAR *buf, 2738 | U32 len); 2739 | 2740 | DXDEC S32 AILCALL AIL_WAV_file_write 2741 | (char const FAR *filename, 2742 | void const FAR *buf, 2743 | U32 len, 2744 | S32 rate, 2745 | S32 format); 2746 | 2747 | DXDEC S32 AILCALL AIL_file_append (char const FAR *filename, 2748 | void const FAR *buf, U32 len); 2749 | 2750 | #ifdef IS_MAC 2751 | 2752 | 2753 | DXDEC S32 AILCALL AIL_file_fss_size(FSSpec const FAR *filename); 2754 | 2755 | DXDEC void FAR * AILCALL AIL_file_fss_read(FSSpec const FAR *filename, 2756 | void FAR *dest); 2757 | 2758 | DXDEC S32 AILCALL AIL_file_fss_write(FSSpec const FAR *filename, 2759 | void const FAR *buf, 2760 | U32 len); 2761 | 2762 | DXDEC S32 AILCALL AIL_file_fss_attrib_write 2763 | (FSSpec const FAR *filename, 2764 | void const FAR *buf, 2765 | U32 len, 2766 | U32 type, 2767 | U32 creator ); 2768 | 2769 | DXDEC S32 AILCALL AIL_WAV_file_fss_write 2770 | (FSSpec const FAR *filename, 2771 | void const FAR *buf, 2772 | U32 len, 2773 | S32 rate, 2774 | S32 format); 2775 | 2776 | DXDEC void * AILCALL AIL_mem_use_malloc(void * AILCALLBACK (*fn)(U32)); 2777 | DXDEC void * AILCALL AIL_mem_use_free (void AILCALLBACK (*fn)(void *)); 2778 | 2779 | #endif 2780 | 2781 | #ifdef IS_DOS 2782 | 2783 | extern void * AILCALLBACK (*AIL_mem_alloc) (U32); 2784 | extern void AILCALLBACK (*AIL_mem_free) (void *); 2785 | 2786 | void * cdecl AIL_mem_use_malloc(void * AILCALLBACK (*fn)(U32)); 2787 | void * cdecl AIL_mem_use_free (void AILCALLBACK (*fn)(void *)); 2788 | 2789 | // 2790 | // Other memory-management functions 2791 | // 2792 | 2793 | DXDEC S32 AILCALL AIL_mem_alloc_DOS (U32 n_paras, 2794 | void **protected_ptr, 2795 | U32 *segment_far_ptr, 2796 | U32 *selector); 2797 | 2798 | DXDEC void AILCALL AIL_mem_free_DOS (void *protected_ptr, 2799 | U32 segment_far_ptr, 2800 | U32 selector); 2801 | 2802 | DXDEC S32 AILCALL AIL_vmm_lock_range (void *p1, void *p2); 2803 | DXDEC S32 AILCALL AIL_vmm_unlock_range (void *p1, void *p2); 2804 | 2805 | DXDEC S32 AILCALL AIL_vmm_lock (void *start, U32 size); 2806 | DXDEC S32 AILCALL AIL_vmm_unlock (void *start, U32 size); 2807 | 2808 | DXDEC U32 AILCALL AIL_sel_base (U32 sel); 2809 | 2810 | DXDEC void AILCALL AIL_sel_set_limit (U32 sel, 2811 | U32 limit); 2812 | // 2813 | // Last IO_PARMS structure used to attempt device detection 2814 | // 2815 | 2816 | extern IO_PARMS AIL_last_IO_attempt; 2817 | 2818 | // 2819 | // Low-level support services 2820 | // 2821 | 2822 | DXDEC REALFAR AILCALL AIL_get_real_vect (U32 vectnum); 2823 | 2824 | DXDEC void AILCALL AIL_set_real_vect (U32 vectnum, 2825 | REALFAR real_ptr); 2826 | 2827 | DXDEC void AILCALL AIL_set_USE16_ISR (S32 IRQ, 2828 | REALFAR real_base, 2829 | U32 ISR_offset); 2830 | 2831 | DXDEC void AILCALL AIL_restore_USE16_ISR (S32 IRQ); 2832 | 2833 | DXDEC U32 AILCALL AIL_disable_interrupts (void); 2834 | DXDEC void AILCALL AIL_restore_interrupts (U32 FD_register); 2835 | 2836 | DXDEC void AILCALL AIL_switch_stack (void *stack, 2837 | U32 size, 2838 | U32 *SS, 2839 | void **ESP, 2840 | void **EBP); 2841 | 2842 | DXDEC void AILCALL AIL_restore_stack (U32 SS, 2843 | void *ESP, 2844 | void *EBP); 2845 | 2846 | DXDEC S32 AILCALL AIL_call_driver (AIL_DRIVER *drvr, 2847 | S32 fn, 2848 | VDI_CALL *in, 2849 | VDI_CALL *out); 2850 | 2851 | DXDEC S32 AILCALL AIL_read_INI (AIL_INI *INI, 2852 | char *filename); 2853 | 2854 | DXDEC U32 AILCALL AIL_interrupt_divisor (void); 2855 | 2856 | #endif 2857 | 2858 | 2859 | #ifdef __WATCOMC__ 2860 | 2861 | void MSSBreakPoint(); 2862 | #pragma aux MSSBreakPoint = "int 3"; 2863 | 2864 | #else 2865 | 2866 | #define MSSBreakPoint() __asm {int 3} 2867 | 2868 | #endif 2869 | 2870 | 2871 | // 2872 | // High-level support services 2873 | // 2874 | 2875 | #ifdef IS_MAC 2876 | 2877 | #if !defined(max) 2878 | #define max(a,b) (((a) > (b)) ? (a) : (b)) 2879 | #endif 2880 | #if !defined(min) 2881 | #define min(a,b) (((a) < (b)) ? (a) : (b)) 2882 | #endif 2883 | 2884 | #endif 2885 | 2886 | #ifdef IS_DOS 2887 | 2888 | #ifdef IS_WATCOM 2889 | 2890 | #if !defined(max) // Watcom stdlib.h doesn't define these for C++ 2891 | #define max(a,b) (((a) > (b)) ? (a) : (b)) 2892 | #endif 2893 | #if !defined(min) 2894 | #define min(a,b) (((a) < (b)) ? (a) : (b)) 2895 | #endif 2896 | 2897 | #endif 2898 | 2899 | #ifdef __SW_3R 2900 | extern S32 AILCALL AIL_startup_reg (void); 2901 | #define AIL_startup AIL_startup_reg 2902 | #else 2903 | extern S32 AILCALL AIL_startup_stack (void); 2904 | #define AIL_startup AIL_startup_stack 2905 | #endif 2906 | 2907 | #define AIL_quick_startup(ud,um,opr,opb,ops) AIL_quick_startup_with_start(&AIL_startup,ud,um,opr,opb,ops) 2908 | 2909 | #define AIL_get_preference(number) (AIL_preference[number]) 2910 | 2911 | #else 2912 | 2913 | DXDEC S32 AILCALL AIL_startup (void); 2914 | 2915 | DXDEC S32 AILCALL AIL_get_preference (U32 number); 2916 | 2917 | #endif 2918 | 2919 | DXDEC void AILCALL AIL_shutdown (void); 2920 | 2921 | DXDEC S32 AILCALL AIL_set_preference (U32 number, 2922 | S32 value); 2923 | 2924 | DXDEC char FAR *AILCALL AIL_last_error (void); 2925 | 2926 | DXDEC void AILCALL AIL_set_error (char const FAR * error_msg); 2927 | 2928 | // 2929 | // Low-level support services 2930 | // 2931 | 2932 | DXDEC void 2933 | #ifndef IS_MAC 2934 | __cdecl 2935 | #endif 2936 | AIL_debug_printf (C8 const FAR *fmt, ...); 2937 | 2938 | #ifdef IS_X86 2939 | 2940 | DXDEC U32 AILCALL AIL_MMX_available (void); 2941 | 2942 | #endif 2943 | 2944 | DXDEC void AILCALL AIL_lock (void); 2945 | DXDEC void AILCALL AIL_unlock (void); 2946 | 2947 | #ifdef IS_WIN32 2948 | 2949 | DXDEC void AILCALL AIL_lock_mutex (void); 2950 | DXDEC void AILCALL AIL_unlock_mutex (void); 2951 | 2952 | #endif 2953 | 2954 | DXDEC void AILCALL AIL_delay (S32 intervals); 2955 | 2956 | DXDEC S32 AILCALL AIL_background (void); 2957 | 2958 | // 2959 | // Process services 2960 | // 2961 | 2962 | DXDEC HTIMER AILCALL AIL_register_timer (AILTIMERCB fn); 2963 | 2964 | DXDEC U32 AILCALL AIL_set_timer_user (HTIMER timer, 2965 | U32 user); 2966 | 2967 | DXDEC void AILCALL AIL_set_timer_period (HTIMER timer, 2968 | U32 microseconds); 2969 | 2970 | DXDEC void AILCALL AIL_set_timer_frequency (HTIMER timer, 2971 | U32 hertz); 2972 | 2973 | DXDEC void AILCALL AIL_set_timer_divisor (HTIMER timer, 2974 | U32 PIT_divisor); 2975 | 2976 | DXDEC void AILCALL AIL_start_timer (HTIMER timer); 2977 | DXDEC void AILCALL AIL_start_all_timers (void); 2978 | 2979 | DXDEC void AILCALL AIL_stop_timer (HTIMER timer); 2980 | DXDEC void AILCALL AIL_stop_all_timers (void); 2981 | 2982 | DXDEC void AILCALL AIL_release_timer_handle (HTIMER timer); 2983 | DXDEC void AILCALL AIL_release_all_timers (void); 2984 | 2985 | #ifdef IS_WIN32 2986 | 2987 | #ifndef BUILD_MSS 2988 | 2989 | // static function that handles shutdown 2990 | int __cdecl MSS_auto_cleanup(void); 2991 | 2992 | #ifdef _MSC_VER 2993 | // on MSVC, automatically register a cleanup function 2994 | //ODCODENOTE Remove 2995 | //#define AIL_startup() (MSS_auto_cleanup(),AIL_startup()) 2996 | #endif 2997 | 2998 | #endif 2999 | 3000 | DXDEC HWND AILCALL AIL_HWND (void); 3001 | 3002 | #else 3003 | #ifdef IS_MAC 3004 | DXDEC ProcessSerialNumber AIL_Process(void); 3005 | #endif 3006 | #endif 3007 | 3008 | // 3009 | // high-level digital services 3010 | // 3011 | 3012 | DXDEC HDIGDRIVER AILCALL AIL_open_digital_driver( U32 frequency, 3013 | S32 bits, 3014 | S32 channel, 3015 | U32 flags ); 3016 | 3017 | #define AIL_OPEN_DIGITAL_FORCE_PREFERENCE 1 3018 | 3019 | DXDEC void AILCALL AIL_close_digital_driver( HDIGDRIVER dig ); 3020 | 3021 | #ifdef IS_WINDOWS 3022 | 3023 | #define AIL_MSS_version(str,len) \ 3024 | { \ 3025 | HINSTANCE l=LoadLibrary(MSSDLLNAME); \ 3026 | if ((U32)l<=32) \ 3027 | *(str)=0; \ 3028 | else { \ 3029 | LoadString(l,1,str,len); \ 3030 | FreeLibrary(l); \ 3031 | } \ 3032 | } 3033 | 3034 | DXDEC S32 AILCALL AIL_waveOutOpen (HDIGDRIVER FAR *drvr, 3035 | LPHWAVEOUT FAR *lphWaveOut, 3036 | S32 wDeviceID, 3037 | LPWAVEFORMAT lpFormat); 3038 | 3039 | DXDEC void AILCALL AIL_waveOutClose (HDIGDRIVER drvr); 3040 | 3041 | DXDEC S32 AILCALL AIL_digital_handle_release(HDIGDRIVER drvr); 3042 | 3043 | DXDEC S32 AILCALL AIL_digital_handle_reacquire 3044 | (HDIGDRIVER drvr); 3045 | 3046 | #else 3047 | 3048 | #ifdef IS_MAC 3049 | 3050 | typedef struct MSS_VersionType_ 3051 | { 3052 | Str255 version_name; 3053 | } MSS_VersionType; 3054 | 3055 | #define AIL_MSS_version(str,len) \ 3056 | { \ 3057 | long _res = OpenResFile("\pMiles Shared Library"); \ 3058 | if (_res==-1) \ 3059 | { \ 3060 | str[0]=0; \ 3061 | } \ 3062 | else \ 3063 | { \ 3064 | Handle _H; \ 3065 | short _Err; \ 3066 | long _cur= CurResFile(); \ 3067 | UseResFile(_res); \ 3068 | _H = GetResource('vers', 2); \ 3069 | _Err = ResError(); \ 3070 | if((_Err != noErr) || (_H==0)) \ 3071 | { \ 3072 | str[0]=0; \ 3073 | UseResFile(_cur); \ 3074 | CloseResFile(_res); \ 3075 | } \ 3076 | else \ 3077 | { \ 3078 | if (GetHandleSize(_H)==0) \ 3079 | { \ 3080 | str[0]=0; \ 3081 | UseResFile(_cur); \ 3082 | CloseResFile(_res); \ 3083 | } \ 3084 | else \ 3085 | { \ 3086 | MSS_VersionType * _vt = (MSS_VersionType*)*_H; \ 3087 | if ((U32)_vt->version_name[6]>4) \ 3088 | _vt->version_name[6]-=4; \ 3089 | else \ 3090 | _vt->version_name[6]=0; \ 3091 | if (((U32)len) <= ((U32)_vt->version_name[6])) \ 3092 | _vt->version_name[6] = (U8)len-1; \ 3093 | memcpy( str, _vt->version_name+11, _vt->version_name[6] ); \ 3094 | str[_vt->version_name[6]]=0; \ 3095 | UseResFile(_cur); \ 3096 | CloseResFile(_res); \ 3097 | } \ 3098 | ReleaseResource(_H); \ 3099 | } \ 3100 | } \ 3101 | } 3102 | 3103 | DXDEC S32 AILCALL AIL_digital_handle_release(HDIGDRIVER drvr); 3104 | 3105 | DXDEC S32 AILCALL AIL_digital_handle_reacquire 3106 | (HDIGDRIVER drvr); 3107 | 3108 | #else 3109 | 3110 | // 3111 | // DOS installation services 3112 | // 3113 | 3114 | DXDEC IO_PARMS * AILCALL AIL_get_IO_environment (AIL_DRIVER *drvr); 3115 | 3116 | DXDEC AIL_DRIVER* AILCALL AIL_install_driver (U8 const *driver_image, 3117 | U32 n_bytes); 3118 | 3119 | DXDEC void AILCALL AIL_uninstall_driver (AIL_DRIVER *drvr); 3120 | 3121 | DXDEC S32 AILCALL AIL_install_DIG_INI (HDIGDRIVER *dig); 3122 | 3123 | DXDEC HDIGDRIVER AILCALL AIL_install_DIG_driver_file 3124 | (char const *filename, 3125 | IO_PARMS *IO); 3126 | 3127 | DXDEC void AILCALL AIL_uninstall_DIG_driver (HDIGDRIVER dig); 3128 | 3129 | 3130 | DXDEC HDIGDRIVER AILCALL AIL_install_DIG_driver_image 3131 | (void const *driver_image, 3132 | U32 size, 3133 | IO_PARMS *IO); 3134 | #endif 3135 | #endif 3136 | 3137 | DXDEC char FAR* AILCALL AIL_set_redist_directory(char const FAR*dir); 3138 | 3139 | DXDEC S32 AILCALL AIL_digital_CPU_percent (HDIGDRIVER dig); 3140 | 3141 | DXDEC S32 AILCALL AIL_digital_latency (HDIGDRIVER dig); 3142 | 3143 | DXDEC HSAMPLE AILCALL AIL_allocate_sample_handle 3144 | (HDIGDRIVER dig); 3145 | 3146 | DXDEC HSAMPLE AILCALL AIL_allocate_file_sample (HDIGDRIVER dig, 3147 | void const FAR *file_image, 3148 | S32 block); 3149 | 3150 | DXDEC void AILCALL AIL_release_sample_handle (HSAMPLE S); 3151 | 3152 | DXDEC void AILCALL AIL_init_sample (HSAMPLE S); 3153 | 3154 | DXDEC S32 AILCALL AIL_set_sample_file (HSAMPLE S, 3155 | void const FAR *file_image, 3156 | S32 block); 3157 | 3158 | DXDEC S32 AILCALL AIL_set_named_sample_file (HSAMPLE S, 3159 | C8 const FAR *file_type_suffix, 3160 | void const FAR *file_image, 3161 | S32 file_size, 3162 | S32 block); 3163 | 3164 | DXDEC HPROVIDER AILCALL AIL_set_sample_processor (HSAMPLE S, 3165 | SAMPLESTAGE pipeline_stage, 3166 | HPROVIDER provider); 3167 | 3168 | DXDEC HPROVIDER AILCALL AIL_set_digital_driver_processor 3169 | (HDIGDRIVER dig, 3170 | DIGDRVSTAGE pipeline_stage, 3171 | HPROVIDER provider); 3172 | 3173 | DXDEC void AILCALL AIL_set_sample_adpcm_block_size 3174 | (HSAMPLE S, 3175 | U32 blocksize); 3176 | 3177 | DXDEC void AILCALL AIL_set_sample_address (HSAMPLE S, 3178 | void const FAR *start, 3179 | U32 len); 3180 | 3181 | DXDEC void AILCALL AIL_set_sample_type (HSAMPLE S, 3182 | S32 format, 3183 | U32 flags); 3184 | 3185 | DXDEC void AILCALL AIL_start_sample (HSAMPLE S); 3186 | 3187 | DXDEC void AILCALL AIL_stop_sample (HSAMPLE S); 3188 | 3189 | DXDEC void AILCALL AIL_resume_sample (HSAMPLE S); 3190 | 3191 | DXDEC void AILCALL AIL_end_sample (HSAMPLE S); 3192 | 3193 | DXDEC void AILCALL AIL_set_sample_playback_rate 3194 | (HSAMPLE S, 3195 | S32 playback_rate); 3196 | 3197 | DXDEC void AILCALL AIL_set_sample_volume (HSAMPLE S, 3198 | S32 volume); 3199 | 3200 | DXDEC void AILCALL AIL_set_sample_pan (HSAMPLE S, 3201 | S32 pan); 3202 | 3203 | DXDEC void AILCALL AIL_set_sample_loop_count (HSAMPLE S, 3204 | S32 loop_count); 3205 | 3206 | DXDEC void AILCALL AIL_set_sample_loop_block (HSAMPLE S, 3207 | S32 loop_start_offset, 3208 | S32 loop_end_offset); 3209 | 3210 | DXDEC U32 AILCALL AIL_sample_status (HSAMPLE S); 3211 | 3212 | DXDEC S32 AILCALL AIL_sample_playback_rate (HSAMPLE S); 3213 | 3214 | DXDEC S32 AILCALL AIL_sample_volume (HSAMPLE S); 3215 | 3216 | DXDEC S32 AILCALL AIL_sample_pan (HSAMPLE S); 3217 | 3218 | DXDEC S32 AILCALL AIL_sample_loop_count (HSAMPLE S); 3219 | 3220 | DXDEC void AILCALL AIL_set_digital_master_volume 3221 | (HDIGDRIVER dig, 3222 | S32 master_volume); 3223 | 3224 | DXDEC S32 AILCALL AIL_digital_master_volume (HDIGDRIVER dig); 3225 | 3226 | DXDEC void AILCALL AIL_set_sample_reverb(HSAMPLE S, 3227 | F32 reverb_level, 3228 | F32 reverb_reflect_time, 3229 | F32 reverb_decay_time); 3230 | 3231 | DXDEC void AILCALL AIL_sample_reverb (HSAMPLE S, 3232 | F32 FAR *reverb_level, 3233 | F32 FAR *reverb_reflect_time, 3234 | F32 FAR *reverb_decay_time); 3235 | 3236 | // 3237 | // low-level digital services 3238 | // 3239 | 3240 | DXDEC S32 AILCALL AIL_minimum_sample_buffer_size(HDIGDRIVER dig, 3241 | S32 playback_rate, 3242 | S32 format); 3243 | 3244 | DXDEC S32 AILCALL AIL_sample_buffer_ready (HSAMPLE S); 3245 | 3246 | DXDEC void AILCALL AIL_load_sample_buffer (HSAMPLE S, 3247 | U32 buff_num, 3248 | void const FAR *buffer, 3249 | U32 len); 3250 | 3251 | DXDEC void AILCALL AIL_request_EOB_ASI_reset (HSAMPLE S, 3252 | U32 buff_num); 3253 | 3254 | DXDEC S32 AILCALL AIL_sample_buffer_info (HSAMPLE S, //) 3255 | U32 FAR *pos0, 3256 | U32 FAR *len0, 3257 | U32 FAR *pos1, 3258 | U32 FAR *len1); 3259 | 3260 | DXDEC U32 AILCALL AIL_sample_granularity (HSAMPLE S); 3261 | 3262 | DXDEC void AILCALL AIL_set_sample_position (HSAMPLE S, 3263 | U32 pos); 3264 | 3265 | DXDEC U32 AILCALL AIL_sample_position (HSAMPLE S); 3266 | 3267 | DXDEC AILSAMPLECB AILCALL AIL_register_SOB_callback 3268 | (HSAMPLE S, 3269 | AILSAMPLECB SOB); 3270 | 3271 | DXDEC AILSAMPLECB AILCALL AIL_register_EOB_callback 3272 | (HSAMPLE S, 3273 | AILSAMPLECB EOB); 3274 | 3275 | DXDEC AILSAMPLECB AILCALL AIL_register_EOS_callback 3276 | (HSAMPLE S, 3277 | AILSAMPLECB EOS); 3278 | 3279 | DXDEC AILSAMPLECB AILCALL AIL_register_EOF_callback 3280 | (HSAMPLE S, 3281 | AILSAMPLECB EOFILE); 3282 | 3283 | DXDEC void AILCALL AIL_set_sample_user_data (HSAMPLE S, 3284 | U32 index, 3285 | S32 value); 3286 | 3287 | DXDEC S32 AILCALL AIL_sample_user_data (HSAMPLE S, 3288 | U32 index); 3289 | 3290 | DXDEC S32 AILCALL AIL_active_sample_count (HDIGDRIVER dig); 3291 | 3292 | DXDEC void AILCALL AIL_digital_configuration (HDIGDRIVER dig, 3293 | S32 FAR *rate, 3294 | S32 FAR *format, 3295 | char FAR *string); 3296 | #ifdef IS_WIN32 3297 | 3298 | DXDEC S32 AILCALL AIL_set_direct_buffer_control (HSAMPLE S, 3299 | U32 command); 3300 | 3301 | DXDEC void AILCALL AIL_get_DirectSound_info (HSAMPLE S, 3302 | AILLPDIRECTSOUND *lplpDS, 3303 | AILLPDIRECTSOUNDBUFFER *lplpDSB); 3304 | 3305 | DXDEC S32 AILCALL AIL_set_DirectSound_HWND(HDIGDRIVER dig, HWND wnd); 3306 | 3307 | #endif 3308 | 3309 | DXDEC void AILCALL AIL_set_sample_ms_position (HSAMPLE S, //) 3310 | S32 milliseconds); 3311 | 3312 | DXDEC void AILCALL AIL_sample_ms_position (HSAMPLE S, //) 3313 | S32 FAR * total_milliseconds, 3314 | S32 FAR * current_milliseconds); 3315 | 3316 | 3317 | // 3318 | // Digital input services 3319 | // 3320 | 3321 | #if defined(IS_WINDOWS) || defined (IS_MAC) 3322 | 3323 | DXDEC HDIGINPUT AILCALL AIL_open_input (AIL_INPUT_INFO FAR *info); 3324 | 3325 | DXDEC void AILCALL AIL_close_input (HDIGINPUT dig); 3326 | 3327 | DXDEC AIL_INPUT_INFO FAR * 3328 | AILCALL AIL_get_input_info (HDIGINPUT dig); 3329 | 3330 | DXDEC S32 AILCALL AIL_set_input_state (HDIGINPUT dig, 3331 | S32 enable); 3332 | #endif 3333 | 3334 | 3335 | // 3336 | // High-level XMIDI services 3337 | // 3338 | 3339 | DXDEC HMDIDRIVER AILCALL AIL_open_XMIDI_driver( U32 flags ); 3340 | 3341 | #define AIL_OPEN_XMIDI_NULL_DRIVER 1 3342 | 3343 | DXDEC void AILCALL AIL_close_XMIDI_driver( HMDIDRIVER mdi ); 3344 | 3345 | #ifdef IS_MAC 3346 | 3347 | DXDEC S32 AILCALL AIL_MIDI_handle_release 3348 | (HMDIDRIVER mdi); 3349 | 3350 | DXDEC S32 AILCALL AIL_MIDI_handle_reacquire 3351 | (HMDIDRIVER mdi); 3352 | 3353 | #else 3354 | 3355 | #ifdef IS_WINDOWS 3356 | 3357 | DXDEC S32 AILCALL AIL_midiOutOpen(HMDIDRIVER FAR *drvr, 3358 | LPHMIDIOUT FAR *lphMidiOut, 3359 | S32 dwDeviceID); 3360 | 3361 | DXDEC void AILCALL AIL_midiOutClose (HMDIDRIVER mdi); 3362 | 3363 | DXDEC S32 AILCALL AIL_MIDI_handle_release 3364 | (HMDIDRIVER mdi); 3365 | 3366 | DXDEC S32 AILCALL AIL_MIDI_handle_reacquire 3367 | (HMDIDRIVER mdi); 3368 | 3369 | #else 3370 | 3371 | #ifdef IS_DOS 3372 | 3373 | DXDEC S32 AILCALL AIL_install_MDI_INI (HMDIDRIVER *mdi); 3374 | 3375 | DXDEC HMDIDRIVER AILCALL AIL_install_MDI_driver_file 3376 | (char const *filename, 3377 | IO_PARMS *IO); 3378 | 3379 | DXDEC void AILCALL AIL_uninstall_MDI_driver (HMDIDRIVER mdi); 3380 | 3381 | 3382 | DXDEC HMDIDRIVER AILCALL AIL_install_MDI_driver_image 3383 | (void const *driver_image, 3384 | U32 size, 3385 | IO_PARMS *IO); 3386 | 3387 | DXDEC S32 AILCALL AIL_MDI_driver_type (HMDIDRIVER mdi); 3388 | 3389 | DXDEC void AILCALL AIL_set_GTL_filename_prefix (char const*prefix); 3390 | 3391 | DXDEC S32 AILCALL AIL_timbre_status (HMDIDRIVER mdi, 3392 | S32 bank, 3393 | S32 patch); 3394 | 3395 | DXDEC S32 AILCALL AIL_install_timbre (HMDIDRIVER mdi, 3396 | S32 bank, 3397 | S32 patch); 3398 | 3399 | DXDEC void AILCALL AIL_protect_timbre (HMDIDRIVER mdi, 3400 | S32 bank, 3401 | S32 patch); 3402 | 3403 | DXDEC void AILCALL AIL_unprotect_timbre (HMDIDRIVER mdi, 3404 | S32 bank, 3405 | S32 patch); 3406 | 3407 | #endif 3408 | 3409 | #endif 3410 | 3411 | #endif 3412 | 3413 | DXDEC HSEQUENCE AILCALL AIL_allocate_sequence_handle 3414 | (HMDIDRIVER mdi); 3415 | 3416 | DXDEC void AILCALL AIL_release_sequence_handle 3417 | (HSEQUENCE S); 3418 | 3419 | DXDEC S32 AILCALL AIL_init_sequence (HSEQUENCE S, 3420 | void const FAR *start, 3421 | S32 sequence_num); 3422 | 3423 | DXDEC void AILCALL AIL_start_sequence (HSEQUENCE S); 3424 | 3425 | DXDEC void AILCALL AIL_stop_sequence (HSEQUENCE S); 3426 | 3427 | DXDEC void AILCALL AIL_resume_sequence (HSEQUENCE S); 3428 | 3429 | DXDEC void AILCALL AIL_end_sequence (HSEQUENCE S); 3430 | 3431 | DXDEC void AILCALL AIL_set_sequence_tempo (HSEQUENCE S, 3432 | S32 tempo, 3433 | S32 milliseconds); 3434 | 3435 | DXDEC void AILCALL AIL_set_sequence_volume (HSEQUENCE S, 3436 | S32 volume, 3437 | S32 milliseconds); 3438 | 3439 | DXDEC void AILCALL AIL_set_sequence_loop_count 3440 | (HSEQUENCE S, 3441 | S32 loop_count); 3442 | 3443 | DXDEC U32 AILCALL AIL_sequence_status (HSEQUENCE S); 3444 | 3445 | DXDEC S32 AILCALL AIL_sequence_tempo (HSEQUENCE S); 3446 | 3447 | DXDEC S32 AILCALL AIL_sequence_volume (HSEQUENCE S); 3448 | 3449 | DXDEC S32 AILCALL AIL_sequence_loop_count (HSEQUENCE S); 3450 | 3451 | DXDEC void AILCALL AIL_set_XMIDI_master_volume 3452 | (HMDIDRIVER mdi, 3453 | S32 master_volume); 3454 | 3455 | DXDEC S32 AILCALL AIL_XMIDI_master_volume (HMDIDRIVER mdi); 3456 | 3457 | 3458 | // 3459 | // Low-level XMIDI services 3460 | // 3461 | 3462 | DXDEC S32 AILCALL AIL_active_sequence_count (HMDIDRIVER mdi); 3463 | 3464 | DXDEC S32 AILCALL AIL_controller_value (HSEQUENCE S, 3465 | S32 channel, 3466 | S32 controller_num); 3467 | 3468 | DXDEC S32 AILCALL AIL_channel_notes (HSEQUENCE S, 3469 | S32 channel); 3470 | 3471 | DXDEC void AILCALL AIL_sequence_position (HSEQUENCE S, 3472 | S32 FAR *beat, 3473 | S32 FAR *measure); 3474 | 3475 | DXDEC void AILCALL AIL_branch_index (HSEQUENCE S, 3476 | U32 marker); 3477 | 3478 | DXDEC AILPREFIXCB AILCALL AIL_register_prefix_callback 3479 | (HSEQUENCE S, 3480 | AILPREFIXCB callback); 3481 | 3482 | DXDEC AILTRIGGERCB AILCALL AIL_register_trigger_callback 3483 | (HSEQUENCE S, 3484 | AILTRIGGERCB callback); 3485 | 3486 | DXDEC AILSEQUENCECB AILCALL AIL_register_sequence_callback 3487 | (HSEQUENCE S, 3488 | AILSEQUENCECB callback); 3489 | 3490 | DXDEC AILBEATCB AILCALL AIL_register_beat_callback (HSEQUENCE S, 3491 | AILBEATCB callback); 3492 | 3493 | DXDEC AILEVENTCB AILCALL AIL_register_event_callback (HMDIDRIVER mdi, 3494 | AILEVENTCB callback); 3495 | 3496 | DXDEC AILTIMBRECB AILCALL AIL_register_timbre_callback 3497 | (HMDIDRIVER mdi, 3498 | AILTIMBRECB callback); 3499 | 3500 | DXDEC void AILCALL AIL_set_sequence_user_data (HSEQUENCE S, 3501 | U32 index, 3502 | S32 value); 3503 | 3504 | DXDEC S32 AILCALL AIL_sequence_user_data (HSEQUENCE S, 3505 | U32 index); 3506 | 3507 | DXDEC void AILCALL AIL_register_ICA_array (HSEQUENCE S, 3508 | U8 FAR *array); 3509 | 3510 | DXDEC S32 AILCALL AIL_lock_channel (HMDIDRIVER mdi); 3511 | 3512 | DXDEC void AILCALL AIL_release_channel (HMDIDRIVER mdi, 3513 | S32 channel); 3514 | 3515 | DXDEC void AILCALL AIL_map_sequence_channel (HSEQUENCE S, 3516 | S32 seq_channel, 3517 | S32 new_channel); 3518 | 3519 | DXDEC S32 AILCALL AIL_true_sequence_channel (HSEQUENCE S, 3520 | S32 seq_channel); 3521 | 3522 | DXDEC void AILCALL AIL_send_channel_voice_message 3523 | (HMDIDRIVER mdi, 3524 | HSEQUENCE S, 3525 | S32 status, 3526 | S32 data_1, 3527 | S32 data_2); 3528 | 3529 | DXDEC void AILCALL AIL_send_sysex_message (HMDIDRIVER mdi, 3530 | void const FAR *buffer); 3531 | 3532 | DXDEC HWAVESYNTH 3533 | AILCALL AIL_create_wave_synthesizer (HDIGDRIVER dig, 3534 | HMDIDRIVER mdi, 3535 | void const FAR *wave_lib, 3536 | S32 polyphony); 3537 | 3538 | DXDEC void AILCALL AIL_destroy_wave_synthesizer (HWAVESYNTH W); 3539 | 3540 | DXDEC void AILCALL AIL_set_sequence_ms_position (HSEQUENCE S, //) 3541 | S32 milliseconds); 3542 | 3543 | DXDEC void AILCALL AIL_sequence_ms_position(HSEQUENCE S, //) 3544 | S32 FAR *total_milliseconds, 3545 | S32 FAR *current_milliseconds); 3546 | 3547 | 3548 | 3549 | // 3550 | // red book functions 3551 | // 3552 | 3553 | #ifdef IS_DOS 3554 | typedef struct _REDBOOKTRACKINFO { 3555 | U32 tracks; 3556 | U32 trackstarts[100]; 3557 | } REDBOOKTRACKINFO; 3558 | #endif 3559 | 3560 | typedef struct _REDBOOK { 3561 | U32 DeviceID; 3562 | U32 paused; 3563 | U32 pausedsec; 3564 | U32 lastendsec; 3565 | #ifdef IS_DOS 3566 | U32 readcontents; 3567 | REDBOOKTRACKINFO info; 3568 | #endif 3569 | #ifdef IS_MAC 3570 | short vDRefNum; 3571 | #endif 3572 | } REDBOOK; 3573 | 3574 | typedef struct _REDBOOK FAR* HREDBOOK; 3575 | 3576 | #define REDBOOK_ERROR 0 3577 | #define REDBOOK_PLAYING 1 3578 | #define REDBOOK_PAUSED 2 3579 | #define REDBOOK_STOPPED 3 3580 | 3581 | 3582 | DXDEC HREDBOOK AILCALL AIL_redbook_open(U32 which); 3583 | 3584 | #ifdef IS_MAC 3585 | DXDEC HREDBOOK AILCALL AIL_redbook_open_volume(char const * drive); 3586 | #else 3587 | DXDEC HREDBOOK AILCALL AIL_redbook_open_drive(S32 drive); 3588 | #endif 3589 | 3590 | DXDEC void AILCALL AIL_redbook_close(HREDBOOK hand); 3591 | 3592 | DXDEC void AILCALL AIL_redbook_eject(HREDBOOK hand); 3593 | 3594 | DXDEC void AILCALL AIL_redbook_retract(HREDBOOK hand); 3595 | 3596 | DXDEC U32 AILCALL AIL_redbook_status(HREDBOOK hand); 3597 | 3598 | DXDEC U32 AILCALL AIL_redbook_tracks(HREDBOOK hand); 3599 | 3600 | DXDEC U32 AILCALL AIL_redbook_track(HREDBOOK hand); 3601 | 3602 | DXDEC void AILCALL AIL_redbook_track_info(HREDBOOK hand,U32 tracknum, 3603 | U32 FAR* startmsec,U32 FAR* endmsec); 3604 | 3605 | DXDEC U32 AILCALL AIL_redbook_id(HREDBOOK hand); 3606 | 3607 | DXDEC U32 AILCALL AIL_redbook_position(HREDBOOK hand); 3608 | 3609 | DXDEC U32 AILCALL AIL_redbook_play(HREDBOOK hand,U32 startmsec, U32 endmsec); 3610 | 3611 | DXDEC U32 AILCALL AIL_redbook_stop(HREDBOOK hand); 3612 | 3613 | DXDEC U32 AILCALL AIL_redbook_pause(HREDBOOK hand); 3614 | 3615 | DXDEC U32 AILCALL AIL_redbook_resume(HREDBOOK hand); 3616 | 3617 | DXDEC S32 AILCALL AIL_redbook_volume(HREDBOOK hand); 3618 | 3619 | DXDEC S32 AILCALL AIL_redbook_set_volume(HREDBOOK hand, S32 volume); 3620 | 3621 | #ifdef IS_WIN16 3622 | #define AIL_ms_count timeGetTime 3623 | DXDEC U32 AILCALL AIL_us_count(void); 3624 | #else 3625 | DXDEC U32 AILCALL AIL_ms_count(void); 3626 | DXDEC U32 AILCALL AIL_us_count(void); 3627 | #endif 3628 | 3629 | 3630 | typedef struct _STREAM FAR* HSTREAM; // Handle to stream 3631 | 3632 | typedef void (AILCALLBACK FAR* AILSTREAMCB) (HSTREAM stream); 3633 | 3634 | typedef struct _STREAM { 3635 | 3636 | S32 block_oriented; // 1 if this is an ADPCM or ASI-compressed stream 3637 | S32 using_ASI; // 1 if using ASI decoder to uncompress stream data 3638 | ASISTAGE FAR *ASI; // handy pointer to our ASI coded 3639 | 3640 | HSAMPLE samp; // the sample handle 3641 | 3642 | U32 fileh; // the open file handle 3643 | 3644 | U8 FAR* bufs[3]; // the data buffers 3645 | U32 bufsizes[3]; // the size of each buffer 3646 | S32 reset_ASI[3]; // should we reset the ASI at the end of the buffer? 3647 | S32 bufstart[3]; // offset of where this buffer started 3648 | void FAR* asyncs[3];// async read structures 3649 | 3650 | S32 loadedbufstart[2]; // offset of where the loaded buffer started 3651 | S32 loadedorder[2]; // order of the buffers as they were loaded 3652 | S32 loadorder; // incremented as each buffer is loaded 3653 | 3654 | S32 bufsize; // size of each buffer 3655 | S32 readsize; // size of each read block 3656 | 3657 | U32 buf1; // 0,1,2 (current buffer that we are reading into) 3658 | S32 size1; // holds the current amount of data read 3659 | 3660 | U32 buf2; // 0,1,2 (the next buffer that we are reading into) 3661 | S32 size2; // next buffer loaded up to 3662 | 3663 | U32 buf3; // 0,1,2 (the next buffer that we are reading into) 3664 | S32 size3; // next buffer loaded up to 3665 | 3666 | U32 datarate; // datarate in bytes per second 3667 | S32 filerate; // original datarate of the file 3668 | S32 filetype; // file format type 3669 | U32 fileflags; // file format flags (signed or unsigned) 3670 | S32 totallen; // total length of the sound data 3671 | 3672 | S32 substart; // subblock loop start 3673 | S32 sublen; // subblock loop len 3674 | S32 subpadding; // amount to pad the final block 3675 | 3676 | U32 blocksize; // ADPCM block size 3677 | S32 padding; // padding to be done 3678 | S32 padded; // padding done 3679 | 3680 | S32 loadedsome; // have we done any loads? 3681 | 3682 | U32 startpos; // point that the sound data begins 3683 | U32 totalread; // total bytes read from the disk 3684 | 3685 | U32 loopsleft; // how many loops are left 3686 | 3687 | U32 error; // read error has occurred 3688 | 3689 | S32 preload; // preload the file into the first buffer 3690 | U32 preloadpos; // position to use in preload 3691 | S32 noback; // no background processing 3692 | S32 alldone; // alldone 3693 | S32 primeamount; // amount to load after a seek 3694 | S32 readatleast; // forced amount to read on next service 3695 | 3696 | S32 playcontrol; // control: 0=stopped, 1=started, |8=paused, |16=sample paused 3697 | 3698 | AILSTREAMCB callback; // end of stream callback 3699 | 3700 | S32 user_data[8]; // Miscellaneous user data 3701 | void FAR* next; // pointer to next stream 3702 | 3703 | #if defined(IS_WINDOWS) || defined(IS_MAC) 3704 | S32 autostreaming; // are we autostreaming this stream 3705 | #endif 3706 | 3707 | #ifdef IS_WINDOWS 3708 | S32 cb_IsWin32s; // Is the callback win32s? 3709 | #endif 3710 | 3711 | S32 docallback; // set when it time to poll for a callback 3712 | 3713 | #ifdef IS_MAC 3714 | IOParam stream_param; 3715 | S32 donext; 3716 | S32 donext1; 3717 | U32 fillup; 3718 | U32 session; 3719 | U32 tamt; 3720 | U32 buf; 3721 | S32* size; 3722 | S32* done; 3723 | S32 done1; 3724 | S32 done2; 3725 | S32 done3; 3726 | Boolean force_quit; 3727 | #endif 3728 | 3729 | } MSTREAM_TYPE; 3730 | 3731 | 3732 | DXDEC HSTREAM AILCALL AIL_open_stream(HDIGDRIVER dig, char const FAR * filename, S32 stream_mem); 3733 | 3734 | DXDEC void AILCALL AIL_close_stream(HSTREAM stream); 3735 | 3736 | DXDEC S32 AILCALL AIL_service_stream(HSTREAM stream, S32 fillup); 3737 | 3738 | DXDEC void AILCALL AIL_start_stream(HSTREAM stream); 3739 | 3740 | DXDEC void AILCALL AIL_pause_stream(HSTREAM stream, S32 onoff); 3741 | 3742 | DXDEC void AILCALL AIL_set_stream_volume(HSTREAM stream,S32 volume); 3743 | 3744 | DXDEC void AILCALL AIL_set_stream_pan(HSTREAM stream,S32 pan); 3745 | 3746 | DXDEC S32 AILCALL AIL_stream_volume(HSTREAM stream); 3747 | 3748 | DXDEC S32 AILCALL AIL_stream_pan(HSTREAM stream); 3749 | 3750 | DXDEC void AILCALL AIL_set_stream_playback_rate(HSTREAM stream, S32 rate); 3751 | 3752 | DXDEC S32 AILCALL AIL_stream_playback_rate(HSTREAM stream); 3753 | 3754 | DXDEC S32 AILCALL AIL_stream_loop_count(HSTREAM stream); 3755 | 3756 | DXDEC void AILCALL AIL_set_stream_loop_count(HSTREAM stream, S32 count); 3757 | 3758 | DXDEC void AILCALL AIL_set_stream_loop_block (HSTREAM S, 3759 | S32 loop_start_offset, 3760 | S32 loop_end_offset); 3761 | 3762 | DXDEC S32 AILCALL AIL_stream_status(HSTREAM stream); 3763 | 3764 | DXDEC void AILCALL AIL_set_stream_position(HSTREAM stream,S32 offset); 3765 | 3766 | DXDEC S32 AILCALL AIL_stream_position(HSTREAM stream); 3767 | 3768 | DXDEC void AILCALL AIL_stream_info(HSTREAM stream, S32 FAR* datarate, S32 FAR* sndtype, S32 FAR* length, S32 FAR* memory); 3769 | 3770 | DXDEC AILSTREAMCB AILCALL AIL_register_stream_callback(HSTREAM stream, AILSTREAMCB callback); 3771 | 3772 | DXDEC void AILCALL AIL_auto_service_stream(HSTREAM stream, S32 onoff); 3773 | 3774 | DXDEC void AILCALL AIL_set_stream_user_data (HSTREAM S, 3775 | U32 index, 3776 | S32 value); 3777 | 3778 | DXDEC S32 AILCALL AIL_stream_user_data (HSTREAM S, 3779 | U32 index); 3780 | 3781 | DXDEC void AILCALL AIL_set_stream_ms_position (HSTREAM S, 3782 | S32 milliseconds); 3783 | 3784 | DXDEC void AILCALL AIL_stream_ms_position (HSTREAM S, //) 3785 | S32 FAR * total_milliseconds, 3786 | S32 FAR * current_milliseconds); 3787 | 3788 | DXDEC void AILCALL AIL_set_stream_reverb(HSTREAM S, 3789 | F32 reverb_level, 3790 | F32 reverb_reflect_time, 3791 | F32 reverb_decay_time); 3792 | 3793 | DXDEC void AILCALL AIL_stream_reverb (HSTREAM S, 3794 | F32 FAR *reverb_level, 3795 | F32 FAR *reverb_reflect_time, 3796 | F32 FAR *reverb_decay_time); 3797 | 3798 | DXDEC HPROVIDER AILCALL AIL_set_stream_processor (HSTREAM S, 3799 | SAMPLESTAGE pipeline_stage, 3800 | HPROVIDER provider); 3801 | 3802 | #ifdef IS_MAC 3803 | typedef struct MSS_FILE 3804 | { 3805 | S32 file_type; // 0 = char*, 1 = FSSpec* 3806 | void const FAR* file; 3807 | } MSS_FILE; 3808 | #else 3809 | typedef char MSS_FILE; 3810 | #endif 3811 | 3812 | typedef U32 (AILCALLBACK FAR*AIL_file_open_callback) (MSS_FILE const FAR* Filename, 3813 | U32 FAR* FileHandle); 3814 | 3815 | typedef void (AILCALLBACK FAR*AIL_file_close_callback) (U32 FileHandle); 3816 | 3817 | #define AIL_FILE_SEEK_BEGIN 0 3818 | #define AIL_FILE_SEEK_CURRENT 1 3819 | #define AIL_FILE_SEEK_END 2 3820 | 3821 | typedef S32 (AILCALLBACK FAR*AIL_file_seek_callback) (U32 FileHandle, 3822 | S32 Offset, 3823 | U32 Type); 3824 | 3825 | typedef U32 (AILCALLBACK FAR*AIL_file_read_callback) (U32 FileHandle, 3826 | void FAR* Buffer, 3827 | U32 Bytes); 3828 | 3829 | DXDEC void AILCALL AIL_set_file_callbacks (AIL_file_open_callback opencb, 3830 | AIL_file_close_callback closecb, 3831 | AIL_file_seek_callback seekcb, 3832 | AIL_file_read_callback readcb); 3833 | 3834 | #ifdef IS_32 3835 | 3836 | typedef void FAR* (AILCALLBACK FAR*AIL_file_async_read_callback) (U32 FileHandle, 3837 | void FAR* Buffer, 3838 | U32 Bytes); 3839 | 3840 | typedef S32 (AILCALLBACK FAR*AIL_file_async_status_callback) (void FAR* async, 3841 | S32 wait, 3842 | U32 FAR* BytesRead); 3843 | 3844 | DXDEC void AILCALL AIL_set_file_async_callbacks (AIL_file_open_callback opencb, 3845 | AIL_file_close_callback closecb, 3846 | AIL_file_seek_callback seekcb, 3847 | AIL_file_async_read_callback areadcb, 3848 | AIL_file_async_status_callback statuscb); 3849 | 3850 | #endif 3851 | 3852 | // 3853 | // High-level DLS functions 3854 | // 3855 | 3856 | typedef struct _DLSFILEID { 3857 | S32 id; 3858 | struct _DLSFILEID FAR* next; 3859 | } DLSFILEID; 3860 | 3861 | typedef struct _DLSFILEID FAR* HDLSFILEID; 3862 | 3863 | typedef struct _DLSDEVICE { 3864 | void FAR* pGetPref; 3865 | void FAR* pSetPref; 3866 | void FAR* pMSSOpen; 3867 | void FAR* pOpen; 3868 | void FAR* pClose; 3869 | void FAR* pLoadFile; 3870 | void FAR* pLoadMem; 3871 | void FAR* pUnloadFile; 3872 | void FAR* pUnloadAll; 3873 | void FAR* pGetInfo; 3874 | void FAR* pCompact; 3875 | void FAR* pSetAttr; 3876 | S32 DLSHandle; 3877 | U32 format; 3878 | U32 buffer_size; 3879 | void FAR* buffer[2]; 3880 | HSAMPLE sample; 3881 | HMDIDRIVER mdi; 3882 | HDIGDRIVER dig; 3883 | HDLSFILEID first; 3884 | #ifdef IS_WINDOWS 3885 | HMODULE lib; 3886 | #else 3887 | #ifdef IS_DOS 3888 | char FAR* DOSname; 3889 | #endif 3890 | #endif 3891 | } DLSDEVICE; 3892 | 3893 | typedef struct _DLSDEVICE FAR* HDLSDEVICE; 3894 | 3895 | typedef struct _AILDLSINFO { 3896 | char Description[128]; 3897 | S32 MaxDLSMemory; 3898 | S32 CurrentDLSMemory; 3899 | S32 LargestSize; 3900 | S32 GMAvailable; 3901 | S32 GMBankSize; 3902 | } AILDLSINFO; 3903 | 3904 | #ifdef IS_DOS 3905 | 3906 | typedef struct _AILDOSDLS { 3907 | char FAR* description; 3908 | void FAR* pDLSOpen; 3909 | void FAR* pMSSOpen; 3910 | void FAR* pOpen; 3911 | void FAR* pClose; 3912 | void FAR* pLoadFile; 3913 | void FAR* pLoadMem; 3914 | void FAR* pUnloadFile; 3915 | void FAR* pUnloadAll; 3916 | void FAR* pGetInfo; 3917 | void FAR* pCompact; 3918 | void FAR* pSetAttr; 3919 | } AILDOSDLS; 3920 | 3921 | #endif 3922 | 3923 | 3924 | DXDEC HDLSDEVICE AILCALL AIL_DLS_open(HMDIDRIVER mdi, HDIGDRIVER dig, 3925 | #if defined(IS_WINDOWS) || defined(IS_MAC) 3926 | char const FAR * libname, 3927 | #else 3928 | AILDOSDLS const FAR * dosdls, 3929 | #endif 3930 | U32 flags, U32 rate, S32 bits, S32 channels); 3931 | 3932 | // 3933 | // Parameters for the dwFlag used in DLSClose() and flags in AIL_DLS_close 3934 | // 3935 | 3936 | #define RETAIN_DLS_COLLECTION 0x00000001 3937 | #define RETURN_TO_BOOTUP_STATE 0x00000002 3938 | #define RETURN_TO_GM_ONLY_STATE 0x00000004 3939 | #define DLS_COMPACT_MEMORY 0x00000008 3940 | 3941 | DXDEC void AILCALL AIL_DLS_close(HDLSDEVICE dls, U32 flags); 3942 | 3943 | DXDEC HDLSFILEID AILCALL AIL_DLS_load_file(HDLSDEVICE dls, char const FAR* filename, U32 flags); 3944 | 3945 | DXDEC HDLSFILEID AILCALL AIL_DLS_load_memory(HDLSDEVICE dls, void const FAR* memfile, U32 flags); 3946 | 3947 | // 3948 | // other parameters for AIL_DLS_unload 3949 | // 3950 | 3951 | #define AIL_DLS_UNLOAD_MINE 0 3952 | #define AIL_DLS_UNLOAD_ALL ((HDLSFILEID)(U32)(S32)-1) 3953 | 3954 | DXDEC void AILCALL AIL_DLS_unload(HDLSDEVICE dls, HDLSFILEID dlsid); 3955 | 3956 | DXDEC void AILCALL AIL_DLS_compact(HDLSDEVICE dls); 3957 | 3958 | DXDEC void AILCALL AIL_DLS_get_info(HDLSDEVICE dls, AILDLSINFO FAR* info, S32 FAR* PercentCPU); 3959 | 3960 | DXDEC void AILCALL AIL_DLS_set_reverb(HDLSDEVICE dls, 3961 | F32 reverb_level, 3962 | F32 reverb_reflect_time, 3963 | F32 reverb_decay_time); 3964 | 3965 | DXDEC void AILCALL AIL_DLS_get_reverb(HDLSDEVICE dls, 3966 | F32 FAR* reverb_level, 3967 | F32 FAR* reverb_reflect_time, 3968 | F32 FAR* reverb_decay_time); 3969 | 3970 | DXDEC HPROVIDER AILCALL AIL_set_DLS_processor (HDLSDEVICE dev, 3971 | SAMPLESTAGE pipeline_stage, 3972 | HPROVIDER provider); 3973 | 3974 | 3975 | // 3976 | // Quick-integration service functions and data types 3977 | // 3978 | 3979 | typedef struct 3980 | { 3981 | U32 const FAR *data; 3982 | S32 size; 3983 | S32 type; 3984 | void FAR *handle; 3985 | S32 status; 3986 | void FAR* next; 3987 | S32 speed; 3988 | S32 volume; 3989 | S32 extravol; 3990 | F32 rlevel; 3991 | F32 rrtime; 3992 | F32 rdtime; 3993 | HDLSFILEID dlsid; 3994 | void FAR* dlsmem; 3995 | void FAR* dlsmemunc; 3996 | S32 milliseconds; 3997 | S32 length; 3998 | S32 userdata; 3999 | } 4000 | AUDIO_TYPE; 4001 | 4002 | 4003 | #define QSTAT_DONE 1 // Data has finished playing 4004 | #define QSTAT_LOADED 2 // Data has been loaded, but not yet played 4005 | #define QSTAT_PLAYING 3 // Data is currently playing 4006 | 4007 | typedef AUDIO_TYPE FAR * HAUDIO; // Generic handle to any audio data type 4008 | 4009 | #define AIL_QUICK_USE_WAVEOUT 2 4010 | #define AIL_QUICK_MIDI_AND_DLS 2 4011 | #define AIL_QUICK_DLS_ONLY 3 4012 | #define AIL_QUICK_MIDI_AND_VORTEX_DLS 4 4013 | #define AIL_QUICK_MIDI_AND_SONICVIBES_DLS 5 4014 | 4015 | DXDEC S32 AILCALL 4016 | #if defined(IS_WINDOWS) || defined(IS_MAC) 4017 | AIL_quick_startup ( 4018 | #else 4019 | AIL_quick_startup_with_start(void* startup, 4020 | #endif 4021 | S32 use_digital, 4022 | S32 use_MIDI, 4023 | U32 output_rate, 4024 | S32 output_bits, 4025 | S32 output_channels); 4026 | 4027 | DXDEC void AILCALL AIL_quick_shutdown (void); 4028 | 4029 | DXDEC void AILCALL AIL_quick_handles (HDIGDRIVER FAR* pdig, 4030 | HMDIDRIVER FAR* pmdi, 4031 | HDLSDEVICE FAR* pdls ); 4032 | 4033 | DXDEC HAUDIO AILCALL AIL_quick_load (char const FAR *filename); 4034 | 4035 | #ifdef IS_MAC 4036 | DXDEC HAUDIO AILCALL AIL_quick_fss_load (FSSpec const FAR *filename); 4037 | #endif 4038 | 4039 | DXDEC HAUDIO AILCALL AIL_quick_load_mem (void const FAR *mem, 4040 | U32 size); 4041 | 4042 | DXDEC HAUDIO AILCALL AIL_quick_copy (HAUDIO audio); 4043 | 4044 | DXDEC void AILCALL AIL_quick_unload (HAUDIO audio); 4045 | 4046 | DXDEC S32 AILCALL AIL_quick_play (HAUDIO audio, 4047 | U32 loop_count); 4048 | 4049 | DXDEC void AILCALL AIL_quick_halt (HAUDIO audio); 4050 | 4051 | DXDEC S32 AILCALL AIL_quick_status (HAUDIO audio); 4052 | 4053 | DXDEC HAUDIO AILCALL AIL_quick_load_and_play (char const FAR *filename, 4054 | U32 loop_count, 4055 | S32 wait_request); 4056 | 4057 | #ifdef IS_MAC 4058 | DXDEC HAUDIO AILCALL AIL_quick_fss_load_and_play (FSSpec const FAR *filename, 4059 | U32 loop_count, 4060 | S32 wait_request); 4061 | #endif 4062 | 4063 | DXDEC void AILCALL AIL_quick_set_speed (HAUDIO audio, S32 speed); 4064 | 4065 | DXDEC void AILCALL AIL_quick_set_volume (HAUDIO audio, S32 volume, S32 extravol); 4066 | 4067 | DXDEC void AILCALL AIL_quick_set_reverb (HAUDIO audio, 4068 | F32 reverb_level, 4069 | F32 reverb_reflect_time, 4070 | F32 reverb_decay_time); 4071 | 4072 | DXDEC void AILCALL AIL_quick_set_ms_position(HAUDIO audio,S32 milliseconds); 4073 | 4074 | DXDEC S32 AILCALL AIL_quick_ms_position(HAUDIO audio); 4075 | 4076 | DXDEC S32 AILCALL AIL_quick_ms_length(HAUDIO audio); 4077 | 4078 | 4079 | #define AIL_QUICK_XMIDI_TYPE 1 4080 | #define AIL_QUICK_DIGITAL_TYPE 2 4081 | #define AIL_QUICK_DLS_XMIDI_TYPE 3 4082 | #define AIL_QUICK_MPEG_DIGITAL_TYPE 4 4083 | 4084 | DXDEC S32 AILCALL AIL_quick_type(HAUDIO audio); 4085 | 4086 | // 4087 | // used for AIL_process 4088 | // 4089 | 4090 | typedef struct _AILMIXINFO { 4091 | AILSOUNDINFO Info; 4092 | ADPCMDATA mss_adpcm; 4093 | U32 src_fract; 4094 | S32 left_val; 4095 | S32 right_val; 4096 | } AILMIXINFO; 4097 | 4098 | 4099 | 4100 | DXDEC S32 AILCALL AIL_WAV_info(void const FAR* data, AILSOUNDINFO FAR* info); 4101 | 4102 | DXDEC S32 AILCALL AIL_size_processed_digital_audio( 4103 | U32 dest_rate, 4104 | U32 dest_format, 4105 | S32 num_srcs, 4106 | AILMIXINFO const FAR* src); 4107 | 4108 | DXDEC S32 AILCALL AIL_process_digital_audio( 4109 | void FAR *dest_buffer, 4110 | S32 dest_buffer_size, 4111 | U32 dest_rate, 4112 | U32 dest_format, 4113 | S32 num_srcs, 4114 | AILMIXINFO FAR* src); 4115 | 4116 | #define AIL_LENGTHY_INIT 0 4117 | #define AIL_LENGTHY_SET_PREFERENCE 1 4118 | #define AIL_LENGTHY_UPDATE 2 4119 | #define AIL_LENGTHY_DONE 3 4120 | 4121 | typedef S32 (AILCALLBACK FAR* AILLENGTHYCB)(U32 state,U32 user); 4122 | 4123 | typedef S32 (AILCALLBACK FAR* AILCODECSETPREF)(char const FAR* preference,U32 value); 4124 | 4125 | DXDEC S32 AILCALL AIL_compress_ASI(AILSOUNDINFO const FAR * info, //) 4126 | char const FAR* filename_ext, 4127 | void FAR* FAR* outdata, 4128 | U32 FAR* outsize, 4129 | AILLENGTHYCB callback); 4130 | 4131 | DXDEC S32 AILCALL AIL_decompress_ASI(void const FAR* indata, //) 4132 | U32 insize, 4133 | char const FAR* filename_ext, 4134 | void FAR* FAR* wav, 4135 | U32 FAR* wavsize, 4136 | AILLENGTHYCB callback); 4137 | 4138 | DXDEC S32 AILCALL AIL_compress_ADPCM(AILSOUNDINFO const FAR * info, 4139 | void FAR* FAR* outdata, U32 FAR* outsize); 4140 | 4141 | DXDEC S32 AILCALL AIL_decompress_ADPCM(AILSOUNDINFO const FAR * info, 4142 | void FAR* FAR* outdata, U32 FAR* outsize); 4143 | 4144 | DXDEC S32 AILCALL AIL_compress_DLS(void const FAR* dls, 4145 | char const FAR* compression_extension, 4146 | void FAR* FAR* mls, U32 FAR* mlssize, 4147 | AILLENGTHYCB callback); 4148 | 4149 | DXDEC S32 AILCALL AIL_merge_DLS_with_XMI(void const FAR* xmi, void const FAR* dls, 4150 | void FAR* FAR* mss, U32 FAR* msssize); 4151 | 4152 | DXDEC S32 AILCALL AIL_extract_DLS( void const FAR *source_image, //) 4153 | U32 source_size, 4154 | void FAR * FAR *XMI_output_data, 4155 | U32 FAR *XMI_output_size, 4156 | void FAR * FAR *DLS_output_data, 4157 | U32 FAR *DLS_output_size, 4158 | AILLENGTHYCB callback); 4159 | 4160 | #define AILFILTERDLS_USINGLIST 1 4161 | 4162 | DXDEC S32 AILCALL AIL_filter_DLS_with_XMI(void const FAR* xmi, void const FAR* dls, 4163 | void FAR* FAR* dlsout, U32 FAR* dlssize, 4164 | S32 flags, AILLENGTHYCB callback); 4165 | 4166 | #define AILMIDITOXMI_USINGLIST 1 4167 | #define AILMIDITOXMI_TOLERANT 2 4168 | 4169 | DXDEC S32 AILCALL AIL_MIDI_to_XMI (void const FAR* MIDI, 4170 | U32 MIDI_size, 4171 | void FAR* FAR*XMIDI, 4172 | U32 FAR* XMIDI_size, 4173 | S32 flags); 4174 | 4175 | #define AILMIDILIST_ROLANDSYSEX 1 4176 | #define AILMIDILIST_ROLANDUN 2 4177 | #define AILMIDILIST_ROLANDAB 4 4178 | 4179 | DXDEC S32 AILCALL AIL_list_MIDI (void const FAR* MIDI, 4180 | U32 MIDI_size, 4181 | char FAR* FAR* lst, 4182 | U32 FAR* lst_size, 4183 | S32 flags); 4184 | #define AILDLSLIST_ARTICULATION 1 4185 | #define AILDLSLIST_DUMP_WAVS 2 4186 | 4187 | DXDEC S32 AILCALL AIL_list_DLS (void const FAR* DLS, 4188 | char FAR* FAR* lst, 4189 | U32 FAR* lst_size, 4190 | S32 flags, 4191 | C8 FAR* title); 4192 | 4193 | #define AILFILETYPE_UNKNOWN 0 4194 | #define AILFILETYPE_PCM_WAV 1 4195 | #define AILFILETYPE_ADPCM_WAV 2 4196 | #define AILFILETYPE_OTHER_WAV 3 4197 | #define AILFILETYPE_VOC 4 4198 | #define AILFILETYPE_MIDI 5 4199 | #define AILFILETYPE_XMIDI 6 4200 | #define AILFILETYPE_XMIDI_DLS 7 4201 | #define AILFILETYPE_XMIDI_MLS 8 4202 | #define AILFILETYPE_DLS 9 4203 | #define AILFILETYPE_MLS 10 4204 | #define AILFILETYPE_MPEG_L1_AUDIO 11 4205 | #define AILFILETYPE_MPEG_L2_AUDIO 12 4206 | #define AILFILETYPE_MPEG_L3_AUDIO 13 4207 | #define AILFILETYPE_OTHER_ASI_WAV 14 4208 | 4209 | 4210 | DXDEC S32 AILCALL AIL_file_type(void const FAR* data, U32 size); 4211 | 4212 | DXDEC S32 AILCALL AIL_find_DLS (void const FAR* data, U32 size, 4213 | void FAR* FAR* xmi, U32 FAR* xmisize, 4214 | void FAR* FAR* dls, U32 FAR* dlssize); 4215 | 4216 | #if defined(IS_WIN32) || defined(IS_MAC) 4217 | 4218 | // 4219 | // Auxiliary 2D interface calls 4220 | // 4221 | 4222 | DXDEC HDIGDRIVER AILCALL AIL_primary_digital_driver (HDIGDRIVER new_primary); 4223 | 4224 | // 4225 | // Filter result codes 4226 | // 4227 | 4228 | typedef S32 FLTRESULT; 4229 | 4230 | #define FLT_NOERR 0 // Success -- no error 4231 | #define FLT_NOT_ENABLED 1 // FLT not enabled 4232 | #define FLT_ALREADY_STARTED 2 // FLT already started 4233 | #define FLT_INVALID_PARAM 3 // Invalid parameters used 4234 | #define FLT_INTERNAL_ERR 4 // Internal error in FLT driver 4235 | #define FLT_OUT_OF_MEM 5 // Out of system RAM 4236 | #define FLT_ERR_NOT_IMPLEMENTED 6 // Feature not implemented 4237 | #define FLT_NOT_FOUND 7 // FLT supported device not found 4238 | #define FLT_NOT_INIT 8 // FLT not initialized 4239 | #define FLT_CLOSE_ERR 9 // FLT not closed correctly 4240 | 4241 | //############################################################################ 4242 | //## ## 4243 | //## Interface "MSS pipeline filter" ## 4244 | //## ## 4245 | //############################################################################ 4246 | 4247 | typedef FLTRESULT (AILCALL FAR *FLT_STARTUP)(void); 4248 | 4249 | typedef FLTRESULT (AILCALL FAR *FLT_SHUTDOWN)(void); 4250 | 4251 | typedef C8 FAR * (AILCALL FAR *FLT_ERROR)(void); 4252 | 4253 | typedef S32 (AILCALL FAR *FLT_SET_PROVIDER_PREFERENCE)(HATTRIB preference, 4254 | void const FAR* value); 4255 | 4256 | typedef HDRIVERSTATE (AILCALL FAR *FLT_OPEN_DRIVER) (HDIGDRIVER dig, 4257 | S32 FAR *build_buffer, 4258 | S32 build_buffer_size); 4259 | 4260 | typedef FLTRESULT (AILCALL FAR *FLT_CLOSE_DRIVER) (HDRIVERSTATE state); 4261 | 4262 | typedef void (AILCALL FAR *FLT_PREMIX_PROCESS) (HDRIVERSTATE driver 4263 | #ifdef IS_MAC 4264 | ,U32 buffer_size 4265 | #endif 4266 | ); 4267 | 4268 | typedef void (AILCALL FAR *FLT_POSTMIX_PROCESS) (HDRIVERSTATE driver 4269 | #ifdef IS_MAC 4270 | ,U32 buffer_size 4271 | #endif 4272 | ); 4273 | 4274 | //############################################################################ 4275 | //## ## 4276 | //## Interface "Pipeline filter sample services" ## 4277 | //## ## 4278 | //############################################################################ 4279 | 4280 | typedef HSAMPLESTATE (AILCALL FAR * FLTSMP_OPEN_SAMPLE) (HDRIVERSTATE driver, 4281 | HSAMPLE S); 4282 | 4283 | typedef FLTRESULT (AILCALL FAR * FLTSMP_CLOSE_SAMPLE) (HSAMPLESTATE state); 4284 | 4285 | typedef S32 (AILCALL FAR * FLTSMP_SAMPLE_PROCESS) (HSAMPLESTATE state, 4286 | void const FAR * FAR *orig_src, 4287 | U32 FAR * orig_src_fract, 4288 | void FAR * orig_src_end, 4289 | S32 FAR * FAR *build_dest, 4290 | void FAR * build_dest_end, 4291 | S32 FAR * left_val, 4292 | S32 FAR * right_val, 4293 | S32 playback_ratio, 4294 | S32 left_scale, 4295 | S32 right_scale, 4296 | S32 base_scale, 4297 | MIXSTAGE FAR * mixer_provider, 4298 | U32 mixer_operation); 4299 | 4300 | typedef S32 (AILCALL FAR * FLTSMP_SAMPLE_ATTRIBUTE) (HSAMPLESTATE state, 4301 | HATTRIB attribute); 4302 | 4303 | typedef S32 (AILCALL FAR * FLTSMP_SET_SAMPLE_PREFERENCE) (HSAMPLESTATE state, 4304 | HATTRIB preference, 4305 | void const FAR* value); 4306 | 4307 | // 4308 | // Pipeline filter calls 4309 | // 4310 | 4311 | DXDEC S32 AILCALL AIL_enumerate_filters (HPROENUM FAR *next, 4312 | HPROVIDER FAR *dest, 4313 | C8 FAR * FAR *name); 4314 | 4315 | DXDEC HDRIVERSTATE 4316 | AILCALL AIL_open_filter (HPROVIDER lib, 4317 | HDIGDRIVER dig); 4318 | 4319 | DXDEC void AILCALL AIL_close_filter (HDRIVERSTATE filter); 4320 | 4321 | DXDEC S32 AILCALL AIL_enumerate_filter_attributes 4322 | (HPROVIDER lib, 4323 | HINTENUM FAR * next, 4324 | RIB_INTERFACE_ENTRY FAR * dest); 4325 | 4326 | DXDEC void AILCALL AIL_filter_attribute (HPROVIDER lib, 4327 | C8 const FAR* name, 4328 | void FAR * val); 4329 | 4330 | DXDEC void AILCALL AIL_set_filter_preference 4331 | (HPROVIDER lib, 4332 | C8 const FAR* name, 4333 | void const FAR* val); 4334 | 4335 | DXDEC S32 AILCALL AIL_enumerate_filter_sample_attributes 4336 | (HPROVIDER lib, 4337 | HINTENUM FAR * next, 4338 | RIB_INTERFACE_ENTRY FAR * dest); 4339 | 4340 | DXDEC void AILCALL AIL_filter_sample_attribute 4341 | (HSAMPLE S, 4342 | C8 const FAR* name, 4343 | void FAR * val); 4344 | 4345 | DXDEC void AILCALL AIL_filter_stream_attribute 4346 | (HSTREAM S, 4347 | C8 const FAR* name, 4348 | void FAR* val); 4349 | 4350 | DXDEC void AILCALL AIL_filter_DLS_attribute 4351 | (HDLSDEVICE dls, 4352 | C8 const FAR* name, 4353 | void FAR * val); 4354 | 4355 | DXDEC void AILCALL AIL_set_filter_sample_preference 4356 | (HSAMPLE S, 4357 | C8 const FAR * name, 4358 | void const FAR * val); 4359 | 4360 | DXDEC void AILCALL AIL_set_filter_stream_preference 4361 | (HSTREAM S, 4362 | C8 const FAR * name, 4363 | void const FAR * val); 4364 | 4365 | DXDEC void AILCALL AIL_set_filter_DLS_preference 4366 | (HDLSDEVICE dls, 4367 | C8 const FAR * name, 4368 | void const FAR * val); 4369 | 4370 | typedef struct _FLTPROVIDER 4371 | { 4372 | PROVIDER_QUERY_ATTRIBUTE PROVIDER_query_attribute; 4373 | 4374 | FLT_STARTUP startup; 4375 | FLT_ERROR error; 4376 | FLT_SHUTDOWN shutdown; 4377 | FLT_SET_PROVIDER_PREFERENCE set_provider_preference; 4378 | FLT_OPEN_DRIVER open_driver; 4379 | FLT_CLOSE_DRIVER close_driver; 4380 | FLT_PREMIX_PROCESS premix_process; 4381 | FLT_POSTMIX_PROCESS postmix_process; 4382 | 4383 | FLTSMP_OPEN_SAMPLE open_sample; 4384 | FLTSMP_CLOSE_SAMPLE close_sample; 4385 | FLTSMP_SAMPLE_PROCESS sample_process; 4386 | FLTSMP_SAMPLE_ATTRIBUTE sample_attribute; 4387 | FLTSMP_SET_SAMPLE_PREFERENCE set_sample_preference; 4388 | 4389 | HDIGDRIVER dig; 4390 | HPROVIDER provider; 4391 | HDRIVERSTATE driver_state; 4392 | 4393 | struct _FLTPROVIDER FAR *next; 4394 | } 4395 | FLTPROVIDER; 4396 | 4397 | // 4398 | // 3D provider calls 4399 | // 4400 | 4401 | DXDEC S32 AILCALL AIL_enumerate_3D_providers (HPROENUM FAR *next, 4402 | HPROVIDER FAR *dest, 4403 | C8 FAR * FAR *name); 4404 | 4405 | DXDEC M3DRESULT AILCALL AIL_open_3D_provider (HPROVIDER lib); 4406 | 4407 | DXDEC void AILCALL AIL_close_3D_provider (HPROVIDER lib); 4408 | 4409 | DXDEC S32 AILCALL AIL_enumerate_3D_provider_attributes 4410 | (HPROVIDER lib, 4411 | HINTENUM FAR * next, 4412 | RIB_INTERFACE_ENTRY FAR * dest); 4413 | 4414 | DXDEC void AILCALL AIL_3D_provider_attribute (HPROVIDER lib, 4415 | C8 const FAR* name, 4416 | void FAR * val); 4417 | 4418 | DXDEC void AILCALL AIL_set_3D_provider_preference(HPROVIDER lib, 4419 | C8 const FAR* name, 4420 | void const FAR* val); 4421 | 4422 | struct H3D 4423 | { 4424 | H3DPOBJECT actual; 4425 | HPROVIDER owner; 4426 | S32 user_data[8]; 4427 | }; 4428 | 4429 | typedef struct _M3DPROVIDER 4430 | { 4431 | PROVIDER_QUERY_ATTRIBUTE PROVIDER_query_attribute; 4432 | M3D_STARTUP startup; 4433 | M3D_ERROR error; 4434 | M3D_SHUTDOWN shutdown; 4435 | M3D_SET_PROVIDER_PREFERENCE set_provider_preference; 4436 | M3D_ACTIVATE activate; 4437 | M3D_ALLOCATE_3D_SAMPLE_HANDLE allocate_3D_sample_handle; 4438 | M3D_RELEASE_3D_SAMPLE_HANDLE release_3D_sample_handle; 4439 | M3D_START_3D_SAMPLE start_3D_sample; 4440 | M3D_STOP_3D_SAMPLE stop_3D_sample; 4441 | M3D_RESUME_3D_SAMPLE resume_3D_sample; 4442 | M3D_END_3D_SAMPLE end_3D_sample; 4443 | M3D_SET_3D_SAMPLE_DATA set_3D_sample_data; 4444 | M3D_SET_3D_SAMPLE_VOLUME set_3D_sample_volume; 4445 | M3D_SET_3D_SAMPLE_PLAYBACK_RATE set_3D_sample_playback_rate; 4446 | M3D_SET_3D_SAMPLE_OFFSET set_3D_sample_offset; 4447 | M3D_SET_3D_SAMPLE_LOOP_COUNT set_3D_sample_loop_count; 4448 | M3D_SET_3D_SAMPLE_LOOP_BLOCK set_3D_sample_loop_block; 4449 | M3D_3D_SAMPLE_STATUS sample_status; 4450 | M3D_3D_SAMPLE_VOLUME sample_volume; 4451 | M3D_3D_SAMPLE_PLAYBACK_RATE sample_playback_rate; 4452 | M3D_3D_SAMPLE_OFFSET sample_offset; 4453 | M3D_3D_SAMPLE_LENGTH sample_length; 4454 | M3D_3D_SAMPLE_LOOP_COUNT sample_loop_count; 4455 | M3D_SET_3D_SAMPLE_DISTANCES set_3D_sample_distances; 4456 | M3D_3D_SAMPLE_DISTANCES sample_distances; 4457 | M3D_ACTIVE_3D_SAMPLE_COUNT active_3D_sample_count; 4458 | M3D_3D_OPEN_LISTENER open_listener; 4459 | M3D_3D_CLOSE_LISTENER close_listener; 4460 | M3D_3D_OPEN_OBJECT open_object; 4461 | M3D_3D_CLOSE_OBJECT close_object; 4462 | M3D_SET_3D_POSITION set_3D_position; 4463 | M3D_SET_3D_VELOCITY set_3D_velocity; 4464 | M3D_SET_3D_VELOCITY_VECTOR set_3D_velocity_vector; 4465 | M3D_SET_3D_ORIENTATION set_3D_orientation; 4466 | M3D_3D_POSITION position; 4467 | M3D_3D_VELOCITY velocity; 4468 | M3D_3D_ORIENTATION orientation; 4469 | M3D_3D_UPDATE_POSITION update_position; 4470 | M3D_3D_AUTO_UPDATE_POSITION auto_update_position; 4471 | M3D_3D_SAMPLE_ATTRIBUTE sample_query_attribute; 4472 | M3D_3D_SET_SAMPLE_PREFERENCE set_sample_preference; 4473 | M3D_3D_ROOM_TYPE room_type; 4474 | M3D_SET_3D_ROOM_TYPE set_3D_room_type; 4475 | M3D_3D_SPEAKER_TYPE speaker_type; 4476 | M3D_SET_3D_SPEAKER_TYPE set_3D_speaker_type; 4477 | M3D_SET_3D_SAMPLE_OBSTRUCTION set_3D_sample_obstruction; 4478 | M3D_SET_3D_SAMPLE_OCCLUSION set_3D_sample_occlusion; 4479 | M3D_SET_3D_SAMPLE_CONE set_3D_sample_cone; 4480 | M3D_SET_3D_SAMPLE_EFFECTS_LEVEL set_3D_sample_effects_level; 4481 | M3D_3D_SAMPLE_OBSTRUCTION sample_obstruction; 4482 | M3D_3D_SAMPLE_OCCLUSION sample_occlusion; 4483 | M3D_3D_SAMPLE_CONE sample_cone; 4484 | M3D_3D_SAMPLE_EFFECTS_LEVEL sample_effects_level; 4485 | M3D_SET_3D_EOS set_3D_EOS; 4486 | } M3DPROVIDER; 4487 | 4488 | // 4489 | // Sample calls 4490 | // 4491 | 4492 | DXDEC H3DSAMPLE AILCALL AIL_allocate_3D_sample_handle 4493 | (HPROVIDER lib); 4494 | 4495 | 4496 | DXDEC void AILCALL AIL_release_3D_sample_handle 4497 | (H3DSAMPLE S); 4498 | 4499 | 4500 | DXDEC void AILCALL AIL_start_3D_sample (H3DSAMPLE S); 4501 | 4502 | 4503 | DXDEC void AILCALL AIL_stop_3D_sample (H3DSAMPLE S); 4504 | 4505 | 4506 | DXDEC void AILCALL AIL_resume_3D_sample (H3DSAMPLE S); 4507 | 4508 | DXDEC void AILCALL AIL_end_3D_sample (H3DSAMPLE S); 4509 | 4510 | DXDEC S32 AILCALL AIL_set_3D_sample_file (H3DSAMPLE S, 4511 | void const FAR*file_image); 4512 | 4513 | DXDEC S32 AILCALL AIL_set_3D_sample_info (H3DSAMPLE S, 4514 | AILSOUNDINFO const FAR*info); 4515 | 4516 | DXDEC void AILCALL AIL_set_3D_sample_volume (H3DSAMPLE S, 4517 | S32 volume); 4518 | 4519 | DXDEC void AILCALL AIL_set_3D_sample_offset (H3DSAMPLE S, 4520 | U32 offset); 4521 | 4522 | DXDEC void AILCALL AIL_set_3D_sample_playback_rate 4523 | (H3DSAMPLE S, 4524 | S32 playback_rate); 4525 | 4526 | DXDEC void AILCALL AIL_set_3D_sample_loop_count(H3DSAMPLE S, 4527 | U32 loops); 4528 | 4529 | DXDEC void AILCALL AIL_set_3D_sample_loop_block(H3DSAMPLE S, 4530 | S32 loop_start_offset, 4531 | S32 loop_end_offset); 4532 | 4533 | DXDEC U32 AILCALL AIL_3D_sample_status (H3DSAMPLE S); 4534 | 4535 | DXDEC S32 AILCALL AIL_3D_sample_volume (H3DSAMPLE S); 4536 | 4537 | DXDEC U32 AILCALL AIL_3D_sample_offset (H3DSAMPLE S); 4538 | 4539 | DXDEC S32 AILCALL AIL_3D_sample_playback_rate (H3DSAMPLE S); 4540 | 4541 | DXDEC U32 AILCALL AIL_3D_sample_length (H3DSAMPLE S); 4542 | 4543 | DXDEC U32 AILCALL AIL_3D_sample_loop_count (H3DSAMPLE S); 4544 | 4545 | 4546 | DXDEC S32 AILCALL AIL_3D_room_type (HPROVIDER lib); 4547 | 4548 | DXDEC void AILCALL AIL_set_3D_room_type (HPROVIDER lib, 4549 | S32 room_type); 4550 | 4551 | #define AIL_3D_2_SPEAKER 0 4552 | #define AIL_3D_HEADPHONE 1 4553 | #define AIL_3D_SURROUND 2 4554 | #define AIL_3D_4_SPEAKER 3 4555 | 4556 | 4557 | DXDEC S32 AILCALL AIL_3D_speaker_type (HPROVIDER lib); 4558 | 4559 | DXDEC void AILCALL AIL_set_3D_speaker_type (HPROVIDER lib, 4560 | S32 speaker_type); 4561 | 4562 | 4563 | // 4564 | // Changed the definition of distances to only be max and min, vs. front 4565 | // min/max and back min/max. Only RSX supported the concept of different 4566 | // front and distances, so we changed the API to make it more orthogonal 4567 | // to most of the 3D providers. Sorry in advance. 4568 | // 4569 | 4570 | DXDEC void AILCALL AIL_set_3D_sample_distances (H3DSAMPLE S, 4571 | F32 max_dist, 4572 | F32 min_dist); 4573 | 4574 | 4575 | DXDEC void AILCALL AIL_3D_sample_distances (H3DSAMPLE S, 4576 | F32 FAR * max_dist, 4577 | F32 FAR * min_dist); 4578 | 4579 | DXDEC S32 AILCALL AIL_active_3D_sample_count (HPROVIDER lib); 4580 | 4581 | DXDEC S32 AILCALL AIL_enumerate_3D_sample_attributes 4582 | (HPROVIDER lib, 4583 | HINTENUM FAR * next, 4584 | RIB_INTERFACE_ENTRY FAR * dest); 4585 | 4586 | DXDEC void AILCALL AIL_3D_sample_attribute (H3DSAMPLE samp, 4587 | C8 const FAR* name, 4588 | void FAR * val); 4589 | 4590 | 4591 | DXDEC void AILCALL AIL_set_3D_sample_preference (H3DSAMPLE samp, 4592 | C8 const FAR* name, 4593 | void const FAR* val); 4594 | 4595 | DXDEC void AILCALL AIL_set_3D_sample_obstruction (H3DSAMPLE S, 4596 | F32 obstruction); 4597 | 4598 | DXDEC void AILCALL AIL_set_3D_sample_occlusion (H3DSAMPLE S, 4599 | F32 occlusion); 4600 | 4601 | DXDEC void AILCALL AIL_set_3D_sample_cone (H3DSAMPLE S, 4602 | F32 inner_angle, 4603 | F32 outer_angle, 4604 | S32 outer_volume); 4605 | 4606 | DXDEC void AILCALL AIL_set_3D_sample_effects_level 4607 | (H3DSAMPLE S, 4608 | F32 effects_level); 4609 | 4610 | DXDEC F32 AILCALL AIL_3D_sample_obstruction (H3DSAMPLE S); 4611 | 4612 | DXDEC F32 AILCALL AIL_3D_sample_occlusion (H3DSAMPLE S); 4613 | 4614 | DXDEC void AILCALL AIL_3D_sample_cone (H3DSAMPLE S, 4615 | F32 FAR* inner_angle, 4616 | F32 FAR* outer_angle, 4617 | S32 FAR* outer_volume); 4618 | 4619 | DXDEC F32 AILCALL AIL_3D_sample_effects_level (H3DSAMPLE S); 4620 | 4621 | 4622 | DXDEC AIL3DSAMPLECB AILCALL AIL_register_3D_EOS_callback 4623 | (H3DSAMPLE S, 4624 | AIL3DSAMPLECB EOS); 4625 | 4626 | 4627 | // 4628 | // Positioning-object allocation calls 4629 | // 4630 | 4631 | DXDEC H3DPOBJECT AILCALL AIL_open_3D_listener (HPROVIDER lib); 4632 | 4633 | DXDEC void AILCALL AIL_close_3D_listener (H3DPOBJECT listener); 4634 | 4635 | DXDEC H3DPOBJECT AILCALL AIL_open_3D_object (HPROVIDER lib); 4636 | 4637 | DXDEC void AILCALL AIL_close_3D_object (H3DPOBJECT obj); 4638 | 4639 | // 4640 | // 3D object calls 4641 | // 4642 | 4643 | DXDEC void AILCALL AIL_set_3D_position (H3DPOBJECT obj, 4644 | F32 X, 4645 | F32 Y, 4646 | F32 Z); 4647 | 4648 | DXDEC void AILCALL AIL_set_3D_velocity (H3DPOBJECT obj, 4649 | F32 dX_per_ms, 4650 | F32 dY_per_ms, 4651 | F32 dZ_per_ms, 4652 | F32 magnitude); 4653 | 4654 | DXDEC void AILCALL AIL_set_3D_velocity_vector (H3DPOBJECT obj, 4655 | F32 dX_per_ms, 4656 | F32 dY_per_ms, 4657 | F32 dZ_per_ms); 4658 | 4659 | DXDEC void AILCALL AIL_set_3D_orientation (H3DPOBJECT obj, 4660 | F32 X_face, 4661 | F32 Y_face, 4662 | F32 Z_face, 4663 | F32 X_up, 4664 | F32 Y_up, 4665 | F32 Z_up); 4666 | 4667 | DXDEC void AILCALL AIL_3D_position (H3DPOBJECT obj, 4668 | F32 FAR *X, 4669 | F32 FAR *Y, 4670 | F32 FAR *Z); 4671 | 4672 | DXDEC void AILCALL AIL_3D_velocity (H3DPOBJECT obj, 4673 | F32 FAR *dX_per_ms, 4674 | F32 FAR *dY_per_ms, 4675 | F32 FAR *dZ_per_ms); 4676 | 4677 | DXDEC void AILCALL AIL_3D_orientation (H3DPOBJECT obj, 4678 | F32 FAR *X_face, 4679 | F32 FAR *Y_face, 4680 | F32 FAR *Z_face, 4681 | F32 FAR *X_up, 4682 | F32 FAR *Y_up, 4683 | F32 FAR *Z_up); 4684 | 4685 | DXDEC void AILCALL AIL_update_3D_position (H3DPOBJECT obj, 4686 | F32 dt_milliseconds); 4687 | 4688 | DXDEC void AILCALL AIL_auto_update_3D_position (H3DPOBJECT obj, 4689 | S32 enable); 4690 | 4691 | DXDEC void AILCALL AIL_set_3D_user_data (H3DPOBJECT obj, 4692 | U32 index, 4693 | S32 value); 4694 | 4695 | DXDEC S32 AILCALL AIL_3D_user_data (H3DPOBJECT obj, 4696 | U32 index); 4697 | 4698 | // Obsolete 3D function names: 4699 | #define AIL_set_3D_object_user_data AIL_set_3D_user_data 4700 | #define AIL_3D_object_user_data AIL_3D_user_data 4701 | #define AIL_3D_open_listener AIL_open_3D_listener 4702 | #define AIL_3D_close_listener AIL_close_3D_listener 4703 | #define AIL_3D_open_object AIL_open_3D_object 4704 | #define AIL_3D_close_object AIL_close_3D_object 4705 | 4706 | // 4707 | // RAD room types - currently the same as EAX 4708 | // 4709 | 4710 | enum 4711 | { 4712 | ENVIRONMENT_GENERIC, // factory default 4713 | ENVIRONMENT_PADDEDCELL, 4714 | ENVIRONMENT_ROOM, // standard environments 4715 | ENVIRONMENT_BATHROOM, 4716 | ENVIRONMENT_LIVINGROOM, 4717 | ENVIRONMENT_STONEROOM, 4718 | ENVIRONMENT_AUDITORIUM, 4719 | ENVIRONMENT_CONCERTHALL, 4720 | ENVIRONMENT_CAVE, 4721 | ENVIRONMENT_ARENA, 4722 | ENVIRONMENT_HANGAR, 4723 | ENVIRONMENT_CARPETEDHALLWAY, 4724 | ENVIRONMENT_HALLWAY, 4725 | ENVIRONMENT_STONECORRIDOR, 4726 | ENVIRONMENT_ALLEY, 4727 | ENVIRONMENT_FOREST, 4728 | ENVIRONMENT_CITY, 4729 | ENVIRONMENT_MOUNTAINS, 4730 | ENVIRONMENT_QUARRY, 4731 | ENVIRONMENT_PLAIN, 4732 | ENVIRONMENT_PARKINGLOT, 4733 | ENVIRONMENT_SEWERPIPE, 4734 | ENVIRONMENT_UNDERWATER, 4735 | ENVIRONMENT_DRUGGED, 4736 | ENVIRONMENT_DIZZY, 4737 | ENVIRONMENT_PSYCHOTIC, 4738 | 4739 | ENVIRONMENT_COUNT // total number of environments 4740 | }; 4741 | 4742 | // 4743 | // enumerated values for EAX 4744 | // 4745 | 4746 | #ifndef EAX_H_INCLUDED 4747 | 4748 | enum 4749 | { 4750 | EAX_ENVIRONMENT_GENERIC, // factory default 4751 | EAX_ENVIRONMENT_PADDEDCELL, 4752 | EAX_ENVIRONMENT_ROOM, // standard environments 4753 | EAX_ENVIRONMENT_BATHROOM, 4754 | EAX_ENVIRONMENT_LIVINGROOM, 4755 | EAX_ENVIRONMENT_STONEROOM, 4756 | EAX_ENVIRONMENT_AUDITORIUM, 4757 | EAX_ENVIRONMENT_CONCERTHALL, 4758 | EAX_ENVIRONMENT_CAVE, 4759 | EAX_ENVIRONMENT_ARENA, 4760 | EAX_ENVIRONMENT_HANGAR, 4761 | EAX_ENVIRONMENT_CARPETEDHALLWAY, 4762 | EAX_ENVIRONMENT_HALLWAY, 4763 | EAX_ENVIRONMENT_STONECORRIDOR, 4764 | EAX_ENVIRONMENT_ALLEY, 4765 | EAX_ENVIRONMENT_FOREST, 4766 | EAX_ENVIRONMENT_CITY, 4767 | EAX_ENVIRONMENT_MOUNTAINS, 4768 | EAX_ENVIRONMENT_QUARRY, 4769 | EAX_ENVIRONMENT_PLAIN, 4770 | EAX_ENVIRONMENT_PARKINGLOT, 4771 | EAX_ENVIRONMENT_SEWERPIPE, 4772 | EAX_ENVIRONMENT_UNDERWATER, 4773 | EAX_ENVIRONMENT_DRUGGED, 4774 | EAX_ENVIRONMENT_DIZZY, 4775 | EAX_ENVIRONMENT_PSYCHOTIC, 4776 | 4777 | EAX_ENVIRONMENT_COUNT // total number of environments 4778 | }; 4779 | 4780 | #define EAX_REVERBMIX_USEDISTANCE (-1.0F) 4781 | 4782 | #endif 4783 | 4784 | #else 4785 | 4786 | typedef struct _FLTPROVIDER 4787 | { 4788 | U32 junk; 4789 | } FLTPROVIDER; 4790 | 4791 | #endif 4792 | 4793 | #ifdef __cplusplus 4794 | } 4795 | #endif 4796 | 4797 | 4798 | #if defined(_PUSHPOP_SUPPORTED) || PRAGMA_STRUCT_PACKPUSH 4799 | #pragma pack(pop) 4800 | #else 4801 | #pragma pack() 4802 | #endif 4803 | 4804 | 4805 | #endif 4806 | -------------------------------------------------------------------------------- /mss/mss32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CookiePLMonster/VBdec/991e43eea584c055c9d5b573345c0baf12b71ce1/mss/mss32.lib -------------------------------------------------------------------------------- /mss/mss32_2.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CookiePLMonster/VBdec/991e43eea584c055c9d5b573345c0baf12b71ce1/mss/mss32_2.lib -------------------------------------------------------------------------------- /resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by vbdec.rc 4 | 5 | // Next default values for new objects 6 | // 7 | #ifdef APSTUDIO_INVOKED 8 | #ifndef APSTUDIO_READONLY_SYMBOLS 9 | #define _APS_NEXT_RESOURCE_VALUE 101 10 | #define _APS_NEXT_COMMAND_VALUE 40001 11 | #define _APS_NEXT_CONTROL_VALUE 1001 12 | #define _APS_NEXT_SYMED_VALUE 101 13 | #endif 14 | #endif 15 | -------------------------------------------------------------------------------- /vagdec.cpp: -------------------------------------------------------------------------------- 1 | #include "vagdec.h" 2 | 3 | #include 4 | 5 | static HPROVIDER providerHandle; 6 | void RegisterVAGInterface() 7 | { 8 | // ASI codec 9 | const RIB_INTERFACE_ENTRY codecEntries[] = { 10 | REG_FN(PROVIDER_query_attribute), 11 | REG_AT("Name", PROVIDER_NAME, RIB_STRING), 12 | REG_AT("Version", PROVIDER_VERSION, RIB_HEX), 13 | REG_AT("Input file types", IN_FTYPES, RIB_STRING), 14 | //REG_AT("Input wave tag", IN_WTAG, RIB_DEC), 15 | REG_AT("Output file types", OUT_FTYPES, RIB_STRING), 16 | REG_AT("Maximum frame size", FRAME_SIZE, RIB_DEC), 17 | REG_FN(ASI_startup), 18 | REG_FN(ASI_error), 19 | REG_FN(ASI_shutdown), 20 | }; 21 | 22 | // ASI stream 23 | const RIB_INTERFACE_ENTRY streamEntries[] = { 24 | REG_FN( ASI_stream_open ), 25 | REG_FN( ASI_stream_process ), 26 | REG_FN( ASI_stream_attribute ), 27 | REG_FN( ASI_stream_set_preference ), 28 | REG_FN( ASI_stream_seek ), 29 | REG_FN( ASI_stream_close ), 30 | REG_AT("Input bit rate", INPUT_BIT_RATE, RIB_DEC), 31 | REG_AT("Input sample rate", INPUT_SAMPLE_RATE, RIB_DEC), 32 | REG_AT("Input sample width", INPUT_BITS, RIB_DEC), 33 | REG_AT("Input channels", INPUT_CHANNELS, RIB_DEC), 34 | REG_AT("Output bit rate", OUTPUT_BIT_RATE, RIB_DEC), 35 | REG_AT("Output sample rate", OUTPUT_SAMPLE_RATE, RIB_DEC), 36 | REG_AT("Output sample width", OUTPUT_BITS, RIB_DEC), 37 | REG_AT("Output channels", OUTPUT_CHANNELS, RIB_DEC), 38 | REG_AT("Position", POSITION, RIB_DEC), 39 | REG_AT("Percent done", PERCENT_DONE, RIB_PERCENT), 40 | REG_AT("Minimum input block size", MIN_INPUT_BLOCK_SIZE, RIB_DEC), 41 | //REG_AT("MPEG version", MPEG_VERSION, RIB_DEC), 42 | //REG_AT("MPEG layer", MPEG_LAYER, RIB_DEC), 43 | //REG_AT("Interleave", INTERLEAVE, RIB_DEC), 44 | //REG_PR("Raw source sample rate", RAW_RATE, RIB_DEC), 45 | //REG_PR("Raw source sample width", RAW_BITS, RIB_DEC), 46 | //REG_PR("Raw source channels", RAW_CHANNELS, RIB_DEC), 47 | REG_PR("Requested sample rate", REQUESTED_RATE, RIB_DEC), 48 | REG_PR("Requested sample width", REQUESTED_BITS, RIB_DEC), 49 | REG_PR("Requested channels", REQUESTED_CHANS, RIB_DEC) 50 | }; 51 | 52 | providerHandle = RIB_provider_library_handle(); 53 | RIB_register( providerHandle, "ASI codec", codecEntries ); 54 | RIB_register( providerHandle, "ASI stream", streamEntries ); 55 | } 56 | 57 | void UnRegisterVAGInterface() 58 | { 59 | RIB_unregister_all(providerHandle); 60 | } 61 | 62 | // ASI codec 63 | 64 | U32 AILCALL FAR PROVIDER_query_attribute(HATTRIB index) 65 | { 66 | switch ( index ) 67 | { 68 | case PROVIDER_NAME: 69 | return (U32)"MSS VAG Audio Decoder"; 70 | case PROVIDER_VERSION: 71 | return 0x100; 72 | case IN_FTYPES: // Input file types 73 | return (U32)"VAG audio files\0*.VAG"; 74 | //case IN_WTAG: // Input wave tag 75 | // return 85; 76 | case OUT_FTYPES: // Output file types; 77 | return (U32)"Raw PCM files\0*.RAW"; 78 | case FRAME_SIZE: // Maximum frame size 79 | return 2 * 16 * 512; 80 | default: 81 | return 0; 82 | } 83 | } 84 | 85 | static int startingCount = 0; 86 | ASIRESULT AILCALL FAR ASI_startup(void) 87 | { 88 | // TODO: Implement 89 | return startingCount++ == 0 ? ASI_NOERR : ASI_ALREADY_STARTED; 90 | } 91 | 92 | ASIRESULT AILCALL FAR ASI_shutdown(void) 93 | { 94 | // TODO: Implement 95 | if ( startingCount != 0 ) 96 | { 97 | startingCount--; 98 | return ASI_NOERR; 99 | } 100 | else 101 | { 102 | return ASI_NOT_INIT; 103 | } 104 | } 105 | 106 | C8 FAR* AILCALL FAR ASI_error(void) 107 | { 108 | // TODO: Implement 109 | return nullptr; 110 | } 111 | 112 | // ASI stream 113 | 114 | static short quantize(double sample) 115 | { 116 | int a = int(sample + 0.5); 117 | 118 | if (a < -32768) return -32768; 119 | if (a > 32767) return 32767; 120 | 121 | return short(a); 122 | } 123 | 124 | #include 125 | 126 | bool FetchStr( ASISTREAM *STR, int offset = -1 ) 127 | { 128 | U8 in_buf[0x20]; 129 | 130 | if ( STR->loop ) 131 | { 132 | offset = sizeof(STR->VAGheader); 133 | STR->loop = false; 134 | } 135 | 136 | auto bytes_read = STR->fetch_CB(STR->user, in_buf, STR->num_of_channels * 0x10, offset); 137 | if (bytes_read < STR->num_of_channels * 0x10) return false; 138 | 139 | if (*(U32*)&in_buf[0] == 'pGAV') // hooray loop 140 | { 141 | bytes_read = STR->fetch_CB(STR->user, in_buf, STR->num_of_channels * 0x10, sizeof(STR->VAGheader)); 142 | if (bytes_read < STR->num_of_channels * 0x10) return false; 143 | } 144 | 145 | if (offset != -1) 146 | { 147 | STR->channels[0].s_1 = STR->channels[0].s_2 = 0.0; 148 | STR->channels[1].s_1 = STR->channels[1].s_2 = 0.0; 149 | } 150 | 151 | static const double f[5][2] = { { 0.0, 0.0 }, 152 | { 60.0 / 64.0, 0.0 }, 153 | { 115.0 / 64.0, -52.0 / 64.0 }, 154 | { 98.0 / 64.0, -55.0 / 64.0 }, 155 | { 122.0 / 64.0, -60.0 / 64.0 } }; 156 | 157 | U8 *bufs[] = { in_buf, &in_buf[0x10] }; 158 | S16 *dest[] = { STR->channels[0].decoded_samples, STR->channels[1].decoded_samples }; 159 | for (int c = 0; c < STR->num_of_channels; c++) 160 | { 161 | int predict_nr = *(bufs[c]++); 162 | int shift_factor = predict_nr & 0xf; 163 | predict_nr >>= 4; 164 | assert( predict_nr < 5 ); 165 | int flags = *(bufs[c]++); 166 | if ( flags == 7 ) return false; 167 | for ( int i = 0; i < 28; i += 2 ) 168 | { 169 | int d = *(bufs[c]++); 170 | short s = short(( d & 0xf ) << 12); 171 | STR->channels[c].samples[i] = (double) ( s >> shift_factor ); 172 | s = short(( d & 0xf0 ) << 8); 173 | STR->channels[c].samples[i+1] = (double) ( s >> shift_factor ); 174 | 175 | } 176 | for ( int i = 0; i < 28; i++ ) 177 | { 178 | STR->channels[c].samples[i] = STR->channels[c].samples[i] + STR->channels[c].s_1 * f[predict_nr][0] + STR->channels[c].s_2 * f[predict_nr][1]; 179 | STR->channels[c].s_2 = STR->channels[c].s_1; 180 | STR->channels[c].s_1 = STR->channels[c].samples[i]; 181 | *(dest[c]++) = quantize( STR->channels[c].samples[i] ); 182 | } 183 | if ( flags == 1 ) break; 184 | } 185 | return true; 186 | } 187 | 188 | 189 | HASISTREAM AILCALL FAR ASI_stream_open(U32 user, AILASIFETCHCB fetch_CB, U32 total_size) 190 | { 191 | ASISTREAM FAR *STR = (ASISTREAM FAR *) AIL_mem_alloc_lock( sizeof(ASISTREAM) ); 192 | if (STR == nullptr) 193 | { 194 | return 0; 195 | } 196 | 197 | memset(STR, 0, sizeof(*STR)); 198 | 199 | STR->user = user; 200 | STR->fetch_CB = fetch_CB; 201 | STR->size = total_size; 202 | 203 | fetch_CB(user, &STR->VAGheader, sizeof(STR->VAGheader), -1); 204 | STR->VAGheader.version = _byteswap_ulong(STR->VAGheader.version); 205 | STR->VAGheader.sample_rate = _byteswap_ulong(STR->VAGheader.sample_rate); 206 | STR->VAGheader.size = _byteswap_ulong(STR->VAGheader.size); 207 | STR->num_of_channels = (STR->VAGheader.stereo != 0) ? 2 : 1; 208 | 209 | FetchStr(STR, sizeof(STR->VAGheader)); 210 | return (HASISTREAM)STR; 211 | } 212 | 213 | ASIRESULT AILCALL ASI_stream_close(HASISTREAM stream) 214 | { 215 | ASISTREAM FAR *STR = (ASISTREAM FAR *) stream; 216 | 217 | AIL_mem_free_lock(STR); 218 | 219 | return ASI_NOERR; 220 | } 221 | 222 | S32 AILCALL FAR ASI_stream_process(HASISTREAM stream, void FAR *buffer, S32 buffer_size) 223 | { 224 | ASISTREAM *STR = (ASISTREAM*)stream; 225 | 226 | S16 *dest = (S16 *)buffer; 227 | S32 bytes_decoded = 0; 228 | 229 | for (int i = 0; i < buffer_size / (2 * STR->num_of_channels); i++) 230 | { 231 | for (int c = 0; c < STR->num_of_channels; c++) 232 | { 233 | dest[i * STR->num_of_channels + c] = STR->channels[c].decoded_samples[STR->cursor]; 234 | bytes_decoded += sizeof(S16); 235 | } 236 | STR->cursor++; 237 | if (STR->cursor >= 28) 238 | { 239 | STR->cursor = 0; 240 | if (!FetchStr(STR)) 241 | break; 242 | } 243 | } 244 | STR->offset += bytes_decoded; 245 | return bytes_decoded; 246 | } 247 | 248 | ASIRESULT AILCALL ASI_stream_seek (HASISTREAM stream, S32 stream_offset) 249 | { 250 | ASISTREAM *STR = (ASISTREAM*)stream; 251 | if (stream_offset > (S32)(STR->VAGheader.size + sizeof(STR->VAGheader))) return ASI_INVALID_PARAM; 252 | 253 | if (stream_offset == -2) // loop 254 | { 255 | stream_offset = sizeof(STR->VAGheader); 256 | STR->loop = true; 257 | } 258 | else 259 | { 260 | STR->offset = stream_offset; 261 | STR->cursor = 0; 262 | FetchStr(STR, stream_offset); 263 | } 264 | 265 | return ASI_NOERR; 266 | } 267 | 268 | S32 AILCALL FAR ASI_stream_attribute (HASISTREAM stream, HATTRIB attrib) 269 | { 270 | ASISTREAM *STR = (ASISTREAM*)stream; 271 | switch (attrib) 272 | { 273 | case INPUT_BIT_RATE: return STR->VAGheader.sample_rate * 4 * STR->num_of_channels; 274 | case INPUT_SAMPLE_RATE: return STR->VAGheader.sample_rate; 275 | case INPUT_BITS: return 4; 276 | case INPUT_CHANNELS: return STR->num_of_channels; 277 | case OUTPUT_BIT_RATE: return STR->VAGheader.sample_rate * 16 * STR->num_of_channels; 278 | case OUTPUT_SAMPLE_RATE: return STR->VAGheader.sample_rate; 279 | case OUTPUT_BITS: return 16; 280 | case OUTPUT_CHANNELS: return STR->num_of_channels; 281 | case POSITION: return STR->offset; 282 | case PERCENT_DONE: 283 | { 284 | float percent = ((float)(100.0 * STR->offset) / (STR->size / (STR->num_of_channels * 16 * 512))); 285 | return *(S32*)&percent; 286 | } 287 | case MIN_INPUT_BLOCK_SIZE: return STR->num_of_channels * 16 * 512; 288 | } 289 | return -1; 290 | } 291 | 292 | S32 AILCALL FAR ASI_stream_set_preference (HASISTREAM stream, HATTRIB preference, void FAR* value) 293 | { 294 | return 0; 295 | } -------------------------------------------------------------------------------- /vagdec.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "mss/mss.h" 4 | 5 | enum PROPERTY 6 | { 7 | // 8 | // Additional decoder props (beyond standard RIB PROVIDER_ properties) 9 | // 10 | 11 | IN_FTYPES, // STRING supported input file types 12 | IN_WTAG, // Tag used for this data in a wave file 13 | OUT_FTYPES, // STRING supported output file types 14 | FRAME_SIZE, // S32 worst-case frame buffer size 15 | 16 | INPUT_BIT_RATE, // S32 input bit rate 17 | INPUT_SAMPLE_RATE, // S32 sample rate of input data 18 | INPUT_BITS, // S32 bit width per sample of input data 19 | INPUT_CHANNELS, // S32 # of channels in input data 20 | 21 | OUTPUT_BIT_RATE, // S32 output bit rate 22 | OUTPUT_SAMPLE_RATE, // S32 output sample rate 23 | OUTPUT_BITS, // S32 bit width per sample of output data 24 | OUTPUT_CHANNELS, // S32 # of channels in output data 25 | 26 | POSITION, // S32 bytes processed so far 27 | PERCENT_DONE, // % percent done 28 | MIN_INPUT_BLOCK_SIZE, // S32 minimum block size for input 29 | 30 | // 31 | // Codec-specific stream props 32 | // 33 | //INTERLEAVE, 34 | 35 | // 36 | // Stream properties 37 | // 38 | 39 | //RAW_RATE, 40 | //RAW_BITS, 41 | //RAW_CHANNELS, 42 | 43 | REQUESTED_RATE, // S32 requested rate for output data 44 | REQUESTED_BITS, // S32 requested bit width for output data 45 | REQUESTED_CHANS // S32 requested # of channels for output data 46 | }; 47 | 48 | struct VAG_HEADER // Big endian 49 | { 50 | char VAG[3]; 51 | char field_3; // can be p or i 52 | int version; // doesn't seem to matter at all 53 | int field_8; // always 0? 54 | int size; // size minus 0x30 55 | int sample_rate; 56 | int stereo; 57 | int field_18[2]; // always 0? 58 | char filename[16]; 59 | char padding[16]; 60 | }; 61 | 62 | struct ASISTREAM 63 | { 64 | U32 user; 65 | U32 size; 66 | AILASIFETCHCB fetch_CB; 67 | 68 | U32 offset; 69 | 70 | S32 cursor; 71 | U32 blocks; 72 | U32 cur_block; 73 | 74 | S32 num_of_channels; 75 | 76 | bool loop; 77 | 78 | VAG_HEADER VAGheader; 79 | 80 | struct 81 | { 82 | double s_1, s_2; 83 | double samples[28]; 84 | S16 decoded_samples[28]; 85 | } channels[2]; 86 | }; 87 | 88 | void RegisterVAGInterface(); 89 | void UnRegisterVAGInterface(); 90 | 91 | U32 AILCALL FAR PROVIDER_query_attribute(HATTRIB index); 92 | ASIRESULT AILCALL FAR ASI_startup(void); 93 | ASIRESULT AILCALL FAR ASI_shutdown(void); 94 | C8 FAR* AILCALL FAR ASI_error(void); 95 | 96 | HASISTREAM AILCALL FAR ASI_stream_open(U32 user, AILASIFETCHCB fetch_CB, U32 total_size); 97 | ASIRESULT AILCALL ASI_stream_close(HASISTREAM stream); 98 | ASIRESULT AILCALL ASI_stream_seek (HASISTREAM stream, S32 stream_offset); 99 | S32 AILCALL FAR ASI_stream_process(HASISTREAM stream, void FAR *buffer, S32 buffer_size); 100 | S32 AILCALL FAR ASI_stream_attribute (HASISTREAM stream, HATTRIB attrib); 101 | S32 AILCALL FAR ASI_stream_set_preference (HASISTREAM stream, HATTRIB preference, void FAR* value); -------------------------------------------------------------------------------- /vbcalls.cpp: -------------------------------------------------------------------------------- 1 | #include "vagdec.h" 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | class VBStream 10 | { 11 | public: 12 | static const size_t VB_SAMPLE_SIZE = 0x10; 13 | static const size_t VB_BLOCK_SIZE = 512 * VB_SAMPLE_SIZE * 2; 14 | 15 | VBStream( FILE* file, int sample_rate, int stereo, int size ) 16 | : stream( file ), fileSize( size + sizeof(VAG_HEADER) ) 17 | { 18 | memset( &virtualHeader, 0, sizeof(virtualHeader) ); 19 | virtualHeader.VAG[0] = 'V'; 20 | virtualHeader.VAG[1] = 'A'; 21 | virtualHeader.VAG[2] = 'G'; 22 | virtualHeader.field_3 = 'p'; 23 | 24 | virtualHeader.sample_rate = _byteswap_ulong(sample_rate); 25 | virtualHeader.stereo = _byteswap_ulong(stereo); 26 | virtualHeader.size = _byteswap_ulong(size); 27 | 28 | blockBuffer = stereo != 0 ? (U8*)AIL_mem_alloc_lock( VB_BLOCK_SIZE ) : nullptr; 29 | } 30 | 31 | VBStream( const VBStream& ) = delete; 32 | VBStream& operator = ( const VBStream& rhs ) = delete; 33 | 34 | VBStream( VBStream&& rhs ) = default; 35 | VBStream& operator = ( VBStream&& rhs ) = default; 36 | 37 | ~VBStream() 38 | { 39 | if ( blockBuffer != nullptr ) 40 | { 41 | AIL_mem_free_lock( blockBuffer ); 42 | blockBuffer = nullptr; 43 | } 44 | } 45 | 46 | bool UsesInterleave() const { return blockBuffer != nullptr; } 47 | 48 | FILE* GetStream() const { return stream; } 49 | 50 | static S32 GetBlock(S32 offset) 51 | { 52 | // VB_BLOCK_SIZE = 2^14 53 | return offset >> 14; 54 | } 55 | 56 | U32 ReadFile( void FAR* Buffer, U32 Bytes ) 57 | { 58 | if ( virtualCursor == 0 ) 59 | { 60 | VAG_HEADER* header = (VAG_HEADER*)Buffer; 61 | *header = virtualHeader; 62 | 63 | size_t bytesRead = sizeof(VAG_HEADER); 64 | if ( !UsesInterleave() ) 65 | { 66 | bytesRead += fread( &header[1], 1, Bytes-sizeof(*header), stream ); 67 | } 68 | else 69 | { 70 | ReadBlockAndInterleave(); 71 | 72 | memcpy( &header[1], blockBuffer, Bytes-sizeof(*header) ); 73 | bytesRead += Bytes-sizeof(*header); 74 | } 75 | virtualCursor += bytesRead; 76 | return bytesRead; 77 | } 78 | 79 | if ( !UsesInterleave() ) 80 | { 81 | Bytes = fread( Buffer, 1, Bytes, stream ); 82 | } 83 | else 84 | { 85 | if ( currentBlockCursor + Bytes >= VB_BLOCK_SIZE ) 86 | { 87 | size_t firstRead = VB_BLOCK_SIZE - currentBlockCursor; 88 | 89 | memcpy( Buffer, blockBuffer+currentBlockCursor, firstRead ); 90 | ReadBlockAndInterleave(); 91 | memcpy( (U8*)Buffer+firstRead, blockBuffer, Bytes-firstRead ); 92 | 93 | currentBlockCursor += Bytes-firstRead; 94 | } 95 | else 96 | { 97 | memcpy( Buffer, blockBuffer+currentBlockCursor, Bytes ); 98 | currentBlockCursor += Bytes; 99 | } 100 | } 101 | virtualCursor += Bytes; 102 | assert( (virtualCursor & ((VB_SAMPLE_SIZE*2)-1)) == 0 ); 103 | return Bytes; 104 | } 105 | 106 | S32 SeekFile( S32 Offset, U32 Type ) 107 | { 108 | if ( Type == AIL_FILE_SEEK_CURRENT ) Offset += virtualCursor; 109 | else if ( Type == AIL_FILE_SEEK_END ) Offset = fileSize - Offset; 110 | 111 | if ( UsesInterleave() ) 112 | Offset &= ~((VB_SAMPLE_SIZE*2)-1); 113 | else 114 | Offset &= ~(VB_SAMPLE_SIZE-1); 115 | 116 | S32 OffsetNoHeader = Offset - sizeof(VAG_HEADER); 117 | S32 CursorNoHeader = virtualCursor - sizeof(VAG_HEADER); 118 | 119 | if ( OffsetNoHeader <= 0 ) 120 | { 121 | // Seeks to header - do nothing since next ReadFile flushes everything anyway 122 | fseek( stream, 0, SEEK_SET ); 123 | virtualCursor = 0; 124 | return 0; 125 | } 126 | 127 | if ( UsesInterleave() ) 128 | { 129 | // Is within the same block? 130 | if ( GetBlock(OffsetNoHeader) == GetBlock(CursorNoHeader) ) 131 | { 132 | // Do nothing, just move cursor 133 | currentBlockCursor = OffsetNoHeader - CursorNoHeader; 134 | } 135 | else 136 | { 137 | // Read new block 138 | fseek( stream, OffsetNoHeader & ~(VB_BLOCK_SIZE-1), SEEK_SET ); 139 | ReadBlockAndInterleave(); 140 | currentBlockCursor = OffsetNoHeader & (VB_BLOCK_SIZE-1); 141 | } 142 | assert( (currentBlockCursor & ((VB_SAMPLE_SIZE*2)-1)) == 0 ); 143 | } 144 | else 145 | { 146 | fseek( stream, OffsetNoHeader, SEEK_SET ); 147 | } 148 | virtualCursor = Offset; 149 | return virtualCursor; 150 | } 151 | 152 | private: 153 | void ReadBlockAndInterleave( ) 154 | { 155 | U8 buf[VB_BLOCK_SIZE]; 156 | size_t bytesRead = fread( buf, 1, VB_BLOCK_SIZE, stream ); 157 | 158 | // Interleave 159 | if ( bytesRead == VB_BLOCK_SIZE ) 160 | { 161 | U8* leftChannel = buf; 162 | U8* rightChannel = buf+(VB_BLOCK_SIZE/2); 163 | U8* output = blockBuffer; 164 | 165 | for ( int i = 0; i < 512; ++i ) 166 | { 167 | memcpy( output, leftChannel, VB_SAMPLE_SIZE ); 168 | memcpy( output+VB_SAMPLE_SIZE, rightChannel, VB_SAMPLE_SIZE ); 169 | leftChannel += VB_SAMPLE_SIZE; 170 | rightChannel += VB_SAMPLE_SIZE; 171 | output += 2*VB_SAMPLE_SIZE; 172 | } 173 | } 174 | currentBlockCursor = 0; 175 | } 176 | 177 | private: 178 | FILE* stream; 179 | VAG_HEADER virtualHeader; 180 | U8* blockBuffer; 181 | S32 currentBlockCursor = 0, virtualCursor = 0; 182 | S32 fileSize; 183 | }; 184 | 185 | static std::vector adfStreams; 186 | static std::vector vbStreams; 187 | 188 | static void XORADFStream( void FAR* Buffer, size_t size ) 189 | { 190 | U8* buf = (U8*)Buffer; 191 | 192 | while ( size != 0 && ((U32)buf & 3) != 0 ) 193 | { 194 | *buf ++ ^= 0x22; 195 | --size; 196 | } 197 | 198 | while ( size >= 4 ) 199 | { 200 | *(U32*)buf ^= 0x22222222; 201 | buf += 4; 202 | size -= 4; 203 | } 204 | 205 | while ( size != 0 ) 206 | { 207 | *buf ++ ^= 0x22; 208 | --size; 209 | } 210 | } 211 | 212 | static U32 AILCALLBACK FAR OpenFileCB(MSS_FILE const FAR* Filename, U32 FAR* FileHandle) 213 | { 214 | FILE* hFile = nullptr; 215 | errno_t err = fopen_s( &hFile, Filename, "rb" ); 216 | *FileHandle = (U32)hFile; 217 | 218 | if ( err != 0 ) return 0; 219 | 220 | size_t length = strlen(Filename); 221 | if ( Filename[length-4] == '.' && 222 | ( Filename[length-3] == 'a' || Filename[length-3] == 'A' ) && 223 | ( Filename[length-2] == 'd' || Filename[length-2] == 'D' ) && 224 | ( Filename[length-1] == 'f' || Filename[length-1] == 'F' ) 225 | ) 226 | { 227 | MSS_FILE FAR* name = const_cast(Filename); 228 | name[length-3] = 'm'; 229 | name[length-2] = 'p'; 230 | name[length-1] = '3'; 231 | 232 | adfStreams.push_back( hFile ); 233 | } 234 | else if ( Filename[length-3] == '.' && 235 | ( Filename[length-2] == 'v' || Filename[length-2] == 'V' ) && 236 | ( Filename[length-1] == 'b' || Filename[length-1] == 'B' ) 237 | ) 238 | { 239 | MSS_FILE FAR* name = const_cast(Filename); 240 | name[length-2] = 'i'; 241 | name[length-1] = 'n'; 242 | name[length] = 'i'; 243 | name[length+1] = '\0'; 244 | 245 | int samplerate = GetPrivateProfileInt( "VB", "sample_rate", 32000, name ); 246 | int stereo = GetPrivateProfileInt( "VB", "stereo", 1, name ) != 0 ? 1 : 0; 247 | 248 | name[length-2] = 'v'; 249 | name[length-1] = 'a'; 250 | name[length] = 'g'; 251 | 252 | int size = _filelength( _fileno(hFile) ); 253 | vbStreams.emplace_back( hFile, samplerate, stereo, size ); 254 | } 255 | 256 | return (U32)hFile; 257 | } 258 | 259 | static void AILCALLBACK FAR CloseFileCB(U32 FileHandle) 260 | { 261 | FILE* hFile = (FILE*)FileHandle; 262 | { 263 | auto it = std::find( adfStreams.begin(), adfStreams.end(), hFile ); 264 | if ( it != adfStreams.end() ) 265 | { 266 | adfStreams.erase( it ); 267 | fclose( hFile ); 268 | return; 269 | } 270 | } 271 | { 272 | auto it = std::find_if( vbStreams.begin(), vbStreams.end(), [hFile](const VBStream& s) { 273 | return s.GetStream() == hFile; 274 | } ); 275 | if ( it != vbStreams.end() ) 276 | { 277 | vbStreams.erase( it ); 278 | fclose( hFile ); 279 | return; 280 | } 281 | 282 | } 283 | fclose( hFile ); 284 | } 285 | 286 | static S32 AILCALLBACK FAR SeekFileCB(U32 FileHandle, S32 Offset, U32 Type) 287 | { 288 | FILE* hFile = (FILE*)FileHandle; 289 | auto it = std::find_if( vbStreams.begin(), vbStreams.end(), [hFile](const VBStream& s) { 290 | return s.GetStream() == hFile; 291 | } ); 292 | if ( it != vbStreams.end() ) 293 | { 294 | return it->SeekFile( Offset, Type ); 295 | } 296 | 297 | fseek( hFile, Offset, Type ); 298 | return ftell( hFile ); 299 | } 300 | 301 | static U32 AILCALLBACK FAR ReadFileCB(U32 FileHandle, void FAR* Buffer, U32 Bytes) 302 | { 303 | FILE* hFile = (FILE*)FileHandle; 304 | { 305 | auto it = std::find( adfStreams.begin(), adfStreams.end(), hFile ); 306 | if ( it != adfStreams.end() ) 307 | { 308 | size_t bytesRead = fread( Buffer, 1, Bytes, hFile ); 309 | XORADFStream( Buffer, bytesRead ); 310 | return bytesRead; 311 | } 312 | } 313 | { 314 | auto it = std::find_if( vbStreams.begin(), vbStreams.end(), [hFile](const VBStream& s) { 315 | return s.GetStream() == hFile; 316 | } ); 317 | if ( it != vbStreams.end() ) 318 | { 319 | return it->ReadFile( Buffer, Bytes ); 320 | } 321 | } 322 | size_t bytesRead = fread( Buffer, 1, Bytes, hFile ); 323 | return bytesRead; 324 | } 325 | 326 | void AttachVBCallbacks() 327 | { 328 | AIL_set_file_callbacks( OpenFileCB, CloseFileCB, SeekFileCB, ReadFileCB ); 329 | } -------------------------------------------------------------------------------- /vbcalls.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | void AttachVBCallbacks(); -------------------------------------------------------------------------------- /vbdec.rc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CookiePLMonster/VBdec/991e43eea584c055c9d5b573345c0baf12b71ce1/vbdec.rc -------------------------------------------------------------------------------- /vbdec.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vbdec", "vbdec.vcxproj", "{5257A187-36BF-4998-81EB-B7344F3D92FD}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x86 = Debug|x86 11 | Release|x86 = Release|x86 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {5257A187-36BF-4998-81EB-B7344F3D92FD}.Debug|x86.ActiveCfg = Debug|Win32 15 | {5257A187-36BF-4998-81EB-B7344F3D92FD}.Debug|x86.Build.0 = Debug|Win32 16 | {5257A187-36BF-4998-81EB-B7344F3D92FD}.Release|x86.ActiveCfg = Release|Win32 17 | {5257A187-36BF-4998-81EB-B7344F3D92FD}.Release|x86.Build.0 = Release|Win32 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /vbdec.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {5257A187-36BF-4998-81EB-B7344F3D92FD} 15 | vbdec 16 | 8.1 17 | 18 | 19 | 20 | DynamicLibrary 21 | true 22 | v140_xp 23 | MultiByte 24 | 25 | 26 | DynamicLibrary 27 | false 28 | v140_xp 29 | true 30 | MultiByte 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | .asi 46 | 47 | 48 | .asi 49 | 50 | 51 | 52 | Level3 53 | Disabled 54 | true 55 | /Zc:threadSafeInit- %(AdditionalOptions) 56 | StreamingSIMDExtensions 57 | _DEBUG;%(PreprocessorDefinitions) 58 | 59 | 60 | mss/mss32.lib;mss/mss32_2.lib;%(AdditionalDependencies) 61 | false 62 | Windows 63 | true 64 | 65 | 66 | copy /y "$(TargetPath)" "$(GTA_VC_ROOT)\mss\vbdec.asi" 67 | 68 | 69 | 70 | 71 | Level3 72 | MaxSpeed 73 | true 74 | true 75 | true 76 | AnySuitable 77 | Speed 78 | true 79 | MultiThreaded 80 | StreamingSIMDExtensions 81 | Fast 82 | /Zc:threadSafeInit- %(AdditionalOptions) 83 | NDEBUG;%(PreprocessorDefinitions) 84 | 85 | 86 | true 87 | true 88 | mss/mss32.lib;mss/mss32_2.lib;%(AdditionalDependencies) 89 | false 90 | Windows 91 | 92 | 93 | copy /y "$(TargetPath)" "$(GTA_VC_ROOT)\mss\vbdec.asi" 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /vbdec.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | {b15ad6e8-913c-43a3-8c2a-690af29b81de} 18 | 19 | 20 | 21 | 22 | Source Files 23 | 24 | 25 | Source Files 26 | 27 | 28 | Source Files 29 | 30 | 31 | 32 | 33 | Header Files\mss 34 | 35 | 36 | Header Files 37 | 38 | 39 | Header Files 40 | 41 | 42 | Header Files 43 | 44 | 45 | 46 | 47 | Resource Files 48 | 49 | 50 | --------------------------------------------------------------------------------