the game where you go into mines and start crafting! but for consoles (forked directly from smartcmd's github)
at main 3267 lines 119 kB view raw
1#ifndef IMSSAPI_H 2#define IMSSAPI_H 3 4// Internal API file 5 6#if defined(IS_PS3) || defined(IS_PSP) 7#include <string.h> 8#endif 9 10#if defined(IS_WII) 11#include <string.h> 12#include <math.h> 13#endif 14 15#ifdef __cplusplus 16extern "C" 17{ 18#endif 19 20#if defined(IS_WIN32API) || defined(IS_WII) 21 #pragma pack(push, 1) 22#endif 23#ifdef IS_32 24 #if !defined(IS_WIN32API) 25 #define ASMLINK 26 #define ASMPARM 27 #else 28 #if defined(IS_XENON) 29 #define ASMLINK __cdecl 30 #define ASMPARM register 31 #else 32 #define ASMLINK __cdecl 33 #define ASMPARM 34 #endif 35 #endif 36#else 37 #define ASMLINK WINAPI 38 #define ASMPARM 39#endif 40 41#ifndef YES 42#define YES 1 43#endif 44 45#ifndef NULL 46#define NULL 0 47#endif 48 49#define MSSHIWORD(ptr) (((U32)ptr)>>16) 50#define MSSLOWORD(ptr) ((U16)((U32)ptr)) 51 52#ifndef NO 53#define NO 0 54#endif 55 56#ifndef TRUE 57#define TRUE 1 58#endif 59 60#ifndef FALSE 61#define FALSE 0 62#endif 63 64#ifdef IS_MAC 65 66#if !defined(max) 67#define max(a,b) (((a) > (b)) ? (a) : (b)) 68#endif 69#if !defined(min) 70#define min(a,b) (((a) < (b)) ? (a) : (b)) 71#endif 72 73#endif 74 75#ifdef IS_WATCOM 76 77#if !defined(max) // Watcom stdlib.h doesn't define these for C++ 78#define max(a,b) (((a) > (b)) ? (a) : (b)) 79#endif 80#if !defined(min) 81#define min(a,b) (((a) < (b)) ? (a) : (b)) 82#endif 83 84#endif 85 86#ifdef IS_WIN64 87 88 #define PTRFMT "0x%I64X" 89 #define SINTFMT "%I64d" 90 #define HPFMT "%ld" 91 92#else 93 94 #if defined(IS_PS3) || defined(IS_PSP) || defined(IS_3DS) 95 96 #define PTRFMT "0x%lX" 97 #define SINTFMT "%d" // (GCC warns when ints printed with %ld) 98 #define HPFMT "%ld" 99 100 #else 101 102 #define PTRFMT "0x%lX" 103 #define SINTFMT "%ld" 104 #define HPFMT "%ld" 105 106 #endif 107 108#endif 109 110U32 AILCALL XMI_read_VLN(U8 const* *ptr); 111S32 AILCALL XMI_message_size(S32 status); 112void const * AILCALL XMI_find_sequence(U8 const *image, S32 sequence); 113S32 AIL_process_WAV_image( AILSOUNDINFO const * info, HSAMPLE sample ); 114 115#ifdef IS_SPU 116#define NTELEMETRY 117#endif 118 119#include "tmapi.h" 120 121#ifdef NTELEMETRY 122 #define miles_context 0 123#else 124 extern HTELEMETRY g_Miles_Tm; 125 extern S32 g_tm_log; 126 #define miles_context g_Miles_Tm 127#endif 128 129//############################################################################ 130//## ## 131//## API function prototypes ## 132//## ## 133//############################################################################ 134 135#define check_hardware_buffer( S, flags ) 136#define hardware_stop( S ) 137#define set_hardware_position( S ) 138#define hardware_spin_until_stopped( S ) 139#define set_hardware_volume( S ) 140#define set_master_hardware_volume( dig ) 141#define set_hardware_loop_region( S ) 142#define set_hardware_low_pass( S ) 143 144extern void AILCALL InMilesMutex(void); 145extern void AILCALL OutMilesMutex(void); 146 147#ifdef IS_WIN32API 148 149#ifdef NTAPI 150extern HWND AILCALL AIL_API_HWND (void); 151 152void AILEXPORT API_timer (UINT IDEvent, 153 UINT uReserved, 154 DWORD dwUser, 155 DWORD dwReserved1, 156 DWORD dwReserved2); 157 158#endif 159 160extern S32 MilesCount; 161extern U32 lastapitimerms; 162 163 void AILCALL Set_thread_name( U32 thread_id, char const * thread_name ); 164 165#endif 166 167 168#ifdef IS_MAC 169 #if defined(__CARBON__) 170 ProcessSerialNumber AILCALL AIL_API_Process(void); 171 #endif 172#endif 173 174 175#ifdef _DEBUG 176 177DXDEC void AILEXPORT AIL_debug_printf( char const *fmt, ...); 178 179#else 180 181#define AIL_debug_printf(...) 182 183#endif 184 185#ifndef MSS_SPU_PROCESS 186 187// 188// Global preference array 189// 190extern SINTa AIL_preference [N_PREFS]; 191 192#endif 193 194extern char AIL_redist_directory[260]; 195 196extern S32 AILCALL match_suffix(char const* suffix,char const* file_suffix); 197 198#if !defined(IS_X86) || !defined(IS_MAC) // use mix rib on x86 mac 199DXDEC S32 AILCALL MIX_RIB_MAIN( HPROVIDER provider_handle, U32 up_down, RIB_ALLOC_PROVIDER_HANDLE_TYPE * rib_alloc, RIB_REGISTER_INTERFACE_TYPE * rib_reg, RIB_UNREGISTER_INTERFACE_TYPE * rib_unreg ); 200#endif 201 202// 203// High-level support services 204// 205 206extern void AILCALL AIL_API_startup (void); 207extern void AILCALL AIL_API_shutdown (void); 208 209extern SINTa AILCALL AIL_API_set_preference (U32 number, 210 SINTa value); 211 212// 213// Low-level support services 214// 215 216extern void AILCALL AIL_API_sleep (U32 ms); 217 218extern S32 AILCALL AIL_API_background (void); 219 220extern void AILCALL AIL_API_mem_free_lock (void *ptr); 221 222extern void* AILCALL AIL_API_mem_alloc_lock (UINTa size); 223 224// 225// Process services 226// 227 228extern HTIMER AILCALL AIL_API_register_timer (AILTIMERCB fn); 229 230extern UINTa AILCALL AIL_API_set_timer_user (HTIMER timer, 231 UINTa user); 232 233extern void AILCALL AIL_API_set_timer_period (HTIMER timer, 234 U32 microseconds); 235 236extern void AILCALL AIL_API_set_timer_frequency (HTIMER timer, 237 U32 hertz) ; 238 239extern void AILCALL AIL_API_set_timer_divisor (HTIMER timer, 240 U32 PIT_divisor); 241 242extern void AILCALL AIL_API_start_timer (HTIMER timer) ; 243extern void AILCALL AIL_API_start_all_timers (void); 244 245extern void AILCALL AIL_API_stop_timer (HTIMER timer); 246extern void AILCALL AIL_API_stop_all_timers (void); 247 248extern void AILCALL AIL_API_release_timer_handle(HTIMER timer); 249extern void AILCALL AIL_API_release_all_timers (void); 250 251extern void Container_FreeAll(); 252extern void* Container_GetPreset(char const* i_PresetName); 253extern void* Container_GetEnvironment(char const* i_EnvironmentName); 254extern S32 Container_GetSound(char const* i_SoundName, char* o_SoundFileName, MILESBANKSOUNDINFO* o_SoundInfo); 255extern void* Container_GetEvent(char const* i_EventName); 256extern void* Container_GetMarkerList(char const* i_SoundName); 257extern S32 Container_GetLoadedCount(); 258extern S32 Container_GetMemUsage(); 259extern char const* Container_GetLoadedName(S32 i_Index); 260 261extern const U8* AILCALL MilesFindEventInternal(HMSOUNDBANK i_Bank, const char* i_EventName); 262extern void AILCALL MilesClearEventQueueInternal(); 263extern void AILCALL MilesRegisterRandInternal(MSS_USER_RAND * rand); 264extern U64 AILCALL MilesEnqueueEventInternal(const U8* i_Event, void* i_UserBuffer, S32 i_UserBufferLen, S32 i_EnqueueFlags, U64 i_EventFilter); 265extern U64 AILCALL MilesEnqueueEventByNameInternal(char const* i_Name); 266extern U64 AILCALL MilesEnqueueEventContextInternal(HEVENTSYSTEM i_Context, const U8* i_Event, void* i_UserBuffer, S32 i_UserBufferLen, S32 i_EnqueueFlags, U64 i_EventFilter); 267 268extern S32 AILCALL MilesBeginEventQueueProcessingInternal(); 269extern S32 AILCALL MilesCompleteEventQueueProcessingInternal(); 270 271extern S32 AILCALL MilesEnumerateSoundInstancesInternal(HEVENTSYSTEM i_System, HMSSENUM* io_Next, S32 i_Status, const char* i_Labels, U64 search_for_ID, MILESEVENTSOUNDINFO* o_Info); 272extern S32 AILCALL MilesEnumeratePresetPersistsInternal(HEVENTSYSTEM i_System, HMSSENUM* io_Next, const char** o_Name); 273extern HEVENTSYSTEM AILCALL MilesStartupEventSystemInternal(HDIGDRIVER i_Driver, S32 i_CommandBufferSize, char* i_Memory, S32 i_MemoryLen); 274extern HEVENTSYSTEM AILCALL MilesAddEventSystemInternal(HDIGDRIVER i_Driver); 275extern S32 AILCALL MilesSetSoundLabelLimitsInternal(HEVENTSYSTEM i_System, U64 i_Id, const char* i_SoundLimits, char const* i_Name); 276 277 278extern void AILCALL MilesShutdownEventSystemInternal(); 279extern HMSOUNDBANK AILCALL MilesAddSoundBankInternal(const char* i_FileName, char const* i_Name); 280extern S32 AILCALL MilesReleaseSoundBankInternal(HMSOUNDBANK i_Bank); 281extern char* AILCALL MilesTextDumpEventSystemInternal(); 282extern void AILCALL MilesSetEventErrorCallbackInternal(AILEVENTERRORCB i_Callback); 283 284extern void AILCALL MilesSetVarIInternal(UINTa i_System, char const* i_Name, S32 i_Value); 285extern void AILCALL MilesSetVarFInternal(UINTa i_System, char const* i_Name, F32 i_Value); 286extern S32 AILCALL MilesGetVarFInternal(UINTa i_Context, char const* i_Name, F32* o_Value); 287extern S32 AILCALL MilesGetVarIInternal(UINTa i_Context, char const* i_Name, S32* o_Value); 288extern void AILCALL MilesSetSoundStartOffsetInternal(HMSSENUM i_Instance, S32 i_Offset, S32 i_IsMs); 289extern void AILCALL MilesRequeueAsyncsInternal(); 290 291extern AIL_file_open_callback MSS_open; 292extern AIL_file_close_callback MSS_close; 293extern AIL_file_seek_callback MSS_seek; 294extern AIL_file_read_callback MSS_read; 295 296extern S32 disk_err; 297extern char MSS_Directory[260]; 298 299 300extern void stream_background(void); // background service for streaming 301 302#define call_fetch_CB( ASI,usr,dest,bytes,offset ) ((AILASIFETCHCB)((ASI)->fetch_CB))(usr,dest,bytes,offset) 303 304extern HPROVIDER find_ASI_provider(const C8 *attrib, const C8 *filename); 305 306 307// 308// M3D services 309// 310 311extern HDIGDRIVER AILCALL AIL_API_primary_digital_driver (HDIGDRIVER new_primary); 312 313extern void AILCALL AIL_API_set_sample_3D_distances (HSAMPLE samp, 314 F32 max_dist, 315 F32 min_dist, 316 S32 auto_3D_wet_atten); 317 318extern void AILCALL AIL_API_sample_3D_distances (HSAMPLE samp, 319 F32 * max_dist, 320 F32 * min_dist, 321 S32 * auto_3D_wet_atten); 322 323extern void AILCALL AIL_API_set_sample_obstruction (HSAMPLE S, 324 F32 obstruction); 325 326extern void AILCALL AIL_API_set_sample_exclusion (HSAMPLE S, 327 F32 exclusion); 328 329extern void AILCALL AIL_API_set_sample_occlusion (HSAMPLE S, 330 F32 occlusion); 331 332extern void AILCALL AIL_API_set_sample_3D_cone (HSAMPLE S, 333 F32 inner_angle, 334 F32 outer_angle, 335 F32 outer_volume); 336 337extern F32 AILCALL AIL_API_sample_obstruction (HSAMPLE S); 338 339extern F32 AILCALL AIL_API_sample_occlusion (HSAMPLE S); 340 341extern F32 AILCALL AIL_API_sample_exclusion (HSAMPLE S); 342 343extern void AILCALL AIL_API_sample_3D_cone (HSAMPLE S, 344 F32 *inner_angle, 345 F32 *outer_angle, 346 F32 *outer_volume); 347 348extern S32 AILCALL AIL_API_room_type (HDIGDRIVER dig, 349 S32 bus_index); 350 351extern void AILCALL AIL_API_set_room_type (HDIGDRIVER dig, 352 S32 bus_index, 353 S32 EAX_room_type); 354 355extern F32 AILCALL AIL_API_3D_rolloff_factor (HDIGDRIVER dig); 356 357extern void AILCALL AIL_API_set_3D_rolloff_factor (HDIGDRIVER dig, 358 F32 factor ); 359 360extern F32 AILCALL AIL_API_3D_doppler_factor (HDIGDRIVER dig); 361 362extern void AILCALL AIL_API_set_3D_doppler_factor (HDIGDRIVER dig, 363 F32 factor ); 364 365extern F32 AILCALL AIL_API_3D_distance_factor (HDIGDRIVER dig); 366 367extern void AILCALL AIL_API_set_3D_distance_factor (HDIGDRIVER dig, 368 F32 factor ); 369 370extern void AILCALL AIL_API_set_sample_3D_position (HSAMPLE S, 371 F32 X, 372 F32 Y, 373 F32 Z); 374 375extern void AILCALL AIL_API_set_sample_3D_velocity (HSAMPLE S, 376 F32 dX_per_ms, 377 F32 dY_per_ms, 378 F32 dZ_per_ms, 379 F32 magnitude); 380 381extern void AILCALL AIL_API_set_sample_3D_velocity_vector (HSAMPLE S, 382 F32 dX_per_ms, 383 F32 dY_per_ms, 384 F32 dZ_per_ms); 385 386extern void AILCALL AIL_API_set_sample_3D_orientation (HSAMPLE S, 387 F32 X_face, 388 F32 Y_face, 389 F32 Z_face, 390 F32 X_up, 391 F32 Y_up, 392 F32 Z_up); 393 394extern S32 AILCALL AIL_API_sample_3D_position (HSAMPLE S, 395 F32 *X, 396 F32 *Y, 397 F32 *Z); 398 399extern void AILCALL AIL_API_sample_3D_velocity (HSAMPLE S, 400 F32 *dX_per_ms, 401 F32 *dY_per_ms, 402 F32 *dZ_per_ms); 403 404extern void AILCALL AIL_API_sample_3D_orientation (HSAMPLE S, 405 F32 *X_face, 406 F32 *Y_face, 407 F32 *Z_face, 408 F32 *X_up, 409 F32 *Y_up, 410 F32 *Z_up); 411 412extern void AILCALL AIL_API_update_sample_3D_position (HSAMPLE S, 413 F32 dt_milliseconds); 414 415extern void AILCALL AIL_API_set_listener_3D_position(HDIGDRIVER dig, 416 F32 X, 417 F32 Y, 418 F32 Z); 419 420extern void AILCALL AIL_API_set_listener_3D_velocity(HDIGDRIVER dig, 421 F32 dX_per_ms, 422 F32 dY_per_ms, 423 F32 dZ_per_ms, 424 F32 magnitude); 425 426extern void AILCALL AIL_API_set_listener_3D_velocity_vector (HDIGDRIVER dig, 427 F32 dX_per_ms, 428 F32 dY_per_ms, 429 F32 dZ_per_ms); 430 431extern void AILCALL AIL_API_set_listener_3D_orientation (HDIGDRIVER dig, 432 F32 X_face, 433 F32 Y_face, 434 F32 Z_face, 435 F32 X_up, 436 F32 Y_up, 437 F32 Z_up); 438 439extern void AILCALL AIL_API_set_sample_3D_volume_falloff (HSAMPLE S, MSSGRAPHPOINT* graph, S32 pointcount); 440extern void AILCALL AIL_API_set_sample_3D_lowpass_falloff (HSAMPLE S, MSSGRAPHPOINT* graph, S32 pointcount); 441extern void AILCALL AIL_API_set_sample_3D_exclusion_falloff (HSAMPLE S, MSSGRAPHPOINT* graph, S32 pointcount); 442extern void AILCALL AIL_API_set_sample_3D_spread_falloff (HSAMPLE S, MSSGRAPHPOINT* graph, S32 pointcount); 443extern void AILCALL AIL_API_set_sample_3D_position_segments (HSAMPLE S, MSSVECTOR3D* points, S32 pointcount); 444extern void AILCALL AIL_API_set_sample_3D_spread (HSAMPLE S, F32 spread); 445 446extern void AILCALL AIL_API_listener_3D_position (HDIGDRIVER dig, 447 F32 *X, 448 F32 *Y, 449 F32 *Z); 450 451extern void AILCALL AIL_API_listener_3D_velocity (HDIGDRIVER dig, 452 F32 *dX_per_ms, 453 F32 *dY_per_ms, 454 F32 *dZ_per_ms); 455 456extern void AILCALL AIL_API_listener_3D_orientation (HDIGDRIVER dig, 457 F32 *X_face, 458 F32 *Y_face, 459 F32 *Z_face, 460 F32 *X_up, 461 F32 *Y_up, 462 F32 *Z_up); 463 464extern void AILCALL AIL_API_update_listener_3D_position (HDIGDRIVER dig, 465 F32 dt_milliseconds); 466 467extern S32 AILCALL AIL_API_calculate_3D_channel_levels (HDIGDRIVER driver, //) 468 F32 *channel_levels, 469 MSS_SPEAKER const * *speaker_array, 470 MSSVECTOR3D *src_pos, 471 MSSVECTOR3D *src_face, 472 MSSVECTOR3D *src_up, 473 F32 src_inner_angle, 474 F32 src_outer_angle, 475 F32 src_outer_volume, 476 F32 src_max_dist, 477 F32 src_min_dist, 478 MSSVECTOR3D *listen_pos, 479 MSSVECTOR3D *listen_face, 480 MSSVECTOR3D *listen_up, 481 F32 rolloff_factor, 482 MSSVECTOR3D *doppler_velocity, 483 F32 *doppler_shift); 484 485 486#ifdef IS_GENERICDIG 487extern HDIGDRIVER AILCALL AIL_API_open_generic_digital_driver( U32 frequency, 488 S32 bits, 489 S32 channel, 490 U32 flags, 491 RADSS_OPEN_FUNC dig_open); 492#else 493extern HDIGDRIVER AILCALL AIL_API_open_digital_driver( U32 frequency, 494 S32 bits, 495 S32 channel, 496 U32 flags ); 497#endif 498 499extern void AILCALL AIL_API_close_digital_driver( HDIGDRIVER dig ); 500 501#if defined(IS_WINDOWS) 502 503extern S32 AILCALL AIL_API_digital_handle_release(HDIGDRIVER drvr); 504 505extern S32 AILCALL AIL_API_digital_handle_reacquire 506 (HDIGDRIVER drvr); 507#endif 508 509#if defined(IS_WINDOWS) || (defined(IS_MAC) && !defined(IS_IPHONE)) 510 511 512extern HDIGINPUT AILCALL AIL_API_open_input (AIL_INPUT_INFO *info); 513 514extern void AILCALL AIL_API_close_input (HDIGINPUT dig); 515 516extern AIL_INPUT_INFO * 517 AILCALL AIL_API_get_input_info (HDIGINPUT dig); 518 519extern S32 AILCALL AIL_API_set_input_state (HDIGINPUT dig, 520 S32 enable); 521 522#endif 523 524#ifdef MSS_FLT_SUPPORTED 525 526void * SS_execute_filter_chain(HSAMPLE S, //) 527 void * src, 528 void * temp_dest, 529 S32 src_bytes, 530 S32 is_stereo, 531 S16 *dest_mono_sample_buffer); 532 533// 534// Internal FLT services 535// 536 537void FLT_init_list(void); 538 539FLTPROVIDER *FLT_find_provider_instance(HPROVIDER provider, 540 HDIGDRIVER dig); 541 542void FLT_disconnect_driver(HDIGDRIVER dig); 543 544void FLT_call_premix_processors(HDIGDRIVER dig); 545 546S32 FLT_call_postmix_processors(HDIGDRIVER dig, void *output_buffer); 547 548// 549// FLT services 550// 551 552extern S32 AILCALL AIL_API_enumerate_filters (HMSSENUM *next, 553 HPROVIDER *dest, 554 C8 * *name); 555 556extern HDRIVERSTATE 557 AILCALL AIL_API_open_filter (HPROVIDER lib, 558 HDIGDRIVER dig); 559 560extern void AILCALL AIL_API_close_filter (HDRIVERSTATE filter); 561 562 563 564 565 566 567extern S32 AILCALL AIL_API_enumerate_filter_attributes 568 (HPROVIDER lib, 569 HMSSENUM * next, 570 RIB_INTERFACE_ENTRY * dest); 571 572extern void AILCALL AIL_API_filter_attribute (HPROVIDER lib, 573 C8 const * name, 574 void * val); 575 576extern void AILCALL AIL_API_set_filter_preference 577 (HPROVIDER lib, 578 C8 const * name, 579 void const * val); 580 581 582 583 584 585extern S32 AILCALL AIL_API_enumerate_filter_sample_attributes 586 (HPROVIDER lib, 587 HMSSENUM * next, 588 RIB_INTERFACE_ENTRY * dest); 589 590extern void AILCALL AIL_API_filter_sample_attribute 591 (HSAMPLE S, 592 C8 const * name, 593 void * val); 594 595extern void AILCALL AIL_API_set_filter_sample_preference 596 (HSAMPLE S, 597 C8 const * name, 598 void const * val); 599#endif 600 601extern S32 AILCALL AIL_API_enumerate_digital_driver_attributes 602 (HDIGDRIVER dig, 603 HMSSENUM * next, 604 RIB_INTERFACE_ENTRY * dest); 605 606extern void AILCALL AIL_API_digital_driver_attribute (HDIGDRIVER dig, 607 C8 const * name, 608 void * val); 609 610extern S32 AILCALL AIL_API_enumerate_digital_driver_preferences 611 (HDIGDRIVER dig, 612 HMSSENUM * next, 613 RIB_INTERFACE_ENTRY * dest); 614 615extern void AILCALL AIL_API_set_digital_driver_preference(HDIGDRIVER dig, 616 C8 const * name, 617 void const * val); 618 619extern S32 AILCALL AIL_API_enumerate_sample_attributes 620 (HSAMPLE S, 621 HMSSENUM * next, 622 RIB_INTERFACE_ENTRY * dest); 623 624extern void AILCALL AIL_API_sample_attribute (HSAMPLE S, 625 C8 const * name, 626 void * val); 627 628extern S32 AILCALL AIL_API_enumerate_sample_preferences 629 (HSAMPLE S, 630 HMSSENUM * next, 631 RIB_INTERFACE_ENTRY * dest); 632 633extern void AILCALL AIL_API_set_sample_preference (HSAMPLE S, 634 C8 const * name, 635 void const * val); 636 637extern S32 AILCALL AIL_API_digital_CPU_percent(HDIGDRIVER dig); 638 639extern S32 AILCALL AIL_API_digital_SPU_percent(HDIGDRIVER dig); 640 641extern S32 AILCALL AIL_API_background_CPU_percent(void); 642 643extern S32 AILCALL AIL_API_digital_latency(HDIGDRIVER dig); 644 645extern HSAMPLE AILCALL AIL_API_allocate_sample_handle 646 (HDIGDRIVER dig); 647 648extern HSAMPLE AILCALL AIL_API_allocate_bus(HDIGDRIVER dig); 649extern HSAMPLE AILCALL AIL_API_bus_sample_handle(HDIGDRIVER dig, S32 bus_index); 650extern S32 AILCALL AIL_API_install_bus_compressor(HDIGDRIVER dig, S32 bus_index, SAMPLESTAGE filter_stage, S32 input_bus_index); 651DXDEC void AILCALL AIL_free_all_busses(HDIGDRIVER dig); // For miles studio. 652 653extern HSAMPLE AILCALL AIL_API_allocate_file_sample 654 (HDIGDRIVER dig, 655 void const *file_image, 656 S32 block); 657 658extern void AILCALL AIL_API_set_speaker_configuration 659 (HDIGDRIVER dig, 660 MSSVECTOR3D *array, 661 S32 n_channels, 662 F32 falloff_power); 663 664extern MSSVECTOR3D * 665 AILCALL AIL_API_speaker_configuration 666 (HDIGDRIVER dig, 667 S32 *n_physical_channels, 668 S32 *n_logical_channels, 669 F32 *falloff_power, 670 MSS_MC_SPEC *channel_spec); 671 672extern void AILCALL AIL_API_set_listener_relative_receiver_array 673 (HDIGDRIVER dig, 674 MSS_RECEIVER_LIST *array, 675 S32 n_receivers); 676 677extern MSS_RECEIVER_LIST * 678 AILCALL AIL_API_listener_relative_receiver_array 679 (HDIGDRIVER dig, 680 S32 *n_receivers); 681 682extern void AILCALL AIL_API_set_speaker_reverb_levels 683 (HDIGDRIVER dig, 684 F32 *wet_array, 685 F32 *dry_array, 686 MSS_SPEAKER const *speaker_index_array, 687 S32 n_levels); 688 689extern S32 AILCALL AIL_API_speaker_reverb_levels (HDIGDRIVER dig, 690 F32 * *wet_array, 691 F32 * *dry_array, 692 MSS_SPEAKER const * *speaker_index_array); 693 694extern void AILCALL AIL_API_release_sample_handle (HSAMPLE S); 695 696extern S32 AILCALL AIL_API_set_sample_file (HSAMPLE S, 697 void const *file_image, 698 S32 block); 699 700extern S32 AILCALL AIL_API_set_sample_info (HSAMPLE S, 701 AILSOUNDINFO const * info); 702 703extern S32 AILCALL AIL_API_set_named_sample_file (HSAMPLE S, 704 C8 const *file_type_suffix, 705 void const *file_image, 706 U32 file_size, 707 S32 block); 708 709extern HPROVIDER AILCALL AIL_API_set_sample_processor (HSAMPLE S, 710 SAMPLESTAGE pipeline_stage, 711 HPROVIDER provider); 712 713extern HPROVIDER AILCALL AIL_API_set_digital_driver_processor 714 (HDIGDRIVER dig, 715 DIGDRVSTAGE pipeline_stage, 716 HPROVIDER provider); 717 718extern HPROVIDER AILCALL AIL_API_sample_processor (HSAMPLE S, 719 SAMPLESTAGE pipeline_stage); 720 721extern HPROVIDER AILCALL AIL_API_digital_driver_processor 722 (HDIGDRIVER dig, 723 DIGDRVSTAGE pipeline_stage); 724 725extern void AILCALL AIL_API_set_sample_address (HSAMPLE S, 726 void const *start, 727 U32 len); 728 729extern S32 AILCALL AIL_API_init_sample (HSAMPLE S, 730 S32 format); 731 732extern void AILCALL AIL_API_set_sample_adpcm_block_size 733 (HSAMPLE S, 734 U32 blocksize); 735 736extern void AILCALL AIL_API_start_sample (HSAMPLE S); 737extern void AILCALL AIL_API_stop_sample (HSAMPLE S); 738extern void AILCALL AIL_API_end_fade_sample (HSAMPLE S); 739extern void AILCALL AIL_API_resume_sample (HSAMPLE S); 740extern void AILCALL AIL_API_end_sample (HSAMPLE S); 741 742extern void AILCALL AIL_API_sample_group_operation (HDIGDRIVER dig, S32 op, S32 start_id, S32 set_to_id); 743extern void AILCALL AIL_API_schedule_start_sample (HSAMPLE S, U64 mix_time_to_start); 744 745extern void AILCALL AIL_API_push_system_state (HDIGDRIVER dig, U32 flags, S16 crossfade_ms); 746extern void AILCALL AIL_API_pop_system_state (HDIGDRIVER dig, S16 crossfade_ms); 747 748extern void AILCALL AIL_API_set_sample_playback_rate 749 (HSAMPLE S, 750 S32 playback_rate); 751 752extern void AILCALL AIL_API_set_sample_playback_rate_factor 753 (HSAMPLE S, 754 F32 playback_rate_factor); 755 756extern void AILCALL AIL_API_set_sample_playback_delay 757 (HSAMPLE S, 758 S32 playback_delay); 759 760extern void AILCALL AIL_API_set_sample_volume_pan (HSAMPLE S, 761 F32 volume, 762 F32 pan); 763 764extern S32 AILCALL AIL_API_sample_channel_count (HSAMPLE S, U32 *mask); 765 766extern S32 AILCALL AIL_API_set_sample_is_3D (HSAMPLE S, //) 767 S32 onoff); 768 769extern void AILCALL AIL_API_set_sample_speaker_scale_factors (HSAMPLE S, //) 770 MSS_SPEAKER const * dest_speaker_indexes, 771 F32 const * levels, 772 S32 n_levels ); 773 774extern void AILCALL AIL_API_sample_speaker_scale_factors (HSAMPLE S, //) 775 MSS_SPEAKER const * dest_speaker_indexes, 776 F32 * levels, 777 S32 n_levels ); 778 779extern void AILCALL AIL_API_set_sample_channel_levels (HSAMPLE S, 780 MSS_SPEAKER const *source_speaker_indexes, 781 MSS_SPEAKER const *dest_speaker_indexes, 782 F32 const *levels, 783 S32 n_levels); 784 785extern void AILCALL AIL_API_sample_channel_levels (HSAMPLE S, 786 MSS_SPEAKER const *source_speaker_indexes, 787 MSS_SPEAKER const *dest_speaker_indexes, 788 F32 *levels, 789 S32 n_levels); 790 791extern F32 AILCALL AIL_API_sample_output_levels (HSAMPLE S, 792 MSS_SPEAKER const *source_speaker_indexes, 793 MSS_SPEAKER const *dest_speaker_indexes, 794 F32 *levels, 795 S32 n_levels); 796 797extern void AILCALL AIL_API_set_sample_51_volume_pan( HSAMPLE S, 798 F32 volume, 799 F32 pan, 800 F32 fb_pan, 801 F32 center_level, 802 F32 sub_level ); 803 804extern void AILCALL AIL_API_sample_51_volume_pan ( HSAMPLE S, 805 F32* volume, 806 F32* pan, 807 F32* fb_pan, 808 F32* center_level, 809 F32* sub_level ); 810 811extern void AILCALL AIL_API_set_sample_51_volume_levels( HSAMPLE S, 812 F32 f_left_level, 813 F32 f_right_level, 814 F32 b_left_level, 815 F32 b_right_level, 816 F32 center_level, 817 F32 sub_level ); 818 819extern void AILCALL AIL_API_sample_51_volume_levels ( HSAMPLE S, 820 F32* f_left_level, 821 F32* f_right_level, 822 F32* b_left_level, 823 F32* b_right_level, 824 F32* center_level, 825 F32* sub_level ); 826extern void AILCALL AIL_API_set_sample_volume_levels(HSAMPLE S, 827 F32 left_level, 828 F32 right_level); 829 830extern void AILCALL AIL_API_set_sample_reverb_levels(HSAMPLE S, 831 F32 dry_level, 832 F32 wet_level); 833 834extern void AILCALL AIL_API_set_sample_low_pass_cut_off( HSAMPLE S, 835 S32 /*-1 or MSS_SPEAKER*/ input_channel, 836 F32 cutoff ); 837 838extern void AILCALL AIL_API_set_sample_loop_count (HSAMPLE S, 839 S32 loop_count); 840 841extern void AILCALL AIL_API_set_sample_loop_block (HSAMPLE S, 842 S32 loop_start_offset, 843 S32 loop_end_offset); 844 845extern S32 AILCALL AIL_API_sample_loop_block (HSAMPLE S, 846 S32 *loop_start_offset, 847 S32 *loop_end_offset); 848 849extern U32 AILCALL AIL_API_sample_status (HSAMPLE S); 850 851extern S32 AILCALL AIL_API_sample_playback_rate (HSAMPLE S); 852 853extern F32 AILCALL AIL_API_sample_playback_rate_factor (HSAMPLE S); 854 855extern S32 AILCALL AIL_API_sample_playback_delay (HSAMPLE S); 856 857extern void AILCALL AIL_API_sample_volume_pan (HSAMPLE S, 858 F32* volume, 859 F32* pan); 860 861extern void AILCALL AIL_API_sample_volume_levels(HSAMPLE S, 862 F32 * left_level, 863 F32 * right_level); 864 865extern void AILCALL AIL_API_sample_reverb_levels(HSAMPLE S, 866 F32 * dry_level, 867 F32 * wet_level); 868 869extern F32 AILCALL AIL_API_sample_low_pass_cut_off(HSAMPLE S, S32 /*-1 or MSS_SPEAKER*/ channel); 870 871extern S32 AILCALL AIL_API_sample_loop_count (HSAMPLE S); 872 873extern void AILCALL AIL_API_set_digital_master_volume_level 874 (HDIGDRIVER dig, 875 F32 master_volume); 876 877extern F32 AILCALL AIL_API_digital_master_volume_level (HDIGDRIVER dig); 878 879extern void AILCALL AIL_API_set_digital_master_volume_levels(HDIGDRIVER dig, 880 F32 left_level, 881 F32 right_level); 882 883extern void AILCALL AIL_API_set_digital_master_reverb_levels(HDIGDRIVER dig, 884 S32 bus_index, 885 F32 dry_level, 886 F32 wet_level); 887 888extern void AILCALL AIL_API_set_digital_master_room_type(HDIGDRIVER dig, 889 S32 bus_index, 890 S32 room_type); 891 892extern void AILCALL AIL_API_digital_master_reverb_levels(HDIGDRIVER dig, 893 S32 bus_index, 894 F32 * dry_level, 895 F32 * wet_level); 896 897extern void AILCALL AIL_API_set_digital_master_reverb(HDIGDRIVER dig, 898 S32 bus_index, 899 F32 reverb_time, 900 F32 reverb_predelay, 901 F32 reverb_damping); 902 903extern void AILCALL AIL_API_digital_master_reverb(HDIGDRIVER dig, 904 S32 bus_index, 905 F32 * reverb_time, 906 F32 * reverb_predelay, 907 F32 * reverb_damping); 908 909extern S32 AILCALL AIL_API_minimum_sample_buffer_size 910 (HDIGDRIVER dig, 911 S32 playback_rate, 912 S32 format); 913 914extern S32 AILCALL AIL_API_set_sample_buffer_count 915 (HSAMPLE S, 916 S32 n_buffers); 917 918extern S32 AILCALL AIL_API_sample_buffer_count (HSAMPLE S); 919 920extern S32 AILCALL AIL_API_sample_buffer_available (HSAMPLE S); 921 922extern S32 AILCALL AIL_API_sample_loaded_len( HSAMPLE S ); 923 924extern S32 AILCALL AIL_API_load_sample_buffer (HSAMPLE S, 925 S32 buff_num, 926 void const *buffer, 927 U32 len); 928 929extern S32 AILCALL AIL_API_sample_buffer_info (HSAMPLE S, 930 S32 buff_num, 931 U32 *pos, 932 U32 *len, 933 S32 *head, 934 S32 *tail); 935 936extern U32 AILCALL AIL_API_sample_granularity (HSAMPLE S); 937 938extern void AILCALL AIL_API_set_sample_position (HSAMPLE S, 939 U32 pos); 940 941extern U32 AILCALL AIL_API_sample_position (HSAMPLE S); 942 943extern AILSAMPLECB AILCALL AIL_API_register_SOB_callback 944 (HSAMPLE S, 945 AILSAMPLECB SOB); 946 947extern AILSAMPLECB AILCALL AIL_API_register_EOB_callback 948 (HSAMPLE S, 949 AILSAMPLECB EOB); 950 951extern AILSAMPLECB AILCALL AIL_API_register_EOS_callback 952 (HSAMPLE S, 953 AILSAMPLECB EOS); 954 955extern AILFALLOFFCB AILCALL AIL_API_register_falloff_function_callback 956 (HSAMPLE S, 957 AILFALLOFFCB falloff_cb); 958 959extern void AILCALL AIL_API_set_sample_user_data (HSAMPLE S, 960 U32 index, 961 SINTa value); 962 963extern SINTa AILCALL AIL_API_sample_user_data (HSAMPLE S, 964 U32 index); 965 966extern S32 AILCALL AIL_API_active_sample_count (HDIGDRIVER dig); 967 968extern void AILCALL AIL_API_digital_configuration (HDIGDRIVER dig, 969 S32 *rate, 970 S32 *format, 971 char *config); 972 973// 974// High-level XMIDI services 975// 976 977#if defined(IS_WINDOWS) 978 979extern S32 AILCALL AIL_API_midiOutOpen (HMDIDRIVER *drvr, 980 LPHMIDIOUT *lphMidiOut, 981 U32 dwDeviceID); 982 983extern void AILCALL AIL_API_midiOutClose (HMDIDRIVER mdi); 984 985 986extern S32 AILCALL AIL_API_MIDI_handle_release (HMDIDRIVER mdi); 987 988extern S32 AILCALL AIL_API_MIDI_handle_reacquire (HMDIDRIVER mdi); 989 990#else 991 992extern HMDIDRIVER AILCALL AIL_API_open_XMIDI_driver( U32 flags ); 993 994extern void AILCALL AIL_API_close_XMIDI_driver( HMDIDRIVER mdi ); 995 996#endif 997 998extern HSEQUENCE AILCALL AIL_API_allocate_sequence_handle 999 (HMDIDRIVER mdi); 1000 1001extern void AILCALL AIL_API_release_sequence_handle 1002 (HSEQUENCE S); 1003 1004extern S32 AILCALL AIL_API_init_sequence (HSEQUENCE S, 1005 void const *start, 1006 S32 sequence_num); 1007 1008extern void AILCALL AIL_API_start_sequence (HSEQUENCE S); 1009extern void AILCALL AIL_API_stop_sequence (HSEQUENCE S); 1010extern void AILCALL AIL_API_resume_sequence (HSEQUENCE S); 1011extern void AILCALL AIL_API_end_sequence (HSEQUENCE S); 1012 1013extern void AILCALL AIL_API_set_sequence_tempo (HSEQUENCE S, 1014 S32 tempo, 1015 S32 milliseconds); 1016 1017extern void AILCALL AIL_API_set_sequence_volume (HSEQUENCE S, 1018 S32 volume, 1019 S32 milliseconds); 1020 1021extern void AILCALL AIL_API_set_sequence_loop_count 1022 (HSEQUENCE S, 1023 S32 loop_count); 1024 1025extern U32 AILCALL AIL_API_sequence_status (HSEQUENCE S); 1026 1027extern S32 AILCALL AIL_API_sequence_tempo (HSEQUENCE S); 1028extern S32 AILCALL AIL_API_sequence_volume (HSEQUENCE S); 1029extern S32 AILCALL AIL_API_sequence_loop_count (HSEQUENCE S); 1030 1031extern void AILCALL AIL_API_set_XMIDI_master_volume 1032 (HMDIDRIVER mdi, 1033 S32 master_volume); 1034 1035extern S32 AILCALL AIL_API_XMIDI_master_volume (HMDIDRIVER mdi); 1036 1037// 1038// Low-level XMIDI services 1039// 1040 1041extern S32 AILCALL AIL_API_active_sequence_count (HMDIDRIVER mdi); 1042 1043extern S32 AILCALL AIL_API_controller_value (HSEQUENCE S, 1044 S32 channel, 1045 S32 controller_num); 1046 1047extern S32 AILCALL AIL_API_channel_notes (HSEQUENCE S, 1048 S32 channel); 1049 1050extern void AILCALL AIL_API_sequence_position (HSEQUENCE S, 1051 S32 *beat, 1052 S32 *measure); 1053 1054extern void AILCALL AIL_API_branch_index (HSEQUENCE S, 1055 U32 marker); 1056 1057extern AILPREFIXCB AILCALL AIL_API_register_prefix_callback 1058 (HSEQUENCE S, 1059 AILPREFIXCB callback); 1060 1061extern AILTRIGGERCB AILCALL AIL_API_register_trigger_callback 1062 (HSEQUENCE S, 1063 AILTRIGGERCB callback); 1064 1065extern AILSEQUENCECB AILCALL AIL_API_register_sequence_callback 1066 (HSEQUENCE S, 1067 AILSEQUENCECB callback); 1068 1069extern AILEVENTCB AILCALL AIL_API_register_event_callback 1070 (HMDIDRIVER mdi, 1071 AILEVENTCB callback); 1072 1073extern AILBEATCB AILCALL AIL_API_register_beat_callback 1074 (HSEQUENCE S, 1075 AILBEATCB callback); 1076 1077extern AILTIMBRECB AILCALL AIL_API_register_timbre_callback 1078 (HMDIDRIVER mdi, 1079 AILTIMBRECB callback); 1080 1081extern void AILCALL AIL_API_set_sequence_user_data(HSEQUENCE S, 1082 U32 index, 1083 SINTa value); 1084 1085extern SINTa AILCALL AIL_API_sequence_user_data (HSEQUENCE S, 1086 U32 index); 1087 1088extern void AILCALL AIL_API_register_ICA_array (HSEQUENCE S, 1089 U8 *array); 1090 1091extern S32 AILCALL AIL_API_lock_channel (HMDIDRIVER mdi); 1092 1093extern void AILCALL AIL_API_release_channel (HMDIDRIVER mdi, 1094 S32 channel); 1095 1096extern void AILCALL AIL_API_map_sequence_channel (HSEQUENCE S, 1097 S32 seq_channel, 1098 S32 new_channel); 1099 1100extern S32 AILCALL AIL_API_true_sequence_channel (HSEQUENCE S, 1101 S32 seq_channel); 1102 1103extern void AILCALL AIL_API_send_channel_voice_message 1104 (HMDIDRIVER mdi, 1105 HSEQUENCE S, 1106 S32 status, 1107 S32 data_1, 1108 S32 data_2); 1109 1110extern void AILCALL AIL_API_send_sysex_message (HMDIDRIVER mdi, 1111 void const *buffer); 1112 1113extern HWAVESYNTH 1114 AILCALL AIL_API_create_wave_synthesizer (HDIGDRIVER dig, 1115 HMDIDRIVER mdi, 1116 void const *wave_lib, 1117 S32 polyphony); 1118 1119extern void AILCALL AIL_API_destroy_wave_synthesizer(HWAVESYNTH W); 1120 1121extern S32 AILCALL AIL_API_MIDI_to_XMI (void const* MIDI, 1122 U32 MIDI_size, 1123 void**XMIDI, 1124 U32 * XMIDI_size, 1125 S32 flags); 1126 1127#if defined(IS_WIN32) 1128 1129extern S32 AILCALL AIL_API_list_MIDI (void const* MIDI, 1130 U32 MIDI_size, 1131 char* *list, 1132 U32 * list_size, 1133 S32 flags); 1134 1135extern S32 AILCALL AIL_API_list_DLS (void const* DLS, 1136 char**list, 1137 U32 * list_size, 1138 S32 flags, 1139 C8 * title); 1140 1141#endif 1142 1143extern char* AILCALL AIL_API_last_error ( void ); 1144 1145extern void AILCALL AIL_API_set_error ( char const* error_msg ); 1146 1147extern S32 AILCALL AIL_API_file_error (void); 1148 1149extern S32 AILCALL AIL_API_file_size (char const *filename, 1150 char const * caller, 1151 U32 caller_line); 1152 1153extern void * AILCALL AIL_API_file_read (char const *filename, 1154 void *dest, 1155 char const * caller, 1156 U32 caller_line); 1157 1158extern S32 AILCALL AIL_API_file_write (char const *filename, 1159 void const *buf, 1160 U32 len); 1161 1162extern S32 AILCALL AIL_API_WAV_file_write (char const *filename, 1163 void const *buf, 1164 U32 len, 1165 S32 rate, 1166 S32 format); 1167 1168extern void AILCALL AIL_API_serve (void); 1169 1170 1171#ifdef IS_WINDOWS 1172 1173extern HREDBOOK AILCALL AIL_API_redbook_open (U32 which); 1174 1175extern HREDBOOK AILCALL AIL_API_redbook_open_drive(S32 drive); 1176 1177extern void AILCALL AIL_API_redbook_close (HREDBOOK hand); 1178 1179extern void AILCALL AIL_API_redbook_eject (HREDBOOK hand); 1180 1181extern void AILCALL AIL_API_redbook_retract (HREDBOOK hand); 1182 1183extern U32 AILCALL AIL_API_redbook_status (HREDBOOK hand); 1184 1185extern U32 AILCALL AIL_API_redbook_tracks (HREDBOOK hand); 1186 1187extern U32 AILCALL AIL_API_redbook_track (HREDBOOK hand); 1188 1189extern void AILCALL AIL_API_redbook_track_info (HREDBOOK hand, 1190 U32 tracknum, 1191 U32* startmsec, 1192 U32* endmsec); 1193 1194extern U32 AILCALL AIL_API_redbook_id (HREDBOOK hand); 1195 1196extern U32 AILCALL AIL_API_redbook_position (HREDBOOK hand); 1197 1198extern U32 AILCALL AIL_API_redbook_play (HREDBOOK hand, 1199 U32 startmsec, 1200 U32 endmsec); 1201 1202extern U32 AILCALL AIL_API_redbook_stop (HREDBOOK hand); 1203 1204extern U32 AILCALL AIL_API_redbook_pause (HREDBOOK hand); 1205 1206extern U32 AILCALL AIL_API_redbook_resume (HREDBOOK hand); 1207 1208extern F32 AILCALL AIL_API_redbook_volume_level (HREDBOOK hand); 1209 1210extern F32 AILCALL AIL_API_redbook_set_volume_level(HREDBOOK hand, 1211 F32 volume); 1212 1213#endif 1214 1215extern S32 AILCALL AIL_API_quick_startup (S32 use_digital, 1216 S32 use_MIDI, 1217 U32 output_rate, 1218 S32 output_bits, 1219 S32 output_channels); 1220 1221extern void AILCALL AIL_API_quick_shutdown (void); 1222 1223extern void AILCALL AIL_API_quick_handles (HDIGDRIVER* pdig, 1224 HMDIDRIVER* pmdi, 1225 HDLSDEVICE* pdls); 1226 1227extern HAUDIO AILCALL AIL_API_quick_load (char const *filename); 1228 1229extern HAUDIO AILCALL AIL_API_quick_load_mem (void const *mem, 1230 U32 size); 1231 1232extern HAUDIO AILCALL AIL_API_quick_load_named_mem(void const *mem, 1233 char const *filename, 1234 U32 size); 1235 1236extern void AILCALL AIL_API_quick_unload (HAUDIO audio); 1237 1238extern S32 AILCALL AIL_API_quick_play (HAUDIO audio, 1239 U32 loop_count); 1240 1241extern void AILCALL AIL_API_quick_halt (HAUDIO audio); 1242 1243extern S32 AILCALL AIL_API_quick_status (HAUDIO audio); 1244 1245extern HAUDIO AILCALL AIL_API_quick_load_and_play (char const *filename, 1246 U32 loop_count, 1247 S32 wait_request); 1248 1249extern void AILCALL AIL_API_quick_set_speed (HAUDIO audio, 1250 S32 speed); 1251 1252extern void AILCALL AIL_API_quick_set_volume (HAUDIO audio, 1253 F32 volume, 1254 F32 extravol); 1255 1256extern void AILCALL AIL_API_quick_set_reverb_levels(HAUDIO audio, 1257 F32 dry_level, 1258 F32 wet_level); 1259 1260extern void AILCALL AIL_API_quick_set_low_pass_cut_off(HAUDIO audio, 1261 S32 channel, 1262 F32 cut_off); 1263 1264extern HAUDIO AILCALL AIL_API_quick_copy (HAUDIO hand); 1265 1266extern void AILCALL AIL_API_quick_set_ms_position (HAUDIO audio, 1267 S32 milliseconds); 1268 1269extern S32 AILCALL AIL_API_quick_ms_position (HAUDIO audio); 1270 1271extern S32 AILCALL AIL_API_quick_ms_length (HAUDIO audio); 1272 1273extern S32 AILCALL AIL_API_quick_type (HAUDIO audio); 1274 1275// 1276// High-level streaming services 1277// 1278 1279void AILSTRM_shutdown(HDIGDRIVER driver); 1280 1281extern HSTREAM AILCALL AIL_API_open_stream (HDIGDRIVER dig, 1282 char const* filename, 1283 S32 stream_mem); 1284 1285extern void AILCALL AIL_API_close_stream (HSTREAM stream); 1286 1287extern S32 AILCALL AIL_API_service_stream (HSTREAM stream, 1288 S32 fillup); 1289 1290extern void AILCALL AIL_API_start_stream (HSTREAM stream); 1291 1292extern void AILCALL AIL_API_pause_stream (HSTREAM stream, 1293 S32 onoff); 1294 1295extern void AILCALL AIL_API_set_stream_loop_block (HSTREAM S, 1296 S32 loop_start_offset, 1297 S32 loop_end_offset); 1298 1299extern S32 AILCALL AIL_API_stream_loop_count (HSTREAM stream); 1300 1301extern void AILCALL AIL_API_set_stream_loop_count (HSTREAM stream, 1302 S32 count); 1303 1304extern S32 AILCALL AIL_API_stream_status (HSTREAM stream); 1305 1306extern F32 AILCALL AIL_API_stream_filled_percent (HSTREAM stream); 1307 1308extern void AILCALL AIL_API_set_stream_position (HSTREAM stream, 1309 S32 offset); 1310 1311extern S32 AILCALL AIL_API_stream_position (HSTREAM stream); 1312 1313extern void AILCALL AIL_API_stream_info (HSTREAM stream, 1314 S32* datarate, 1315 S32* sndtype, 1316 S32* length, 1317 S32* memory); 1318 1319extern void AILCALL AIL_API_auto_service_stream (HSTREAM stream, 1320 S32 onoff); 1321 1322extern AILSTREAMCB AILCALL AIL_API_register_stream_callback 1323 (HSTREAM stream, 1324 AILSTREAMCB callback); 1325 1326extern void AILCALL AIL_API_set_stream_user_data (HSTREAM S, 1327 U32 index, 1328 SINTa value); 1329 1330extern SINTa AILCALL AIL_API_stream_user_data (HSTREAM S, 1331 U32 index); 1332 1333extern S32 AILCALL AIL_API_size_processed_digital_audio( 1334 U32 dest_rate, 1335 U32 dest_format, 1336 S32 num_srcs, 1337 AILMIXINFO const* src); 1338 1339extern S32 AILCALL AIL_API_process_digital_audio( 1340 void *dest_buffer, 1341 S32 dest_buffer_size, 1342 U32 dest_rate, 1343 U32 dest_format, 1344 S32 num_srcs, 1345 AILMIXINFO* src); 1346 1347extern HDLSDEVICE AILCALL AIL_API_DLS_open (HMDIDRIVER mdi, 1348 HDIGDRIVER dig, 1349#ifdef IS_STATIC 1350 AILSTATICDLS const* dls, 1351#else 1352 char const* libname, 1353#endif 1354 U32 flags, 1355 U32 rate, 1356 S32 bits, 1357 S32 channels); 1358 1359 1360extern void AILCALL AIL_API_DLS_close (HDLSDEVICE dls, 1361 U32 flags); 1362 1363extern HDLSFILEID AILCALL AIL_API_DLS_load_file (HDLSDEVICE dls, 1364 char const* filename, 1365 U32 flags); 1366 1367extern HDLSFILEID AILCALL AIL_API_DLS_load_memory (HDLSDEVICE dls, 1368 void const* memfile, 1369 U32 flags); 1370 1371extern void AILCALL AIL_API_DLS_unload (HDLSDEVICE dls, 1372 HDLSFILEID dlsid); 1373 1374extern void AILCALL AIL_API_DLS_compact (HDLSDEVICE dls); 1375 1376extern void AILEXPORT AIL_API_DLS_set_reverb_levels(HDLSDEVICE dls, 1377 F32 dry_level, 1378 F32 wet_level); 1379 1380extern void AILEXPORT AIL_API_DLS_get_reverb_levels(HDLSDEVICE dls, 1381 F32* dry_level, 1382 F32* wet_level); 1383 1384extern void AILCALL AIL_API_DLS_get_info (HDLSDEVICE dls, 1385 AILDLSINFO* info, 1386 S32* PercentCPU); 1387 1388extern S32 AILCALL AIL_API_extract_DLS (void const*source_image, //) 1389 U32 source_size, 1390 void * *XMI_output_data, 1391 U32 *XMI_output_size, 1392 void * *DLS_output_data, 1393 U32 *DLS_output_size, 1394 AILLENGTHYCB callback); 1395 1396extern void AILCALL AIL_API_set_sequence_ms_position 1397 (HSEQUENCE S, //) 1398 S32 milliseconds); 1399 1400extern void AILCALL AIL_API_sequence_ms_position (HSEQUENCE S, //) 1401 S32 *total_milliseconds, 1402 S32 *current_milliseconds); 1403 1404extern void AILCALL AIL_API_set_sample_ms_position(HSAMPLE S, //) 1405 S32 milliseconds); 1406 1407extern void AILCALL AIL_API_sample_ms_position (HSAMPLE S, //) 1408 S32 *total_milliseconds, 1409 S32 *current_milliseconds); 1410 1411extern U32 AILCALL AIL_API_sample_ms_lookup (HSAMPLE S, //) 1412 S32 milliseconds, 1413 S32* actualms); 1414 1415extern void AILCALL AIL_API_set_stream_ms_position(HSTREAM S, //) 1416 S32 milliseconds); 1417 1418extern void AILCALL AIL_API_stream_ms_position (HSTREAM S, //) 1419 S32 *total_milliseconds, 1420 S32 *current_milliseconds); 1421 1422extern S32 AILCALL AIL_API_WAV_info (void const* data, 1423 AILSOUNDINFO* info); 1424 1425extern S32 AILCALL AIL_API_compress_ADPCM (AILSOUNDINFO const* info, //) 1426 void** outdata, U32* outsize); 1427 1428extern S32 AILCALL AIL_API_decompress_ADPCM (AILSOUNDINFO const* info, 1429 void** outdata, 1430 U32* outsize); 1431 1432extern S32 AILCALL AIL_API_file_type (void const* data, 1433 U32 size); 1434 1435extern S32 AILCALL AIL_API_file_type_named (void const* data, 1436 char const* filename, 1437 U32 size); 1438 1439extern S32 AILCALL AIL_API_find_DLS (void const* data, 1440 U32 size, 1441 void**xmi, 1442 U32* xmisize, 1443 void**dls, 1444 U32* dlssize); 1445 1446// 1447// Internal MSS mixer RIB calls 1448// 1449 1450extern U32 AILCALL MSS_MMX_available (void); 1451 1452extern void AILCALL MSS_mixer_startup (void); 1453extern void AILCALL MSS_mixer_shutdown (void); 1454 1455extern void AILCALL MSS_mixer_flush(S32 *dest, 1456 S32 len 1457#ifdef IS_X86 1458 ,U32 MMX_available 1459#endif 1460 ); 1461 1462extern void AILCALL MSS_mixer_merge(void const * *src, 1463 U32 *src_fract, 1464 void const *src_end, 1465 S32 * *dest, 1466 void *dest_end, 1467 S32 *left_val, 1468 S32 *right_val, 1469 S32 playback_ratio, 1470 S32 scale_left, 1471 S32 scale_right, 1472 U32 operation 1473#ifdef IS_X86 1474 ,U32 MMX_available 1475#endif 1476 ); 1477 1478extern void AILCALL MSS_mixer_copy(void const *src, 1479 S32 src_len, 1480 void *dest, 1481 U32 operation 1482#ifdef IS_BE 1483 ,S32 big_endian_output 1484#else 1485#ifdef IS_X86 1486 ,U32 MMX_available 1487#endif 1488#endif 1489 ); 1490 1491extern void AILCALL SS_set_speaker_configuration (D3DSTATE *D3D, 1492 MSSVECTOR3D *speaker_positions, 1493 S32 n_channels, 1494 S32 logical_channels_per_sample); 1495 1496extern void SS_calculate_3D_channel_levels(D3DSTATE const *D3D, 1497 S32 logical_channels_per_sample, 1498 S3DSTATE *S3D, 1499 F32 *channel_levels); 1500 1501extern void AILCALL SS_update_driver_reverb_state(HDIGDRIVER dig); 1502 1503extern void AILCALL SS_update_sample_reverb_state(HSAMPLE S); 1504 1505extern void AILCALL SS_flush (HDIGDRIVER dig, S32 reverb_index); 1506 1507extern void AILCALL SS_copy (HDIGDRIVER dig, S32 reverb_index, void *lpWaveAddr); 1508 1509 1510extern F32 AILCALLBACK SS_default_falloff_function_callback(HSAMPLE S, //) 1511 F32 distance, 1512 F32 rolloff_factor, 1513 F32 min_dist, 1514 F32 max_dist); 1515extern S32 AILCALLBACK SS_stream_to_buffer(HSAMPLE S, 1516 S16 *dest_mono_sample_buffer, 1517 S32 dest_buffer_size); 1518 1519 1520#ifdef MILES10 1521extern void SS_fill(HDIGDRIVER dig); 1522#else 1523extern void SS_fill(HDIGDRIVER dig, void *lpData); 1524#endif 1525 1526extern void AILCALL SS_start_DIG_driver_playback(HSAMPLE S); 1527 1528extern S32 AILCALL SS_set_sample_type( HSAMPLE S, S32 format, U32 channel_mask ); 1529 1530extern void AILCALL AIL_apply_reverb( HDIGDRIVER dig ); 1531 1532extern S32 AILCALL AIL_allocate_reverb_buffers( HDIGDRIVER dig, S32 index ); 1533 1534extern void AILCALL AIL_apply_lowpass( void* dest, void const* src, void const* src_end, LOWPASS_INFO* lp_in, S32 op ); 1535 1536 1537#if defined(IS_WIN32) || defined(IS_GENERICDIG) 1538extern S32 AILCALL get_system_speaker_configuration(MSS_MC_SPEC *channel_spec); 1539#endif 1540 1541 1542#ifdef IS_BE 1543 1544 #ifdef IS_PPC 1545 1546 #ifdef IS_XENON 1547 1548 #define LE_SWAP32( ptr ) __loadwordbytereverse(0,ptr) 1549 1550 #define LE_SWAP32_OFS( ptr,ofs ) __loadwordbytereverse(ofs,ptr) 1551 1552 #define STORE_LE_SWAP32( ptr, val ) __storewordbytereverse ( (U32)(val), 0, ptr ) 1553 1554 #elif (defined(IS_PS3) && !defined(IS_SPU)) || defined(IS_MAC) 1555 #define LE_SWAP32( ptr ) ld_le32(ptr) 1556 #define LE_SWAP32_OFS( ptr, ofs ) ld_le32_ofs(ptr,ofs) 1557 // the char* is not required, but works around a GCC bug 1558 #define STORE_LE_SWAP32( ptr, val ) st_le32( (char*)(ptr), (U32)(val) ) 1559 #elif defined(IS_WIIU) 1560 1561 #define LE_SWAP32(ptr) (*(__bytereversed unsigned int *)(ptr)) 1562 #define LE_SWAP32_OFS(ptr, ofs) (*(__bytereversed unsigned int *)AIL_ptr_add(ptr, ofs)) 1563 1564 #define STORE_LE_SWAP32( ptr, val ) (*(__bytereversed unsigned int *)(ptr) = (val)) 1565 1566 #define STORE_LE_SWAP16_OFS( ptr, val, const_ofs ) (*(__bytereversed unsigned short*)(AIL_ptr_add(ptr, const_ofs))) = (val) 1567 #else 1568 #define LE_SWAP32( ptr ) __lwbrx((void*)(ptr),0) 1569 #define LE_SWAP32_OFS( ptr,ofs ) __lwbrx((void*)(ptr),ofs) 1570 1571 #define STORE_LE_SWAP32( ptr, val ) __stwbrx( (U32)(val), ptr, 0 ) 1572 #endif 1573 1574 #elif defined(IS_SPU) 1575 1576 static U32 inline LE_SWAP32(void const * src) __attribute__((always_inline)); 1577 static U32 inline LE_SWAP32(void const * src) 1578 { 1579 U32 i = (*((U32*)src)); 1580 vec_uint4 v = spu_promote( i, 0 ); 1581 v = (vec_uint4)spu_shuffle( v, v, ((vec_uchar16){ 3, 2, 1, 0, 4, 5, 6, 7, 1582 8, 9, 10, 11, 12, 13, 14, 15})); 1583 i = spu_extract( v, 0 ); 1584 return i; 1585 } 1586 1587 static U32 inline LE_SWAP32_OFS(void const * src,S32 ofs) __attribute__((always_inline)); 1588 static U32 inline LE_SWAP32_OFS(void const * src,S32 ofs) 1589 { 1590 U32 i = (*((U32*)(((char*)src)+ofs))); 1591 vec_uint4 v = spu_promote( i, 0 ); 1592 v = (vec_uint4)spu_shuffle( v, v, ((vec_uchar16){ 3, 2, 1, 0, 4, 5, 6, 7, 1593 8, 9, 10, 11, 12, 13, 14, 15})); 1594 i = spu_extract( v, 0 ); 1595 return i; 1596 } 1597 1598 #define STORE_LE_SWAP32( ptr, val )\ 1599 { \ 1600 U32 tmp = (U32) val; \ 1601 vec_uint4 v = spu_promote( tmp, 0 ); \ 1602 v = (vec_uint4)spu_shuffle( v, v, ((vec_uchar16){ 3, 2, 1, 0, 4, 5, 6, 7, \ 1603 8, 9, 10, 11, 12, 13, 14, 15})); \ 1604 tmp = spu_extract( v, 0 ); \ 1605 *((U32 *)(((char*)ptr)+0)) = tmp; \ 1606 } 1607 1608 #define STORE_LE_SWAP32_OFS( ptr, val, ofs )\ 1609 { \ 1610 U32 tmp = (U32) val; \ 1611 vec_uint4 v = spu_promote( tmp, 0 ); \ 1612 v = (vec_uint4)spu_shuffle( v, v, ((vec_uchar16){ 3, 2, 1, 0, 4, 5, 6, 7, \ 1613 8, 9, 10, 11, 12, 13, 14, 15})); \ 1614 tmp = spu_extract( v, 0 ); \ 1615 *((U32 *)(((char*)ptr)+ofs)) = tmp; \ 1616 } 1617 1618 #else 1619 1620 #define LE_SWAP32(ptr) \ 1621 ( ( ( ( *((U32 *)(ptr) ) ) << 24 ) ) | \ 1622 ( ( ( *((U32 *)(ptr) ) ) << 8 ) & 0x00FF0000 ) | \ 1623 ( ( ( *((U32 *)(ptr) ) ) >> 8 ) & 0x0000FF00 ) | \ 1624 ( ( ( *((U32 *)(ptr) ) ) >> 24 ) ) ) 1625 1626 #define LE_SWAP32_OFS(ptr,ofs) \ 1627 ( ( ( ( *((U32 *)AIL_ptr_add(ptr,ofs) ) ) << 24 ) ) | \ 1628 ( ( ( *((U32 *)AIL_ptr_add(ptr,ofs) ) ) << 8 ) & 0x00FF0000 ) | \ 1629 ( ( ( *((U32 *)AIL_ptr_add(ptr,ofs) ) ) >> 8 ) & 0x0000FF00 ) | \ 1630 ( ( ( *((U32 *)AIL_ptr_add(ptr,ofs) ) ) >> 24 ) ) ) 1631 1632 #define STORE_LE_SWAP32( ptr, val ) { *((U32 *)ptr) = \ 1633 ( ( ( ( ((U32)(val) ) ) << 24 ) ) | \ 1634 ( ( ( ((U32)(val) ) ) << 8 ) & 0x00FF0000 ) | \ 1635 ( ( ( ((U32)(val) ) ) >> 8 ) & 0x0000FF00 ) | \ 1636 ( ( ( ((U32)(val) ) ) >> 24 ) ) ); } 1637 1638 #endif 1639 1640 #if defined( IS_PPC ) 1641 1642 #ifdef IS_XENON 1643 unsigned short __loadshortbytereverse (int offset, const void * base); 1644 unsigned long __loadwordbytereverse (int offset, const void * base); 1645 1646 void __storeshortbytereverse (unsigned short val, int offset, void * base); 1647 void __storewordbytereverse (unsigned int val, int offset, void * base); 1648 1649 #define LE_SWAP16( ptr ) __loadshortbytereverse (0,(S16 *)ptr) 1650 1651 #define LE_SWAP16_OFS( ptr, const_ofs ) __loadshortbytereverse (const_ofs,(S16 *)ptr) 1652 1653 #define STORE_LE_SWAP16( ptr, val ) __storeshortbytereverse ( (U16)(val), 0, (S16 *)ptr ) 1654 1655 #define STORE_LE_SWAP16_OFS( ptr, val, const_ofs ) __storeshortbytereverse ( (U16)(val), const_ofs, (S16 *)ptr ) 1656 #else 1657 1658 #if (defined(IS_PS3) && !defined(IS_SPU)) || defined(IS_MAC) 1659 1660 #define __fsel( outf, cmp, inf1, inf2 ) \ 1661 __asm__ __volatile__ ("fsel %0,%1,%2,%3" : "=f" (outf) : "f" (cmp), "f" (inf1), "f" (inf2)); 1662 1663 static inline float fclip1(float sample ) 1664 { 1665 float ret; 1666 1667 __fsel( ret, sample + 1.0f, sample, -1.0f ); 1668 __fsel( ret, sample - 1.0f, 1.0f, ret ); 1669 return( ret ); 1670 } 1671 1672 static __inline__ U16 ld_le16(const S16 *addr) 1673 { 1674 U16 val; 1675 __asm__ __volatile__ ("lhbrx %0,0,%1" : "=r" (val) : "r" (addr)); 1676 return val; 1677 } 1678 1679 static __inline__ U16 ld_le16_ofs(const S16 *addr, U64 const_ofs ) 1680 { 1681 U16 val; 1682 __asm__ __volatile__ ("lhbrx %0,%1,%2" : "=r" (val) : "b" (const_ofs), "r" (addr)); 1683 return val; 1684 } 1685 1686 static __inline__ void st_le16(S16 *addr, const U16 val) 1687 { 1688 __asm__ __volatile__ ("sthbrx %1,0,%2" : "=m" (*addr) : "r" (val), "r" (addr)); 1689 } 1690 1691 static __inline__ void st_le16_ofs(S16 *addr, U64 const_ofs, const U16 val) 1692 { 1693 __asm__ __volatile__ ("sthbrx %2,%1,%3" : "=m" (*addr) : "b" (const_ofs), "r" (val), "r" (addr)); 1694 } 1695 1696 static __inline__ U32 ld_le32(const void *addr) 1697 { 1698 U32 val; 1699 1700 __asm__ __volatile__ ("lwbrx %0,0,%1" : "=r" (val) : "r" ((U32*)addr) ); 1701 return val; 1702 } 1703 1704 static __inline__ U32 ld_le32_ofs(const void *addr, U64 const_ofs ) 1705 { 1706 U32 val; 1707 __asm__ __volatile__ ("lwbrx %0,%1,%2" : "=r" (val) : "b" (const_ofs), "r" (addr)); 1708 return val; 1709 } 1710 1711/* static __inline__ void st_le32_ofs(void *addr, U64 const_ofs, const U32 val) 1712 { 1713 __asm__ __volatile__ ("stwbrx %2,%1,%3" : "=m" (*(U32*)addr) : "b" (const_ofs), "r" (val), "r" ((U32*)addr)); 1714 }*/ 1715 1716 static __inline__ void st_le32(void *addr, const U32 val) 1717 { //todo, weird hacks to make this work with GCC 1718 __asm__ __volatile__ ("stwbrx %1,%3,%2" : "=m" (*(U32*)addr) : "r" (val), "r" ((U32*)addr), "O"(0) ); 1719 } 1720 1721 #define LE_SWAP16( ptr ) ld_le16 ((S16 *)ptr) 1722 1723 #define LE_SWAP16_OFS( ptr, const_ofs ) ld_le16_ofs ((S16 *)ptr, const_ofs) 1724 1725 #define STORE_LE_SWAP16( ptr, val ) st_le16( (S16 *)ptr, (U16)(val) ) 1726 1727 #define STORE_LE_SWAP16_OFS( ptr, val, const_ofs ) st_le16_ofs( (S16 *)ptr, const_ofs, (U16)(val) ) 1728 #elif defined(IS_WIIU) 1729 1730 #define LE_SWAP16(ptr) (*(__bytereversed unsigned short *)(ptr)) 1731 #define LE_SWAP16_OFS(ptr, ofs) (*(__bytereversed unsigned short *)AIL_ptr_add(ptr, ofs)) 1732 1733 #define STORE_LE_SWAP16( ptr, val ) (*(__bytereversed unsigned short *)(ptr) = (val)) 1734 1735 #else 1736 #define LE_SWAP16( ptr ) __lhbrx((S16 *)ptr,0) 1737 1738 #define LE_SWAP16_OFS( ptr, const_ofs ) __lhbrx((S16 *)ptr,const_ofs) 1739 1740 #define STORE_LE_SWAP16( ptr, val ) __sthbrx( (U16)(val), (S16 *)ptr, 0 ) 1741 1742 #define STORE_LE_SWAP16_OFS( ptr, val, const_ofs ) __sthbrx( (U16)(val), (S16 *)ptr, const_ofs ) 1743 #endif 1744 #endif 1745 1746 #elif defined( IS_SPU ) 1747 1748 static U32 inline LE_SWAP16(void const * src) __attribute__((always_inline)); 1749 static U32 inline LE_SWAP16(void const * src) 1750 { 1751 U32 i = (*((U16*)src)); 1752 vec_uint4 v = spu_promote( i, 0 ); 1753 v = (vec_uint4)spu_shuffle( v, v, ((vec_uchar16){ 0, 1, 3, 2, 4, 5, 6, 7, 1754 8, 9, 10, 11, 12, 13, 14, 15})); 1755 i = spu_extract( v, 0 ); 1756 return i; 1757 } 1758 1759 static U32 inline LE_SWAP16_OFS(void const * src, S32 ofs) __attribute__((always_inline)); 1760 static U32 inline LE_SWAP16_OFS(void const * src, S32 ofs) 1761 { 1762 U32 i = (*((U16*)(((char*)src)+ofs))); 1763 vec_uint4 v = spu_promote( i, 0 ); 1764 v = (vec_uint4)spu_shuffle( v, v, ((vec_uchar16){ 0, 1, 3, 2, 4, 5, 6, 7, 1765 8, 9, 10, 11, 12, 13, 14, 15})); 1766 i = spu_extract( v, 0 ); 1767 return i; 1768 } 1769 1770 #define STORE_LE_SWAP16( ptr, val )\ 1771 { \ 1772 U32 tmp = (U16) val; \ 1773 vec_uint4 v = spu_promote( tmp, 0 ); \ 1774 v = (vec_uint4)spu_shuffle( v, v, ((vec_uchar16){ 0, 1, 3, 2, 4, 5, 6, 7, \ 1775 8, 9, 10, 11, 12, 13, 14, 15})); \ 1776 tmp = spu_extract( v, 0 ); \ 1777 *((U16 *)(((char*)ptr)+0)) = tmp; \ 1778 } 1779 1780 #define STORE_LE_SWAP16_OFS( ptr, val, ofs )\ 1781 { \ 1782 U32 tmp = (U16) val; \ 1783 vec_uint4 v = spu_promote( tmp, 0 ); \ 1784 v = (vec_uint4)spu_shuffle( v, v, ((vec_uchar16){ 0, 1, 3, 2, 4, 5, 6, 7, \ 1785 8, 9, 10, 11, 12, 13, 14, 15})); \ 1786 tmp = spu_extract( v, 0 ); \ 1787 *((U16 *)(((char*)ptr)+ofs)) = tmp;\ 1788 } 1789 1790 #else 1791 1792 #define LE_SWAP16(ptr) \ 1793 ( ( U16 ) \ 1794 ( ( ( ( *((U16 *)(ptr) ) ) << 8 ) ) | \ 1795 ( ( ( *((U16 *)(ptr) ) ) >> 8 ) ) ) \ 1796 ) 1797 1798 #define LE_SWAP16_OFS(ptr,const_ofs) \ 1799 ( ( U16 ) \ 1800 ( ( ( ( *((U16 *)(AIL_ptr_add(ptr,const_ofs)) ) ) << 8 ) ) | \ 1801 ( ( ( *((U16 *)(AIL_ptr_add(ptr,const_ofs)) ) ) >> 8 ) ) ) \ 1802 ) 1803 1804 #define STORE_LE_SWAP16( ptr, val ) { *((U16*)ptr) = ( \ 1805 ( ( ( ((U16)(val) ) ) << 8 ) ) | \ 1806 ( ( ( ((U16)(val) ) ) >> 8 ) ) ); } 1807 1808 #define STORE_LE_SWAP16_OFS( ptr, val, const_ofs ) { *((U16*)AIL_ptr_add(ptr,const_ofs)) = ( \ 1809 ( ( ( ((U16)(val) ) ) << 8 ) ) | \ 1810 ( ( ( ((U16)(val) ) ) >> 8 ) ) ); } 1811 1812 #endif 1813 1814 #define BE_SWAP32( ptr ) ( *((U32 *)(ptr) ) ) 1815 #define BE_SWAP16( ptr ) ( *((U16 *)(ptr) ) ) 1816 1817 #define MEM_LE_SWAP32(n) *((U32*)n) = LE_SWAP32(n); 1818 #define MEM_LE_SWAP16(n) *((U16*)n) = (U16) LE_SWAP16(n); 1819 1820 #define MEM_BE_SWAP32(n) 1821 #define MEM_BE_SWAP16(n) 1822 1823 // unaligned versions 1824 #define BEU_SWAP32( ptr ) ( *((U32 *)(ptr) ) ) 1825 #define BEU_SWAP16( ptr ) ( *((U16 *)(ptr) ) ) 1826 1827 #define LEU_SWAP32(ptr) LE_SWAP32(ptr) 1828 #define LEU_SWAP16(ptr) LE_SWAP16(ptr) 1829 1830 #define STORE_LEU_SWAP32( ptr, val ) STORE_LE_SWAP32( ptr, val ) 1831 #define STORE_LEU_SWAP16( ptr, val ) STORE_LE_SWAP16( ptr, val ) 1832 1833 #define MEM_LEU_SWAP32(n) *((U32*)n) = LEU_SWAP32(n); 1834 #define MEM_LEU_SWAP16(n) *((U32*)n) = LEU_SWAP32(n); 1835 1836#else // IS_BE 1837 1838 #define LE_SWAP32( ptr ) ( *((U32 *)(ptr) ) ) 1839 #define LE_SWAP32_OFS( ptr,const_ofs ) ( *((U32 *)AIL_ptr_add(ptr,const_ofs) ) ) 1840 #define LE_SWAP16( ptr ) ( *((U16 *)(ptr) ) ) 1841 1842 #define LE_SWAP16_OFS( ptr, const_ofs ) ( *((U16 *)(AIL_ptr_add(ptr,const_ofs)) ) ) 1843 1844 #define STORE_LE_SWAP32( ptr, val ) { *((U32*)(ptr))=(U32)(val); } 1845 #define STORE_LE_SWAP16( ptr, val ) { *((U16*)(ptr))=(U16)(val); } 1846 #define STORE_LE_SWAP16_OFS( ptr, val, const_ofs ) { *((U16*)((((U8*)ptr)+const_ofs)))=(U16)(val); } 1847 1848 #define BE_SWAP32(ptr) \ 1849 ( ( ( ( *((U32 *)(ptr) ) ) << 24 ) ) | \ 1850 ( ( ( *((U32 *)(ptr) ) ) << 8 ) & 0x00FF0000 ) | \ 1851 ( ( ( *((U32 *)(ptr) ) ) >> 8 ) & 0x0000FF00 ) | \ 1852 ( ( ( *((U32 *)(ptr) ) ) >> 24 ) ) ) 1853 1854 #define BE_SWAP16(ptr) \ 1855 ( ( U16 ) \ 1856 ( ( ( ( *((U16 *)(ptr) ) ) << 8 ) ) | \ 1857 ( ( ( *((U16 *)(ptr) ) ) >> 8 ) ) ) \ 1858 ) 1859 1860#if defined(IS_PSP) 1861 1862 #define putunaligned4(temp, s ) \ 1863 __asm__("swl %1,3+%0" : "+m"(*(s)): "r"(temp)); \ 1864 __asm__("swr %1,%0" : "+m"(*(s)) : "r"(temp)); 1865 1866 #define getunaligned4(temp, s ) \ 1867 __asm__("lwl %0,3+%1" : "=r"(temp) : "o"(*(U32*)(s))); \ 1868 __asm__("lwr %0,%1" : "+r"(temp) : "o"(*(U32*)(s)) ); 1869 1870 static inline U32 LEU_SWAP32( void * ptr ) 1871 { 1872 U32 ret; 1873 getunaligned4( ret, ptr ); 1874 return( ret ); 1875 } 1876 1877 static inline U32 BEU_SWAP32( void * ptr ) 1878 { 1879 U32 ret; 1880 1881 getunaligned4( ret, ptr ); 1882 ret = ( ret << 24 ) | ( ( ret << 8 ) & 0x00ff0000 ) | ( ( ret >> 8 ) & 0x0000ff00 ) | ( ret >> 24 ); 1883 return( ret ); 1884 } 1885 1886 #define LEU_SWAP16(ptr) \ 1887 ( ( U16 ) \ 1888 ( ( ( ( ((U32)(((U8 *)(ptr))[1]) ) ) << 8 ) ) | \ 1889 ( ( ( ((U32)(((U8 *)(ptr))[0]) ) ) ) ) ) \ 1890 ) 1891 #define BEU_SWAP16(ptr) \ 1892 ( ( U16 ) \ 1893 ( ( ( ( ((U32)(((U8 *)(ptr))[0]) ) ) << 8 ) ) | \ 1894 ( ( ( ((U32)(((U8 *)(ptr))[1]) ) ) ) ) ) \ 1895 ) 1896 1897 #define STORE_LEU_SWAP32( ptr, val ) { register U32 __v = (U32)val; register U32 * __p = (U32*)ptr; putunaligned4( __v, __p ); } 1898 #define STORE_LEU_SWAP16( ptr, val ) { register U16 __v = (U16)val; ((U8*)(ptr))[0]=(U8)val; ((U8*)(ptr))[1]=(U8)(val>>8);} 1899 1900#else 1901 1902 #define LEU_SWAP32(ptr) LE_SWAP32(ptr) 1903 #define LEU_SWAP16(ptr) LE_SWAP16(ptr) 1904 1905 #define BEU_SWAP32(ptr) BE_SWAP32(ptr) 1906 #define BEU_SWAP16(ptr) BE_SWAP16(ptr) 1907 1908 #define STORE_LEU_SWAP32( ptr, val ) STORE_LE_SWAP32( ptr, val ) 1909 #define STORE_LEU_SWAP16( ptr, val ) STORE_LE_SWAP16( ptr, val ) 1910 1911#endif 1912 1913 #define MEM_LEU_SWAP32(n) 1914 #define MEM_LEU_SWAP16(n) 1915 1916 #define MEM_LE_SWAP32(n) 1917 #define MEM_LE_SWAP16(n) 1918 1919 #define MEM_BE_SWAP32(n) *((U32*)n) = BE_SWAP32(n); 1920 #define MEM_BE_SWAP16(n) *((U16*)n) = BE_SWAP16(n); 1921 1922#endif 1923 1924 1925 1926#if defined(IS_MAC) || defined(IS_WII) || defined(IS_IPHONE) 1927 1928#ifdef IS_X86 1929 1930static inline U32 mult64addsubandshift( U32 mt1, U32 mt2, U32 addv, U32 subv, U32 shift ) 1931{ 1932 U32 retv; 1933 1934 unsigned long long value; 1935 value = (unsigned long long)mt1 * mt2; 1936 value += addv; 1937 value -= subv; 1938 value = (signed long long )value >> (signed long long )shift; 1939 retv = (U32)value; 1940 1941 return( retv ); 1942 1943} 1944 1945 1946static U32 __inline mult64anddiv(U32 a,U32 b, U32 c) 1947{ 1948 U32 retv; 1949 unsigned long long value; 1950 value = (unsigned long long)a * b; 1951 value /= c; 1952 retv = (U32)value; 1953 return( retv ); 1954} 1955 1956static U32 __inline shift64addsubanddiv( U32 val, U32 shift,U32 addv, U32 subv, U32 divv) 1957{ 1958 U32 retv; 1959 unsigned long long value; 1960 value = (unsigned long long)val; 1961 value <<= shift; 1962 value += addv; 1963 value -= subv; 1964 value = (signed long long ) value / (signed long long ) divv; 1965 retv = (U32)value; 1966 return( retv ); 1967} 1968 1969#elif defined(IS_IPHONE) 1970 1971#define WRITE_MONO_SAMPLE( dest, fOut ) \ 1972{ \ 1973 if (fOut > 32767.0F) *dest++ = 32767; \ 1974 else if (fOut < -32768.0F) *dest++ = -32768; \ 1975 else *dest++ = (S16) fOut; \ 1976} 1977 1978static U32 __inline mult64addsubandshift( U32 mt1, U32 mt2, U32 addv, U32 subv, U32 shift ) 1979{ 1980 U32 retv; 1981 unsigned long long value; 1982 value = (unsigned long long)mt1 * mt2; 1983 value += addv; 1984 value -= subv; 1985 value = (signed long long )value >> (signed long long )shift; 1986 retv = (U32)value; 1987 return( retv ); 1988} 1989 1990static U32 __inline mult64anddiv(U32 a,U32 b, U32 c) 1991{ 1992 U32 retv; 1993 unsigned long long value; 1994 value = (unsigned long long)a * b; 1995 value /= c; 1996 retv = (U32)value; 1997 return( retv ); 1998} 1999 2000static U32 __inline shift64addsubanddiv( U32 val, U32 shift,U32 addv, U32 subv, U32 divv) 2001{ 2002 U32 retv; 2003 unsigned long long value; 2004 value = (unsigned long long)val; 2005 value <<= shift; 2006 value += addv; 2007 value -= subv; 2008 value = (signed long long ) value / (signed long long ) divv; 2009 retv = (U32)value; 2010 return( retv ); 2011} 2012 2013#else 2014 2015// 2016// These three dudes help deal with u64s in hi,lo format 2017// 2018 2019#define mul64hilo(_hi,_lo,_mt1,_mt2) \ 2020 __asm \ 2021 { \ 2022 mulhwu _hi, _mt1, _mt2; \ 2023 mullw _lo, _mt1, _mt2 \ 2024 } \ 2025 2026 2027#define imul64hilo(_hi,_lo,_mt1,_mt2) \ 2028 __asm \ 2029 { \ 2030 mulhw _hi, _mt1, _mt2; \ 2031 mullw _lo, _mt1, _mt2 \ 2032 } \ 2033 2034 2035#define add64hilo(_hi,_lo,_hisub,_losub) \ 2036 __asm \ 2037 { \ 2038 addc _lo, _losub, _lo; \ 2039 adde _hi, _hisub, _hi \ 2040 } \ 2041 2042 2043#define sub64hilo(_hi,_lo,_hisub,_losub) \ 2044 __asm \ 2045 { \ 2046 subfc _lo, _losub, _lo; \ 2047 subfe _hi, _hisub, _hi \ 2048 } \ 2049 2050#define carry_check( q, r, c, d ) \ 2051 if ( r < c ) \ 2052 { \ 2053 --q; \ 2054 r += d; \ 2055 if ( r >= d ) \ 2056 { \ 2057 if ( r < c ) \ 2058 { \ 2059 --q; \ 2060 r += d; \ 2061 } \ 2062 } \ 2063 } 2064 2065// The PPC mac doesnt' have intrinsics like CW 2066#ifdef IS_MAC 2067static U32 __cntlzw(U32 in) 2068{ 2069 U32 ret; 2070 asm ("cntlzw %0, %1\n": "=r" (ret): "r" (in)); 2071 return ret; 2072} 2073#endif 2074 2075static inline U32 div64with16( U32 nlo, U32 nhi, U32 d ) 2076{ 2077 U32 dlo, dhi; 2078 U32 rlo, rhi; 2079 U32 qhi, qlo; 2080 U32 carry; 2081 2082 dhi = d >> 16; 2083 dlo = d & 0xffff; 2084 2085 qhi = nhi / dhi; 2086 rhi = nhi % dhi; 2087 2088 carry = qhi * dlo; 2089 2090 rhi = ( rhi << 16 ) | ( nlo >> 16 ); 2091 2092 carry_check( qhi, rhi, carry, d ); 2093 rhi -= carry; 2094 2095 qlo = rhi / dhi; 2096 rlo = rhi % dhi; 2097 carry = qlo * dlo; 2098 2099 qhi <<= 16; 2100 2101 rlo = ( rlo << 16 ) | ( nlo & 0xffff ); 2102 carry_check( qlo, rlo, carry, d ); 2103 2104// rlo -= carry; 2105 2106 return( qhi | qlo ); 2107} 2108 2109static U32 inline mult64anddiv( register U32 a, register U32 b,U32 d ) 2110{ 2111/* register U32 hi, lo; 2112 register U32 mt1, mt2, d; 2113 2114 mt1=m1; 2115 mt2=m2; 2116 d=dv; 2117 2118 mul64hilo( hi, lo, mt1, mt2 ); 2119 2120 return( div64(hi,lo,d) ); 2121*/ 2122 U32 lz; 2123 register U32 nhi=0, nlo=0; 2124 2125 mul64hilo( nhi, nlo, a, b ); 2126 2127 if ( ( d & ( d - 1 ) ) == 0 ) 2128 { 2129 lz = (U32) __cntlzw( d ); 2130 2131 // Shift for powers of 2. 2132 return( ( nhi << ( lz + 1 ) ) | ( nlo >> ( 31 - lz ) ) ); 2133 } 2134 2135 if ( nhi == 0 ) 2136 { 2137 return( nlo / d ); 2138 } 2139 2140 lz = (U32) __cntlzw( d ); 2141 2142 d <<= lz; 2143 nhi = ( nhi << lz ) + ( nlo >> ( 32 - lz ) ); 2144 nlo <<= lz; 2145 2146 return( div64with16( nlo, nhi, d ) ); 2147 2148} 2149 2150static U32 inline mult64andshift( U32 m1,U32 m2,U32 shift ) 2151{ 2152 register U32 hi, lo; 2153 register U32 mt1, mt2; 2154 2155 mt1=m1; 2156 mt2=m2; 2157 2158 mul64hilo( hi, lo, mt1, mt2 ); 2159 2160 return( ( hi << (32 - shift ) ) + ( lo >> shift ) ); 2161} 2162 2163static U32 inline mult64addsubandshift( U32 m1, U32 m2, U32 av, U32 sv, U32 shift ) 2164{ 2165 register U32 hi=0, lo=0; 2166 register U32 mt1, mt2; 2167 register U32 addv; 2168 register U32 subv; 2169 register U32 zero = 0; 2170 2171 mt1=m1; 2172 mt2=m2; 2173 addv=av; 2174 subv=sv; 2175 2176 mul64hilo(hi,lo,mt1,mt2); 2177 add64hilo( hi, lo, zero, addv ); 2178 sub64hilo( hi, lo, zero, subv ); 2179 2180 return( ( hi << (32 - shift ) ) + ( lo >> shift ) ); 2181} 2182 2183static U32 __inline shift64addsubanddiv( U32 val, U32 shift,U32 av, U32 sv, U32 divv) 2184{ 2185 register U32 hi, lo; 2186 register U32 addv; 2187 register U32 subv; 2188 register U32 d; 2189 register U32 zero = 0; 2190 U32 lz; 2191 2192 addv=av; 2193 subv=sv; 2194 d=divv; 2195 2196 hi = val >> ( 32 - shift ); 2197 lo = val << shift; 2198 add64hilo( hi, lo, zero, addv ); 2199 sub64hilo( hi, lo, zero, subv ); 2200 2201 if ( hi & 0x80000000 ) 2202 { 2203 register U32 ihi = hi; 2204 register U32 ilo = lo; 2205 hi = lo = 0; 2206 sub64hilo( hi, lo, ihi, ilo ); 2207 2208 if ( ( d & ( d - 1 ) ) == 0 ) 2209 { 2210 lz = (U32) __cntlzw( d ); 2211 2212 // Shift for powers of 2. 2213 return( (U32) -(S32) ( ( hi << ( lz + 1 ) ) | ( lo >> ( 31 - lz ) ) ) ); 2214 } 2215 2216 if ( hi == 0 ) 2217 { 2218 return( (U32) -(S32) ( lo / d ) ); 2219 } 2220 2221 return( (U32) -(S32) div64with16( lo,hi,d ) ); 2222 } 2223 2224 if ( ( d & ( d - 1 ) ) == 0 ) 2225 { 2226 lz = (U32) __cntlzw( d ); 2227 2228 // Shift for powers of 2. 2229 return( ( hi << ( lz + 1 ) ) | ( lo >> ( 31 - lz ) ) ); 2230 } 2231 2232 if ( hi == 0 ) 2233 { 2234 return( lo / d ); 2235 } 2236 2237 return( div64with16( lo,hi,d ) ); 2238} 2239 2240#define WRITE_MONO_SAMPLE( dest, fOut ) \ 2241{ \ 2242 if (fOut > 32767.0F) STORE_LE_SWAP16( dest, 32767 ); \ 2243 else if (fOut < -32768.0F) STORE_LE_SWAP16( dest, -32768 ); \ 2244 else STORE_LE_SWAP16( dest, (S16) fOut ); \ 2245 ++dest; \ 2246} 2247 2248#endif 2249 2250#else 2251 2252#if ( defined(IS_X86) && defined(IS_WIN32API) ) || defined(IS_LINUX) || defined(__RADSEKRIT2__) 2253 2254// 2255// Macros to aid in writing to build buffers 2256// 2257 2258#define WRITE_MONO_SAMPLE( dest, fOut ) \ 2259{ \ 2260 if (fOut > 32767.0F) *dest++ = 32767; \ 2261 else if (fOut < -32768.0F) *dest++ = -32768; \ 2262 else *dest++ = (S16) fOut; \ 2263} 2264 2265static U32 __inline mult64addsubandshift( U32 mt1, U32 mt2, U32 addv, U32 subv, U32 shift ) 2266{ 2267 U32 retv; 2268 2269#ifdef __GNUC__ 2270 unsigned long long value; 2271 value = (unsigned long long)mt1 * mt2; 2272 value += addv; 2273 value -= subv; 2274 value = (signed long long )value >> (signed long long )shift; 2275 retv = (U32)value; 2276#else 2277#ifdef IS_WIN64 2278 U64 value; 2279 value = (U64) mt1 * mt2; 2280 value += addv; 2281 value -= subv; 2282 value = (S64) value >> (S64) shift; 2283 retv = (U32) value; 2284#else 2285 __asm 2286 { 2287 mov eax,[mt1] 2288 mov ecx,[mt2] 2289 mul ecx 2290 add eax,[addv] 2291 adc edx,0 2292 sub eax,[subv] 2293 sbb edx,0 2294 mov ecx,[shift] 2295 shrd eax,edx,cl 2296 mov [retv], eax 2297 } 2298#endif 2299#endif 2300 return( retv ); 2301} 2302 2303static U32 __inline mult64anddiv(U32 a,U32 b, U32 c) 2304{ 2305 U32 retv; 2306 2307#ifdef __GNUC__ 2308 unsigned long long value; 2309 value = (unsigned long long)a * b; 2310 value /= c; 2311 retv = (U32)value; 2312#else 2313#ifdef IS_WIN64 2314 U64 value; 2315 value = (U64) a * b; 2316 value /= c; 2317 retv = (U32) value; 2318#else 2319 __asm 2320 { 2321 mov eax,[a] 2322 mov ecx,[b] 2323 mul ecx 2324 mov ecx,[c] 2325 div ecx 2326 mov [retv], eax 2327 } 2328#endif 2329#endif 2330 return( retv ); 2331} 2332 2333static U32 __inline shift64addsubanddiv( U32 val, U32 shift,U32 addv, U32 subv, U32 divv) 2334{ 2335 U32 retv; 2336#ifdef __GNUC__ 2337 unsigned long long value; 2338 value = (unsigned long long)val; 2339 value <<= shift; 2340 value += addv; 2341 value -= subv; 2342 value = (signed long long ) value / (signed long long ) divv; 2343 retv = (U32)value; 2344#else 2345#ifdef IS_WIN64 2346 U64 value; 2347 value = (U64) val; 2348 value <<= shift; 2349 value += addv; 2350 value -= subv; 2351 value = (S64) value / (S64) divv; 2352 retv = (U32) value; 2353#else 2354 __asm 2355 { 2356 xor edx, edx 2357 mov eax, [val] 2358 mov ecx, [shift] 2359 shld edx, eax, cl 2360 shl eax, cl 2361 add eax, [addv] 2362 adc edx, 0 2363 sub eax, [subv] 2364 sbb edx, 0 2365 mov ecx, [divv] 2366 idiv ecx 2367 mov [retv], eax 2368 } 2369#endif 2370#endif 2371 return( retv ); 2372} 2373 2374#else 2375 2376#ifdef __WATCOMC__ 2377 2378#else 2379 2380#if defined( IS_XENON ) 2381 2382#define toU64(v) ((U64)((U32)(v))) 2383#define toS64(v) ((S64)((S32)(v))) 2384 2385#define mult64anddiv(mt1,mt2,d) ((U32)((toU64(mt1)*toU64(mt2))/toU64(d))) 2386 2387#define mult64addsubandshift(mt1,mt2,addv,subv,d) ((U32)((((S64)((toU64(mt1)*toU64(mt2))+toU64(addv)))-toS64(subv))>>toS64(d))) 2388 2389#define shift64addsubanddiv(val,shift,addv,subv,divv) ((U32)(((S64)((toU64(val)<<toU64(shift))+toU64(addv)-toU64(subv)))/toS64(divv))) 2390 2391#define WRITE_MONO_SAMPLE( dest, fOut ) \ 2392{ \ 2393 if (fOut > 32767.0F) STORE_LE_SWAP16( dest, 32767 ); \ 2394 else if (fOut < -32768.0F) STORE_LE_SWAP16( dest, -32768 ); \ 2395 else STORE_LE_SWAP16( dest, (S16) fOut ); \ 2396 ++dest; \ 2397} 2398 2399 2400#else 2401 2402#if defined( IS_PSP ) || defined(IS_3DS) || defined(IS_PSP2) || defined(__RADANDROID__) 2403 2404 2405#define toU64(v) ((U64)((U32)(v))) 2406#define toS64(v) ((S64)((S32)(v))) 2407 2408#define mult64anddiv(mt1,mt2,d) ((U32)((toU64(mt1)*toU64(mt2))/toU64(d))) 2409 2410#define mult64addsubandshift(mt1,mt2,addv,subv,d) ((U32)((((S64)((toU64(mt1)*toU64(mt2))+toU64(addv)))-toS64(subv))>>toS64(d))) 2411 2412#define shift64addsubanddiv(val,shift,addv,subv,divv) ((U32)(((S64)((toU64(val)<<toU64(shift))+toU64(addv)-toU64(subv)))/toS64(divv))) 2413 2414#define WRITE_MONO_SAMPLE( dest, fOut ) \ 2415{ \ 2416 if (fOut > 32767.0F) *dest++ = 32767; \ 2417 else if (fOut < -32768.0F) *dest++ = -32768; \ 2418 else *dest++ = (S16) fOut; \ 2419} 2420 2421#elif defined(IS_WIIU) 2422 2423#define toU64(v) ((U64)((U32)(v))) 2424#define toS64(v) ((S64)((S32)(v))) 2425 2426#define mult64anddiv(mt1,mt2,d) ((U32)((toU64(mt1)*toU64(mt2))/toU64(d))) 2427 2428#define mult64addsubandshift(mt1,mt2,addv,subv,d) ((U32)((((S64)((toU64(mt1)*toU64(mt2))+toU64(addv)))-toS64(subv))>>toS64(d))) 2429 2430#define shift64addsubanddiv(val,shift,addv,subv,divv) ((U32)(((S64)((toU64(val)<<toU64(shift))+toU64(addv)-toU64(subv)))/toS64(divv))) 2431 2432#define WRITE_MONO_SAMPLE( dest, fOut ) \ 2433{ \ 2434 if (fOut > 32767.0F) STORE_LE_SWAP16( dest, 32767 ); \ 2435 else if (fOut < -32768.0F) STORE_LE_SWAP16( dest, -32768 ); \ 2436 else STORE_LE_SWAP16( dest, (S16) fOut ); \ 2437 ++dest; \ 2438} 2439 2440 2441 2442#elif defined( IS_PS3 ) && !defined( IS_SPU ) 2443 2444#define toU64(v) ((U64)((U32)(v))) 2445#define toS64(v) ((S64)((S32)(v))) 2446 2447#define mult64anddiv(mt1,mt2,d) ((U32)((toU64(mt1)*toU64(mt2))/toU64(d))) 2448 2449#define mult64addsubandshift(mt1,mt2,addv,subv,d) ((U32)((((S64)((toU64(mt1)*toU64(mt2))+toU64(addv)))-toS64(subv))>>toS64(d))) 2450 2451#define shift64addsubanddiv(val,shift,addv,subv,divv) ((U32)(((S64)((toU64(val)<<toU64(shift))+toU64(addv)-toU64(subv)))/toS64(divv))) 2452 2453static inline float fclip32K(float sample ) 2454{ 2455 float ret; 2456 2457 __fsel( ret, sample + 32767.0f, sample, -32767.0f ); 2458 __fsel( ret, sample - 32767.0f, 32767.0f, ret ); 2459 return( ret ); 2460} 2461 2462#define WRITE_MONO_SAMPLE( dest, fOut ) \ 2463{ \ 2464 STORE_LE_SWAP16( dest, (S16) fclip32K(fOut) ); \ 2465 ++dest; \ 2466} 2467 2468#else 2469 2470U32 mult64addsubandshift(U32 mt1,U32 mt2,U32 addv, U32 subv, U32 shift); 2471U32 shift64addsubanddiv(U32 val,U32 shift,U32 addv, U32 subv, U32 divv); 2472 2473#if defined( IS_SPU ) 2474 2475#define WRITE_MONO_SAMPLE( dest, fOut ) \ 2476{ \ 2477 if (fOut > 32767.0F) *dest = (S16)(U16)0xff7f; \ 2478 else if (fOut < -32768.0F) *dest = (S16)(U16)0x0080; \ 2479 else STORE_LE_SWAP16( dest, (S16) fOut ) \ 2480 ++dest; \ 2481} 2482 2483#define toU64(v) ((U64)((U32)(v))) 2484#define toS64(v) ((S64)((S32)(v))) 2485 2486#define mult64anddiv(mt1,mt2,d) ((U32)((toU64(mt1)*toU64(mt2))/toU64(d))) 2487 2488#define mult64addsubandshift(mt1,mt2,addv,subv,d) ((U32)((((S64)((toU64(mt1)*toU64(mt2))+toU64(addv)))-toS64(subv))>>toS64(d))) 2489 2490#define shift64addsubanddiv(val,shift,addv,subv,divv) ((U32)(((S64)((toU64(val)<<toU64(shift))+toU64(addv)-toU64(subv)))/toS64(divv))) 2491 2492#endif 2493 2494#endif 2495 2496#endif 2497 2498 2499#endif 2500 2501#endif 2502 2503#endif 2504 2505#ifdef MSS_SPU_PROCESS 2506 2507#define SPU_NAME( flt, name ) extern "C" void AILCALL flt##_##name 2508 2509//#define DEBUGSPUMEM 2510#ifdef DEBUGSPUMEM 2511 2512 void * spu_alloc( U32 bytes ); 2513 2514 #ifdef __cplusplus 2515 2516 extern "C" U32 num_mals; 2517 extern "C" void free_mals( int level ); 2518 2519 class stackmark 2520 { 2521 public: 2522 int level; 2523 stackmark() 2524 { 2525 level = num_mals; 2526 } 2527 ~stackmark() 2528 { 2529 free_mals( level ); 2530 } 2531 }; 2532 #define addstackmark() stackmark sm; 2533 #else 2534 #define addstackmark() 2535 #endif 2536 2537#else 2538 2539 #define addstackmark() 2540 2541 #ifdef IS_SPU 2542 #include <alloca.h> 2543 2544 static int stacksizehas( int v ) 2545 { 2546 vector signed int val; 2547 __asm__("or %0,$1,$1" : "=r"(val) ); 2548 2549 if ( val[1] < ( v + 2048 ) ) { MSSBreakPoint(); } 2550 return v; 2551 } 2552 #define spu_alloc(bytes) (void*)alloca( stacksizehas( ( ( bytes ) + 15 ) & ~15 ) ) 2553 #else 2554 #include <malloc.h> 2555 #define spu_alloc(bytes) (void*)alloca( ( ( bytes ) + 15 ) & ~15 ) 2556 #endif 2557 2558#endif 2559 2560#else 2561 2562#define SPU_NAME( flt, name ) static void AILCALL name 2563#define addstackmark() 2564 2565#endif 2566 2567// 2568// low-level utility memory file routines 2569// 2570 2571typedef struct _MEMDUMP 2572{ 2573 void* buffer[1024]; // up to 64 MB 2574 U8* current; 2575 U32 size; 2576 U32 totalsize; 2577 U32 curbufnum; 2578 U32 lastbufnum; 2579 U32 curpos; 2580 S32 error; 2581 S32 expandable; 2582 U32 eachbuf; 2583 U32 firstbuf; 2584} MEMDUMP; 2585 2586// This typedef occurs in mss.h as well. 2587//typedef struct _MEMDUMP* HMEMDUMP; 2588 2589DXDEC HMEMDUMP AILCALL AIL_mem_open(void* addr,U32 size); 2590 2591DXDEC HMEMDUMP AILCALL AIL_mem_create(void); 2592DXDEC HMEMDUMP AILCALL AIL_mem_create_from_existing(void* addr, U32 size); // do not delete pointer passed in 2593 2594DXDEC S32 AILCALL AIL_mem_close(HMEMDUMP m, void** buf, U32* size); 2595 2596DXDEC U32 2597#if defined(IS_WIN32API) 2598__cdecl 2599#endif 2600AIL_mem_printf(HMEMDUMP m, char const* fmt, ...); 2601 2602DXDEC U32 AILCALL AIL_mem_printc(HMEMDUMP m, char c); 2603 2604DXDEC U32 AILCALL AIL_mem_prints(HMEMDUMP m, char const* s); 2605 2606DXDEC U32 AILCALL AIL_mem_write(HMEMDUMP m, void const* s, U32 bytes); 2607 2608DXDEC U32 AILCALL AIL_mem_read(HMEMDUMP m, void* s, U32 bytes); 2609 2610DXDEC U32 AILCALL AIL_mem_seek(HMEMDUMP m, U32 pos); 2611 2612DXDEC U32 AILCALL AIL_mem_size(HMEMDUMP m); 2613 2614DXDEC U32 AILCALL AIL_mem_pos(HMEMDUMP m); 2615 2616DXDEC S32 AILCALL AIL_mem_error(HMEMDUMP m); 2617 2618 2619 2620#define DIG_PROCESS_BUFFER_SIZE 2048 2621 2622extern U8 *ASI_mem_src_ptr; 2623extern S32 ASI_mem_src_len; 2624extern S32 ASI_mem_src_pos; 2625 2626 2627extern S32 AILCALLBACK ASI_mem_stream_CB(UINTa user, //) 2628 void *dest, 2629 S32 bytes_requested, 2630 S32 offset); 2631 2632#if 1 2633 2634#if 0 //used to be a IS_LINUX 2635 2636#else 2637 2638DXDEC S32 AILCALL AIL_stricmp(const char *s1, const char *s2); 2639DXDEC S32 AILCALL AIL_strnicmp( const char *s1, const char *s2, U32 maxlen); 2640 2641#if defined(IS_MAC) || defined(IS_LINUX) || defined(IS_3DS) || defined(IS_IPHONE) || defined(IS_PSP2) || defined(IS_WIIU) || defined(__RADSEKRIT2__) || defined(__RADANDROID__) 2642 2643#ifdef IS_PSP2 2644#ifdef __cplusplus 2645} 2646#endif 2647#endif 2648 2649#include <string.h> 2650#include <stdlib.h> // for abs(). 2651 2652#ifdef IS_PSP2 2653#ifdef __cplusplus 2654extern "C" { 2655#endif 2656#endif 2657 2658 2659#define AIL_memcpy memcpy 2660#define AIL_memmove memmove 2661#define AIL_strcpy strcpy 2662#define AIL_strcmp strcmp 2663#define AIL_strlen strlen 2664#define AIL_strcat strcat 2665#define AIL_memset memset 2666#define AIL_ptr_add(ptr,off) ((void*)(((U8*)(ptr))+(off))) 2667#define AIL_ptr_dif(p1,p2) ((SINTa)((SINTa) p1) - ((SINTa) p2)) 2668#define AIL_ptr_alloc_clone(x) ((void*)x) 2669#define AIL_ptr_free_clone(x) 2670 2671#ifdef __cplusplus 2672} 2673 template <typename T> inline T AILptradd( T ptr, U32 off ) { return( T(AIL_ptr_add( ptr, off )) ); } 2674 #define AIL_ptr_inc_clone(x,y) x=AILptradd(x,y) 2675extern "C" { 2676#endif 2677 2678#define AIL_ptr_fixup_clone(x) 2679#define AIL_ptr_lt(x,y) (((UINTa)x) < ((UINTa)y)) 2680#define AIL_ptr_ge(x,y) (((UINTa)x) >= ((UINTa)y)) 2681#define AIL_ptr_eq(x,y) (((UINTa)x) == ((UINTa)y)) 2682#define AIL_ptr_ne(x,y) (((UINTa)x) != ((UINTa)y)) 2683#define AIL_ptr_lin_addr(x) ((UINTa)(x)) 2684 2685#define AIL_abs abs 2686#define AIL_memcmp memcmp 2687 2688#else // not mac or linux 2689 2690#ifdef IS_WIN32API 2691 2692#define AIL_abs abs 2693 2694#ifdef IS_XENON 2695 2696typedef void *PVOID; 2697typedef int INT; 2698typedef unsigned long ULONG_PTR; 2699typedef ULONG_PTR SIZE_T; 2700 2701PVOID 2702__stdcall 2703XMemSet( 2704 PVOID pDest, 2705 INT c, 2706 SIZE_T count 2707 ); 2708 2709PVOID 2710__stdcall 2711XMemCpy( 2712 PVOID pDest, 2713 const void* pSrc, 2714 SIZE_T count 2715 ); 2716 2717char * __cdecl strcpy( char *_Dest, const char * _Source); 2718 2719#define AIL_memcpy XMemCpy 2720#define AIL_memset XMemSet 2721 2722#else 2723 2724#if defined(_WIN32) || defined(_WIN64) || defined(WIN32) || defined(__NT__) || defined(__WIN32__) 2725 #include <string.h> 2726 void * __cdecl memcpy(void *, const void *, size_t); 2727 void * __cdecl memset(void *, int, size_t); 2728 char * __cdecl strcpy(char *, const char *); 2729#endif 2730 2731#define AIL_memcpy memcpy 2732#define AIL_memset memset 2733 2734#endif 2735 2736#if defined(IS_XENON) 2737#include <string.h> 2738#endif 2739 2740#define AIL_memmove memmove 2741 2742#define AIL_memcmp memcmp 2743 2744#define AIL_strcpy strcpy 2745 2746#define AIL_strcmp strcmp 2747 2748#define AIL_strlen strlen 2749 2750#define AIL_strcat strcat 2751 2752#define AIL_ptr_add(ptr,off) ((void*)(((U8*)(ptr))+(off))) 2753 2754#define AIL_ptr_dif(p1,p2) ((SINTa)((SINTa) p1) - ((SINTa) p2)) 2755 2756#define AIL_ptr_alloc_clone(x) ((void*)x) 2757 2758#define AIL_ptr_free_clone(x) 2759 2760#ifdef __cplusplus 2761} 2762 template <typename T> inline T AILptradd( T ptr, U32 off ) { return( T(AIL_ptr_add( ptr, off )) ); } 2763 #define AIL_ptr_inc_clone(x,y) x=AILptradd(x,y) 2764extern "C" { 2765#endif 2766 2767#define AIL_ptr_fixup_clone(x) 2768 2769#define AIL_ptr_lt(x,y) (((UINTa)x) < ((UINTa)y)) 2770 2771#define AIL_ptr_ge(x,y) (((UINTa)x) >= ((UINTa)y)) 2772 2773#define AIL_ptr_eq(x,y) (((UINTa)x) == ((UINTa)y)) 2774 2775#define AIL_ptr_ne(x,y) (((UINTa)x) != ((UINTa)y)) 2776 2777#define AIL_ptr_lin_addr(x) ((UINTa)(x)) 2778 2779#else 2780 2781#if defined(IS_PSP) 2782 2783#define AIL_memmove memmove 2784 2785#define AIL_memcpy memcpy 2786 2787#define AIL_memset memset 2788 2789#define AIL_memcmp memcmp 2790 2791#define AIL_strcpy strcpy 2792 2793#define AIL_strcmp strcmp 2794 2795#define AIL_stricmp strcasecmp 2796 2797#define AIL_strnicmp strncasecmp 2798 2799#define AIL_strlen strlen 2800 2801#define AIL_strcat strcat 2802 2803#define AIL_ptr_add(ptr,off) ((void*)(((U8*)(ptr))+(off))) 2804 2805#define AIL_ptr_dif(p1,p2) ((SINTa)((SINTa) p1) - ((SINTa) p2)) 2806 2807#define AIL_ptr_alloc_clone(x) ((void*)x) 2808 2809#define AIL_ptr_free_clone(x) 2810 2811#ifdef __cplusplus 2812} 2813 template <typename T> inline T AILptradd( T ptr, U32 off ) { return( T(AIL_ptr_add( ptr, off )) ); } 2814 #define AIL_ptr_inc_clone(x,y) x=AILptradd(x,y) 2815extern "C" { 2816#endif 2817 2818#define AIL_ptr_fixup_clone(x) 2819 2820#define AIL_ptr_lt(x,y) (((UINTa)x) < ((UINTa)y)) 2821 2822#define AIL_ptr_ge(x,y) (((UINTa)x) >= ((UINTa)y)) 2823 2824#define AIL_ptr_eq(x,y) (((UINTa)x) == ((UINTa)y)) 2825 2826#define AIL_ptr_ne(x,y) (((UINTa)x) != ((UINTa)y)) 2827 2828#define AIL_ptr_lin_addr(x) ((UINTa)(x)) 2829 2830static inline S32 AIL_abs(S32 v) { return( ( v >=0 ) ? v : -v ); } 2831 2832 2833#elif defined(IS_PS3) 2834 2835#define AIL_memmove memmove 2836 2837#define AIL_memcpy memcpy 2838 2839#define AIL_memset memset 2840 2841#define AIL_memcmp memcmp 2842 2843#define AIL_strcpy strcpy 2844 2845#define AIL_strcmp strcmp 2846 2847#define AIL_stricmp strcasecmp_ascii 2848 2849#define AIL_strnicmp strncasecmp_ascii 2850 2851#define AIL_strlen strlen 2852 2853#define AIL_strcat strcat 2854 2855#define AIL_ptr_add(ptr,off) ((void*)(((U8*)(ptr))+(off))) 2856 2857#define AIL_ptr_dif(p1,p2) ((SINTa)((SINTa) p1) - ((SINTa) p2)) 2858 2859#define AIL_ptr_alloc_clone(x) ((void*)x) 2860 2861#define AIL_ptr_free_clone(x) 2862 2863#ifdef __cplusplus 2864} 2865 template <typename T> inline T AILptradd( T ptr, U32 off ) { return( T(AIL_ptr_add( ptr, off )) ); } 2866 #define AIL_ptr_inc_clone(x,y) x=AILptradd(x,y) 2867extern "C" { 2868#endif 2869 2870#define AIL_ptr_fixup_clone(x) 2871 2872#define AIL_ptr_lt(x,y) (((UINTa)x) < ((UINTa)y)) 2873 2874#define AIL_ptr_ge(x,y) (((UINTa)x) >= ((UINTa)y)) 2875 2876#define AIL_ptr_eq(x,y) (((UINTa)x) == ((UINTa)y)) 2877 2878#define AIL_ptr_ne(x,y) (((UINTa)x) != ((UINTa)y)) 2879 2880#define AIL_ptr_lin_addr(x) ((UINTa)(x)) 2881 2882static inline S32 AIL_abs(S32 v) { return( ( v >=0 ) ? v : -v ); } 2883 2884#else 2885 2886#ifdef IS_WII 2887 2888#define AIL_memcpy memcpy 2889 2890#define AIL_memmove memmove 2891 2892#define AIL_strcpy strcpy 2893 2894#define AIL_strcmp strcmp 2895 2896#define AIL_strlen strlen 2897 2898#define AIL_strcat strcat 2899 2900#define AIL_memset memset 2901 2902#define AIL_ptr_add(ptr,off) ((void*)(((U8*)(ptr))+(off))) 2903 2904#define AIL_ptr_dif(p1,p2) ((SINTa)((SINTa) p1) - ((SINTa) p2)) 2905 2906#define AIL_ptr_alloc_clone(x) ((void*)x) 2907 2908#define AIL_ptr_free_clone(x) 2909 2910#ifdef __cplusplus 2911} 2912 template <typename T> inline T AILptradd( T ptr, U32 off ) { return( T(AIL_ptr_add( ptr, off )) ); } 2913 #define AIL_ptr_inc_clone(x,y) x=AILptradd(x,y) 2914extern "C" { 2915#endif 2916 2917#define AIL_ptr_fixup_clone(x) 2918 2919#define AIL_ptr_lt(x,y) (((UINTa)x) < ((UINTa)y)) 2920 2921#define AIL_ptr_ge(x,y) (((UINTa)x) >= ((UINTa)y)) 2922 2923#define AIL_ptr_eq(x,y) (((UINTa)x) == ((UINTa)y)) 2924 2925#define AIL_ptr_ne(x,y) (((UINTa)x) != ((UINTa)y)) 2926 2927#define AIL_ptr_lin_addr(x) ((UINTa)(x)) 2928 2929#ifndef __cplusplus 2930int abs( int ); 2931#endif 2932 2933#define AIL_abs abs 2934#define AIL_memcmp memcmp 2935 2936#endif 2937 2938#endif 2939 2940#endif 2941 2942#endif 2943 2944#endif 2945 2946#endif 2947 2948#ifndef AIL_ptr_inc_clone 2949#define AIL_ptr_inc_clone(x,y) AIL_ptr_inc_clone_ref((void * *)(void*) &(x),y) 2950#endif 2951#define AIL_ptr_from_clone(clone,hptr) (AIL_ptr_add(hptr,AIL_ptr_dif(clone,hptr))) 2952 2953 2954#ifdef IS_32 2955 2956#define MSS_do_cb1(type,addr,ds,param1) \ 2957 (addr)(param1) 2958 2959#define MSS_do_cb3(type,addr,ds,param1,param2,param3) \ 2960 (addr)(param1,param2,param3) 2961 2962#define MSS_do_cb4(type,addr,ds,param1,param2,param3,param4) \ 2963 (addr)(param1,param2,param3,param4) 2964 2965#define MSS_do_cb1_with_ret(ret,type,addr,ds,param1) \ 2966 ret = (addr)(param1) 2967 2968#define MSS_do_cb3_with_ret(ret,type,addr,ds,param1,param2,param3) \ 2969 ret = (addr)(param1,param2,param3) 2970 2971#define MSS_do_cb4_with_ret(ret,type,addr,ds,param1,param2,param3,param4) \ 2972 ret = (addr)(param1,param2,param3,param4) 2973 2974#define MSS_do_cb5_with_ret(ret,type,addr,ds,param1,param2,param3,param4,param5) \ 2975 ret = (addr)(param1,param2,param3,param4,param5) 2976 2977#endif 2978 2979#if (defined(IS_MAC) && defined( IS_X86 )) || defined(IS_LINUX) 2980 2981 2982#define MSS_CB_STACK_ALIGN( name ) \ 2983void MSS_CALLBACK_ALIGNED_NAME(name)(void)\ 2984{\ 2985 asm (\ 2986 "mov $16,%%eax\n" \ 2987 "sub $64,%%esp\n" \ 2988 "add %%esp, %%eax\n" \ 2989 "and $0xfffffff0,%%eax\n" \ 2990 "movups 8(%%ebp), %%xmm0\n" \ 2991 "movaps %%xmm0, (%%eax)\n" \ 2992 "movl %%esp, 32(%%eax)\n" \ 2993 "mov %%eax,%%esp\n" \ 2994 "call *%0\n" \ 2995 "movl 32(%%esp), %%esp\n" \ 2996 "add $64,%%esp\n" \ 2997 : : "r" (name) : "eax"); \ 2998} 2999 3000#define MSS_DEF_CB_STACK_ALIGN( name ) DXDEF MSS_CB_STACK_ALIGN( name ) 3001#define MSS_CB_STACK_ALIGN_DEC( name ) void MSS_CALLBACK_ALIGNED_NAME(name)(void); 3002 3003#else 3004 3005#define MSS_CB_STACK_ALIGN( name ) 3006#define MSS_DEF_CB_STACK_ALIGN( name ) 3007#define MSS_CB_STACK_ALIGN_DEC( name ) 3008 3009#endif 3010 3011#ifdef IS_XENON 3012 3013#define XWAVE_FORMAT_XMA 0x0165 3014 3015typedef MSS_STRUCT XXMASTREAMFORMAT 3016{ 3017 U32 PsuedoBytesPerSec; // Used by encoder 3018 U32 SampleRate; // Sample rate for the stream. 3019 U32 LoopStart; // Loop start offset (in bits). 3020 U32 LoopEnd; // Loop end offset (in bits). 3021 3022 // Format for SubframeData: eeee ssss. 3023 // e: Subframe number of loop end point [0,3]. 3024 // s: Number of subframes to skip before decoding and outputting at the loop start point [1,4]. 3025 3026 U8 SubframeData; // Data for decoding subframes. See above. 3027 U8 Channels; // Number of channels in the stream (1 or 2). 3028 U16 ChannelMask; // Channel assignments for the channels in the stream (same as 3029 // lower 16 bits of dwChannelMask in WAVEFORMATEXTENSIBLE). 3030} XXMASTREAMFORMAT; 3031 3032typedef MSS_STRUCT XXMAWAVEFORMAT 3033{ 3034 U16 FormatTag; // Audio format type (always WAVE_FORMAT_XMA). 3035 U16 BitsPerSample; // Bit depth (currently required to be 16). 3036 U16 EncodeOptions; // Options for XMA encoder/decoder. 3037 U16 LargestSkip; // Largest skip used in interleaving streams. 3038 U16 NumStreams; // Number of interleaved audio streams. 3039 U8 LoopCount; // Number of loop repetitions (255 == infinite). 3040 U8 Version; // Version of the encoder that generated this. 3041 XXMASTREAMFORMAT XmaStreams[1]; // Format info for each stream (can grow based on wNumStreams). 3042} XXMAWAVEFORMAT; 3043 3044#endif 3045 3046extern U32 SS_granularity(HSAMPLE S); 3047 3048extern S32 MC_open_output_filter(C8 const *name, //) 3049 HDIGDRIVER driver, 3050 S32 is_matrix_filter); 3051 3052extern void AILCALL MSS_mixer_mc_copy ( MSS_BB * build, 3053 S32 n_build_buffers, 3054 void * lpWaveAddr, 3055 S32 hw_format, 3056#ifdef IS_X86 3057 S32 use_MMX, 3058#endif 3059 S32 samples_per_buffer, 3060 S32 physical_channels_per_sample ); 3061 3062extern void AILCALL MSS_mixer_adpcm_decode( void * dest, 3063 void const * in, 3064 S32 out_len, 3065 S32 in_len, 3066 S32 input_format, 3067 ADPCMDATA *adpcm_data ); 3068// 3069// Prototypes for ADPCM decode routines 3070// 3071 3072extern void ASMLINK DecodeADPCM_STEREO( ASMPARM void *out, 3073 ASMPARM void const *in, 3074 ASMPARM S32 out_len, 3075 ASMPARM S32 in_len, 3076 ASMPARM ADPCMDATA *adpcm_data); 3077 3078extern void ASMLINK DecodeADPCM_MONO( ASMPARM void *out, 3079 ASMPARM void const *in, 3080 ASMPARM S32 out_len, 3081 ASMPARM S32 in_len, 3082 ASMPARM ADPCMDATA *adpcm_data); 3083 3084extern void ASMLINK DecodeADPCM_MONO_8( ASMPARM void *out, 3085 ASMPARM void const *in, 3086 ASMPARM S32 out_len, 3087 ASMPARM S32 in_len, 3088 ASMPARM ADPCMDATA *adpcm_data); 3089 3090 3091// 3092// .VOC file header 3093// 3094 3095typedef MSS_STRUCT 3096{ 3097 S8 ID_string[20]; 3098 3099 U16 data_offset; 3100 U16 version; 3101 U16 ID_code; 3102} 3103VOC; 3104 3105typedef MSS_STRUCT _ADPCMOUT { 3106 U32 riffmark; 3107 U32 rifflen; 3108 U32 wavemark; 3109 U32 fmtmark; 3110 U32 fmtlen; 3111 U16 fmttag; 3112 U16 channels; 3113 U32 sampersec; 3114 U32 avepersec; 3115 U16 blockalign; 3116 U16 bitspersam; 3117 S16 extra; 3118 S16 samples_per_block; 3119 U32 factmark; 3120 U32 factlen; 3121 U32 samples; 3122 U32 datamark; 3123 U32 datalen; 3124} ADPCMOUT; 3125 3126typedef MSS_STRUCT _WAVEOUT { 3127 U32 riffmark; 3128 U32 rifflen; 3129 U32 wavemark; 3130 U32 fmtmark; 3131 U32 fmtlen; 3132 U16 fmttag; 3133 U16 channels; 3134 U32 sampersec; 3135 U32 avepersec; 3136 U16 blockalign; 3137 U16 bitspersam; 3138 U32 datamark; 3139 U32 datalen; 3140} WAVEOUT; 3141 3142typedef MSS_STRUCT _WAVEOUTEXT { 3143 U32 riffmark; 3144 U32 rifflen; 3145 U32 wavemark; 3146 U32 fmtmark; 3147 U32 fmtlen; 3148 U16 fmttag; 3149 U16 channels; 3150 U32 sampersec; 3151 U32 avepersec; 3152 U16 blockalign; 3153 U16 bitspersam; 3154 U16 size; 3155 U16 sampbits; 3156 U32 chanmask; 3157 U8 subfmt[16]; 3158 U32 datamark; 3159 U32 datalen; 3160} WAVEOUTEXT; 3161 3162F32 evaluate_graph(MSSGRAPHPOINT const* graph, S32 cnt, F32 x); 3163 3164// 3165// platform allocators 3166// 3167 3168void * AILCALLBACK platform_alloc(UINTa size); 3169void AILCALLBACK platform_free( void * ptr ); 3170 3171 3172// 3173// Abstracted IO structures. 3174// 3175 3176#ifdef IS_WII 3177#define MAX_PLATFILE_SPECIFIC_SIZE 512 3178#else 3179#define MAX_PLATFILE_SPECIFIC_SIZE 32 3180#endif 3181typedef struct PLATFORM_FILE 3182{ 3183 char plat_specific[MAX_PLATFILE_SPECIFIC_SIZE]; // needs to be at the front for wii 3184 U32 offset; // current offset in to our "file" 3185 U32 start_pos; // offset of our "file" from the start of the physical file. 3186 U32 file_length; // length of our "file" 3187 S32 dont_close; // nonzero if we don't own the file handle, so when done, don't close. 3188 U32 raw_length; // length of the entire file that we might be "inside of" 3189} PLATFORM_FILE; 3190 3191typedef struct FNVALUES 3192{ 3193 char const * filename; 3194 U32 size; 3195 U32 start; 3196} FNVALUES; 3197 3198typedef struct FHVALUES 3199{ 3200 S32 hand; 3201 S32 length; 3202 S32 pos; 3203} FHVALUES; 3204 3205// 3206// Functions implemented per platform. 3207// 3208extern int Platform_OpenFile(struct PLATFORM_FILE* i_File, char const * fn); 3209extern void Platform_SeekFromBeginning(PLATFORM_FILE* i_File, S32 i_Offset); 3210extern U32 Platform_ReadFile(PLATFORM_FILE* i_File, void* o_Buffer, U32 i_ReadBytes); 3211extern void Platform_CloseFile(PLATFORM_FILE* i_File); 3212 3213DXDEC void AILCALL AIL_set_event_settings(void* i_Settings); 3214 3215// Auditioner Declarations 3216//----------------------------------------------------------------------------- 3217S32 Audition_Status(); 3218S32 Audition_Pump(); 3219void* Audition_OpenBank(char const* i_FileName); 3220S32 Audition_OpenComplete(void* i_Bank); 3221void Audition_CloseBank(void* i_Bank); 3222 3223void Audition_Suppress(S32 i_IsSuppressed); 3224void Audition_FrameStart(); 3225void Audition_FrameEnd(); 3226void Audition_DefragStart(); 3227void Audition_SetBlend(U64 i_EventId, char const* i_Name); 3228void Audition_SetPersist(U64 i_EventId, char const* i_Name, char const* i_Preset); 3229void Audition_Event(char const* i_EventName, U64 i_EventId, U64 i_Filter, S32 i_Exists, void* i_InitBlock, S32 i_InitBlockLen); 3230void Audition_Sound(U64 i_EventId, U64 i_SoundId, char const* i_Sound, char const* i_Label, float i_Volume, S32 i_Delay, float i_Pitch); 3231void Audition_SoundComplete(U64 i_SoundId); 3232void Audition_SoundPlaying(U64 i_SoundId); 3233void Audition_SoundFlags(U64 i_SoundId, S32 i_Flags); 3234void Audition_SoundLimited(U64 i_SoundId, char const* i_Label); 3235void Audition_SoundEvicted(U64 i_SoundId, U64 i_ForSound, S32 i_Reason); 3236void Audition_Control(U64 i_EventId, char const* i_Labels, U8 i_ControlType, U64 i_Filter); 3237void Audition_SoundBus(U64 i_SoundId, U8 i_BusIndex); 3238 3239void Audition_Error(U64 i_Id, char const* i_Details); 3240 3241void Audition_AsyncQueued(U64 i_RelevantId, S32 i_AsyncId, char const* i_Asset); 3242void Audition_AsyncLoad(S32 i_AsyncId, S32 i_ExpectedData); 3243void Audition_AsyncError(S32 i_AsyncId); 3244void Audition_AsyncComplete(S32 i_AsyncId, S32 i_DataLoaded); 3245void Audition_AsyncCancel(S32 i_AsyncId); 3246void Audition_ListenerPosition(float x, float y, float z); 3247void Audition_SoundPosition(U64 i_Sound, float x, float y, float z); 3248void Audition_SendCPU(HDIGDRIVER i_Driver); 3249void Audition_UpdateDataCount(S32 i_CurrentDataLoaded); 3250void Audition_SendCount(S32 i_SoundCount); 3251void Audition_HandleSystemLoad(S32 i_Avail, S32 i_Total); 3252void Audition_VarState(char const* i_Var, U64 i_SoundId, S32 i_Int, void* i_4ByteValue); 3253void Audition_RampState(char const* i_Ramp, U64 i_SoundId, S32 i_Type, float i_Current); 3254void Audition_SoundState(U64 i_SoundId, float i_FinalVol, float i_3DVol, float i_BlendVol, float i_BlendPitch, float i_RampVol, float i_RampWet, float i_RampLp, float i_RampRate); 3255void Audition_ClearState(); 3256void Audition_CompletionEvent(U64 i_CompletionEventId, U64 i_ParentSoundId); 3257void Audition_AddRamp(U64 i_ParentSoundId, S32 i_Type, char const* i_Name, char const* i_LabelQuery, U64 i_EventId); 3258 3259#if defined(IS_WIN32API) || defined(IS_WII) 3260 #pragma pack(pop) 3261#endif 3262#ifdef __cplusplus 3263} 3264#endif 3265 3266#endif 3267