1 /*---------------------------------------------------------------------------* 2 Project: Revolution AX library 3 File: AX.h 4 5 Copyright (C)1998-2006 Nintendo All Rights Reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Log: ax.h,v $ 14 Revision 1.30 2008/02/25 05:32:44 aka 15 Added AXGetAdpcmData(). 16 Added AXGetAdpcmOutputSize(). 17 Added AXGetAdpcmWorkSize(). 18 19 Revision 1.29 2008/02/08 08:19:30 aka 20 Added AXMakeCompressorTable(). 21 Added AXSetCompressorTable(). 22 23 Revision 1.28 2006/11/14 06:31:18 aka 24 Revised comment. 25 26 Revision 1.27 2006/11/07 12:01:57 aka 27 Added switch of Biquad IIR filter for remote outputs. 28 29 Revision 1.26 2006/11/07 04:19:32 aka 30 Removed HPF feature. 31 Added biquad IIR feature. 32 Added LPF feature for remote outputs. 33 34 Revision 1.25 2006/10/23 01:28:53 aka 35 Rolled-back AXInit() and AXInitEx(). 36 Added AXInitSpecifyMem() and AXInitExSpecifyMem(). 37 38 Revision 1.24 2006/10/11 11:55:48 aka 39 Added AXGetMasterVolume(). 40 Added AXSetMasterVolume(). 41 42 Revision 1.23 2006/10/10 04:54:55 aka 43 Removed AXSetMaxVoices(). 44 Removed AXSetMemory(). 45 Revised AXInit() & AXInitEx(). 46 47 Revision 1.22 2006/10/10 00:40:38 aka 48 Added AXIsInit(). 49 50 Revision 1.21 2006/10/06 06:52:50 aka 51 Added AXGetMemorySize(). 52 Added AXSetMaxVoices(). 53 Added AXGetMaxVoices(). 54 Added AXSetMemory(). 55 Added AXRegisterExceedCallback(). 56 57 Revision 1.20 2006/09/29 06:43:51 aka 58 Added aux return volume functions to 1.18. 59 60 Revision 1.19 2006/09/25 00:59:55 aka 61 Returned to 1.16 for SDK2.2 patch4. 62 Added aux return volume functions. 63 64 Revision 1.18 2006/09/18 04:36:38 aka 65 Changed AX_MAX_VOICES from 64 to 96. 66 67 Revision 1.17 2006/09/14 01:38:52 aka 68 Removed voice update function. 69 70 Revision 1.16 2006/09/05 10:19:23 aka 71 Added AXGetAuxA/B/CCallback(). 72 73 Revision 1.15 2006/08/14 02:00:38 aka 74 Removed AX_DSP_CYCLES_PBSYNC. 75 76 Revision 1.14 2006/07/25 00:55:22 aka 77 Added a definition AX_ENABLE_REMOTE. 78 79 Revision 1.13 2006/07/21 13:04:41 aka 80 Re-designed how to support controller speakers. 81 82 Revision 1.12 2006/07/19 07:40:48 aka 83 Renamed AX_PB_MIXCTRL_RMT_XXX. 84 85 Revision 1.11 2006/07/19 05:35:21 aka 86 Added AX_PB_MIXCTRL_RMT_XXX definitions for controller speakers. 87 88 Revision 1.10 2006/07/19 05:09:34 aka 89 Added AXRmtGetLpfCoefs() and AXRmtGetHpfCoefs() for controller speakers. 90 91 Revision 1.9 2006/07/19 04:42:13 aka 92 Added AX_RMT_SAMPLES_PER_XXX definitions. 93 94 Revision 1.8 2006/07/10 06:40:47 aka 95 Modified to support controller speakers. 96 97 Revision 1.7 2006/03/22 01:14:59 aka 98 Changed AX_MAX_VOICES from 32 to 64. 99 100 Revision 1.6 2006/03/15 08:25:26 aka 101 Revised AX_DSP_CYCLES. 102 103 Revision 1.5 2006/01/31 04:14:44 aka 104 Renamed "Project" from Dolphin to Revolution. 105 106 Revision 1.4 2006/01/31 01:01:54 aka 107 Removed some comments. 108 109 Revision 1.3 2006/01/30 11:50:16 aka 110 Changed copyright. 111 112 Revision 1.2 2006/01/30 11:29:59 aka 113 Changed some comments from Japanese to English. 114 115 Revision 1.1.1.1 2005/12/29 06:53:27 hiratsu 116 Initial import. 117 118 Revision 1.2 2005/11/07 06:42:32 aka 119 Changed suiting to Revolution's audio spec. 120 121 Revision 1.1.1.1 2005/05/12 02:41:06 yasuh-to 122 Imported from dolphin tree. 123 124 25 03/07/22 9:28a Akagi 125 Changed return of AXRegisterCallback from void to AXUserCallback. 126 127 24 03/06/11 2:58p Akagi 128 Added AXGetLpfCoefs. 129 130 23 03/04/15 19:53 Suzuki 131 added the definition of AX_OUTPUT_BUFFER_DOUBLE and 132 AX_OUTPUT_BUFFER_TRIPLE. 133 134 22 03/04/15 13:44 Suzuki 135 add AXInitEx. 136 137 21 03/04/04 13:26 Suzuki 138 add the definition of DSPADPCM 139 140 20 8/15/02 11:02a Billyjack 141 added low pass filter 142 143 19 02/08/12 5:55p Akagi 144 Added log field. 145 146 $NoKeywords: $ 147 *---------------------------------------------------------------------------*/ 148 149 #ifndef __AX_H__ 150 #define __AX_H__ 151 152 #ifdef __cplusplus 153 extern "C" { 154 #endif 155 156 /*--------------------------------------------------------------------------* 157 *--------------------------------------------------------------------------*/ 158 #define AX_ENABLE_REMOTE 159 160 /*--------------------------------------------------------------------------* 161 profiling 162 *--------------------------------------------------------------------------*/ 163 typedef struct _AXPROFILE 164 { 165 166 OSTime axFrameStart; 167 OSTime auxProcessingStart; 168 OSTime auxProcessingEnd; 169 OSTime userCallbackStart; 170 OSTime userCallbackEnd; 171 OSTime axFrameEnd; 172 u32 axNumVoices; 173 u32 __padding; 174 175 } AXPROFILE; 176 177 /*--------------------------------------------------------------------------* 178 mixing 179 *--------------------------------------------------------------------------*/ 180 typedef struct _AXPBMIX 181 { 182 // mixing values in .15, 0x8000 = ca. 1.0 183 184 u16 vL; 185 u16 vDeltaL; 186 u16 vR; 187 u16 vDeltaR; 188 189 u16 vAuxAL; 190 u16 vDeltaAuxAL; 191 u16 vAuxAR; 192 u16 vDeltaAuxAR; 193 194 u16 vAuxBL; 195 u16 vDeltaAuxBL; 196 u16 vAuxBR; 197 u16 vDeltaAuxBR; 198 199 u16 vAuxCL; 200 u16 vDeltaAuxCL; 201 u16 vAuxCR; 202 u16 vDeltaAuxCR; 203 204 u16 vS; 205 u16 vDeltaS; 206 u16 vAuxAS; 207 u16 vDeltaAuxAS; 208 u16 vAuxBS; 209 u16 vDeltaAuxBS; 210 u16 vAuxCS; 211 u16 vDeltaAuxCS; 212 213 } AXPBMIX; 214 215 #define AXPBMIX_VL_OFF AXPBMIX_OFF 216 #define AXPBMIX_VDELTAL_OFF (AXPBMIX_OFF+1) 217 #define AXPBMIX_VR_OFF (AXPBMIX_OFF+2) 218 #define AXPBMIX_VDELTAR_OFF (AXPBMIX_OFF+3) 219 220 #define AXPBMIX_VAUXAL_OFF (AXPBMIX_OFF+4) 221 #define AXPBMIX_VDELTAAUXAL_OFF (AXPBMIX_OFF+5) 222 #define AXPBMIX_VAUXAR_OFF (AXPBMIX_OFF+6) 223 #define AXPBMIX_VDELTAAUXAR_OFF (AXPBMIX_OFF+7) 224 225 #define AXPBMIX_VAUXBL_OFF (AXPBMIX_OFF+8) 226 #define AXPBMIX_VDELTAAUXBL_OFF (AXPBMIX_OFF+9) 227 #define AXPBMIX_VAUXBR_OFF (AXPBMIX_OFF+10) 228 #define AXPBMIX_VDELTAAUXBR_OFF (AXPBMIX_OFF+11) 229 230 #define AXPBMIX_VAUXCL_OFF (AXPBMIX_OFF+12) 231 #define AXPBMIX_VDELTAAUXCL_OFF (AXPBMIX_OFF+13) 232 #define AXPBMIX_VAUXCR_OFF (AXPBMIX_OFF+14) 233 #define AXPBMIX_VDELTAAUXCR_OFF (AXPBMIX_OFF+15) 234 235 #define AXPBMIX_VS_OFF (AXPBMIX_OFF+16) 236 #define AXPBMIX_VDELTAS_OFF (AXPBMIX_OFF+17) 237 #define AXPBMIX_VAUXAS_OFF (AXPBMIX_OFF+18) 238 #define AXPBMIX_VDELTAAUXAS_OFF (AXPBMIX_OFF+19) 239 #define AXPBMIX_VAUXBS_OFF (AXPBMIX_OFF+20) 240 #define AXPBMIX_VDELTAAUXBS_OFF (AXPBMIX_OFF+21) 241 #define AXPBMIX_VAUXCS_OFF (AXPBMIX_OFF+22) 242 #define AXPBMIX_VDELTAAUXCS_OFF (AXPBMIX_OFF+23) 243 244 #define AXPBMIX_SIZE 24 245 246 /*--------------------------------------------------------------------------* 247 mixing for remote speaker 248 *--------------------------------------------------------------------------*/ 249 typedef struct _AXPBRMTMIX 250 { 251 252 u16 vMain0; 253 u16 vDeltaMain0; 254 u16 vAux0; 255 u16 vDeltaAux0; 256 257 u16 vMain1; 258 u16 vDeltaMain1; 259 u16 vAux1; 260 u16 vDeltaAux1; 261 262 u16 vMain2; 263 u16 vDeltaMain2; 264 u16 vAux2; 265 u16 vDeltaAux2; 266 267 u16 vMain3; 268 u16 vDeltaMain3; 269 u16 vAux3; 270 u16 vDeltaAux3; 271 272 } AXPBRMTMIX; 273 274 #define AXPBRMTMIX_SIZE 16 275 276 /*--------------------------------------------------------------------------* 277 initial time delay 278 *--------------------------------------------------------------------------*/ 279 typedef struct _AXPBITD 280 { 281 282 u16 flag; // on or off for this voice 283 u16 bufferHi; // MRAM buffer 284 u16 bufferLo; // 285 u16 shiftL; // phase shift samples left (current) 286 u16 shiftR; // phase shift samples right (current) 287 u16 targetShiftL; // phase shift samples left (target) 288 u16 targetShiftR; // phase shift samples right (target) 289 290 } AXPBITD; 291 292 // flag 293 #define AX_PB_ITD_OFF 0x0000 294 #define AX_PB_ITD_ON 0x0001 295 296 #define AXPBITD_FLAG_OFF AXPBITD_OFF 297 #define AXPBITD_BUFFERHI_OFF (AXPBITD_OFF+1) 298 #define AXPBITD_BUFFERLO_OFF (AXPBITD_OFF+2) 299 #define AXPBITD_SHIFTL_OFF (AXPBITD_OFF+3) 300 #define AXPBITD_SHIFTR_OFF (AXPBITD_OFF+4) 301 #define AXPBITD_TARGETSHIFTL_OFF (AXPBITD_OFF+5) 302 #define AXPBITD_TARGETSHIFTR_OFF (AXPBITD_OFF+6) 303 #define AXPBITD_SIZE 7 304 305 /*--------------------------------------------------------------------------* 306 depop data (last amplitudes mixed into buffers) 307 *--------------------------------------------------------------------------*/ 308 typedef struct _AXPBDPOP 309 { 310 311 s16 aL; 312 s16 aAuxAL; 313 s16 aAuxBL; 314 s16 aAuxCL; 315 316 s16 aR; 317 s16 aAuxAR; 318 s16 aAuxBR; 319 s16 aAuxCR; 320 321 s16 aS; 322 s16 aAuxAS; 323 s16 aAuxBS; 324 s16 aAuxCS; 325 326 } AXPBDPOP; 327 328 #define AXPBDPOP_AL_OFF AXPBDPOP_OFF 329 #define AXPBDPOP_AAUXAL_OFF (AXPBDPOP_OFF+1) 330 #define AXPBDPOP_AAUXBL_OFF (AXPBDPOP_OFF+2) 331 #define AXPBDPOP_AAUXCL_OFF (AXPBDPOP_OFF+3) 332 333 #define AXPBDPOP_AR_OFF (AXPBDPOP_OFF+4) 334 #define AXPBDPOP_AAUXAR_OFF (AXPBDPOP_OFF+5) 335 #define AXPBDPOP_AAUXBR_OFF (AXPBDPOP_OFF+6) 336 #define AXPBDPOP_AAUXCR_OFF (AXPBDPOP_OFF+7) 337 338 #define AXPBDPOP_AS_OFF (AXPBDPOP_OFF+8) 339 #define AXPBDPOP_AAUXAS_OFF (AXPBDPOP_OFF+9) 340 #define AXPBDPOP_AAUXBS_OFF (AXPBDPOP_OFF+10) 341 #define AXPBDPOP_AAUXCS_OFF (AXPBDPOP_OFF+11) 342 343 #define AXPBDPOP_SIZE 12 344 345 /*--------------------------------------------------------------------------* 346 depop data for remote speakers 347 *--------------------------------------------------------------------------*/ 348 typedef struct _AXPBRMTDPOP 349 { 350 351 s16 aMain0; 352 s16 aMain1; 353 s16 aMain2; 354 s16 aMain3; 355 356 s16 aAux0; 357 s16 aAux1; 358 s16 aAux2; 359 s16 aAux3; 360 361 } AXPBRMTDPOP; 362 363 #define AXPBDRMTPOP_SIZE 8 364 365 /*--------------------------------------------------------------------------* 366 volume envelope 367 *--------------------------------------------------------------------------*/ 368 typedef struct _AXPBVE 369 { 370 371 u16 currentVolume; // .15 volume at start of frame 372 s16 currentDelta; // signed per sample delta delta 373 374 } AXPBVE; 375 376 #define AXPBVE_CURRENTVOLUME_OFF AXPBVE_OFF 377 #define AXPBVE_CURRENTDELTA_OFF (AXPBVE_OFF+1) 378 #define AXPBVE_SIZE 2 379 380 /*--------------------------------------------------------------------------* 381 buffer addressing 382 *--------------------------------------------------------------------------*/ 383 typedef struct _AXPBADDR 384 { // all values are mesured in samples: 385 386 u16 loopFlag; // 0 = one-shot, 1=looping 387 u16 format; // sample format used (see below) 388 u16 loopAddressHi; // Start of loop (this will point to a shared "zero" buffer if one-shot mode is active) 389 u16 loopAddressLo; 390 u16 endAddressHi; // End of sample (and loop) 391 u16 endAddressLo; 392 u16 currentAddressHi; // Current playback position 393 u16 currentAddressLo; 394 395 } AXPBADDR; 396 397 #define AXPBADDR_LOOP_OFF 0 // States for loopFlag field 398 #define AXPBADDR_LOOP_ON 1 399 400 #define AXPBADDR_LOOPFLAG_OFF AXPBADDR_OFF 401 #define AXPBADDR_FORMAT_OFF (AXPBADDR_OFF+1) 402 #define AXPBADDR_LOOPADDRESSHI_OFF (AXPBADDR_OFF+2) 403 #define AXPBADDR_LOOPADDRESSLO_OFF (AXPBADDR_OFF+3) 404 #define AXPBADDR_ENDADDRESSHI_OFF (AXPBADDR_OFF+4) 405 #define AXPBADDR_ENDADDRESSLO_OFF (AXPBADDR_OFF+5) 406 #define AXPBADDR_CURRENTADDRESSHI_OFF (AXPBADDR_OFF+6) 407 #define AXPBADDR_CURRENTADDRESSLO_OFF (AXPBADDR_OFF+7) 408 #define AXPBADDR_SIZE 8 409 410 /*--------------------------------------------------------------------------* 411 ADPCM decoder state 412 *--------------------------------------------------------------------------*/ 413 typedef struct _AXPBADPCM 414 { 415 416 u16 a[8][2]; // coef table a1[0],a2[0],a1[1],a2[1].... 417 418 u16 gain; // gain to be applied (0 for ADPCM, 0x0800 for PCM8/16) 419 420 u16 pred_scale; // predictor / scale combination (nibbles, as in hardware) 421 u16 yn1; // y[n - 1] 422 u16 yn2; // y[n - 2] 423 424 } AXPBADPCM; 425 426 #define AXPBADPCM_A1 AXPBADPCM_OFF 427 #define AXPBADPCM_A2 (AXPBADPCM_OFF+8) 428 #define AXPBADPCM_GAIN (AXPBADPCM_OFF+16 429 #define AXPBADPCM_PRED_SCALE (AXPBADPCM_OFF+17) 430 #define AXPBADPCM_YN1 (AXPBADPCM_OFF+18) 431 #define AXPBADPCM_YN2 (AXPBADPCM_OFF+19) 432 #define AXPBADPCM_SIZE 20 433 434 /*--------------------------------------------------------------------------* 435 sample rate converter state 436 *--------------------------------------------------------------------------*/ 437 typedef struct _AXPBSRC 438 { 439 440 u16 ratioHi; // sampling ratio, integer 441 u16 ratioLo; // sampling ratio, fraction 442 443 u16 currentAddressFrac; // current fractional sample position 444 445 u16 last_samples[4]; // last 4 input samples 446 447 } AXPBSRC; 448 449 #define AXPBSRC_RATIOHI_OFF AXPBSRC_OFF 450 #define AXPBSRC_RATIOLO_OFF (AXPBSRC_OFF+1) 451 #define AXPBSRC_CURRENTADDRESSFRAC_OFF (AXPBSRC_OFF+2) 452 #define AXPBSRC_LAST_SAMPLES_OFF (AXPBSRC_OFF+3) // 4 words 453 #define AXPBSRC_SIZE 7 454 455 /*--------------------------------------------------------------------------* 456 sample rate converter state for remote speakers 457 *--------------------------------------------------------------------------*/ 458 typedef struct _AXPBRMTSRC 459 { 460 461 u16 currentAddressFrac; // current fractional sample position 462 463 u16 last_samples[4]; // last 4 input samples 464 465 } AXPBRMTSRC; 466 467 #define AXPBRMTSRC_SIZE 5 468 469 /*--------------------------------------------------------------------------* 470 ADPCM loop parameters 471 *--------------------------------------------------------------------------*/ 472 typedef struct _AXPBADPCMLOOP 473 { 474 475 u16 loop_pred_scale; // predictor / scale combination (nibbles, as in hardware) 476 u16 loop_yn1; // y[n - 1] 477 u16 loop_yn2; // y[n - 2] 478 479 } AXPBADPCMLOOP; 480 481 #define AXPBADPCMLOOP_PRED_SCALE AXPBADPCMLOOP_OFF 482 #define AXPBADPCMLOOP_YN1 (AXPBADPCMLOOP_OFF+1) 483 #define AXPBADPCMLOOP_YN2 (AXPBADPCMLOOP_OFF+2) 484 #define AXPBADPCMLOOP_SIZE 3 485 486 /*--------------------------------------------------------------------------* 487 IIR filter parameters (lowpass) 488 *--------------------------------------------------------------------------*/ 489 typedef struct _AXPBLPF 490 { 491 492 u16 on; 493 u16 yn1; 494 u16 a0; 495 u16 b0; 496 497 } AXPBLPF; 498 499 #define AXPBLPF_ON AXPBLPF_OFF 500 #define AXPBLPF_YN1 (AXPBLPF_OFF+1) 501 #define AXPBLPF_A0 (AXPBLPF_OFF+2) 502 #define AXPBLPF_B0 (AXPBLPF_OFF+3) 503 #define AXPBLPF_SIZE 4 504 505 /*--------------------------------------------------------------------------* 506 Biquad IIR filter parameters 507 *--------------------------------------------------------------------------*/ 508 typedef struct _AXPBBIQUAD 509 { 510 511 u16 on; 512 u16 xn1; 513 u16 xn2; 514 u16 yn1; 515 u16 yn2; 516 u16 b0; 517 u16 b1; 518 u16 b2; 519 u16 a1; 520 u16 a2; 521 522 } AXPBBIQUAD; 523 524 #define AXPBBIQUAD_ON AXPBBIQUAD_OFF 525 #define AXPBBIQUAD_XN1 (AXPBBIQUAD_OFF+1) 526 #define AXPBBIQUAD_XN2 (AXPBBIQUAD_OFF+2) 527 #define AXPBBIQUAD_YN1 (AXPBBIQUAD_OFF+3) 528 #define AXPBBIQUAD_YN2 (AXPBBIQUAD_OFF+4) 529 #define AXPBBIQUAD_B0 (AXPBBIQUAD_OFF+5) 530 #define AXPBBIQUAD_B1 (AXPBBIQUAD_OFF+6) 531 #define AXPBBIQUAD_B2 (AXPBBIQUAD_OFF+7) 532 #define AXPBBIQUAD_A1 (AXPBBIQUAD_OFF+8) 533 #define AXPBBIQUAD_A2 (AXPBBIQUAD_OFF+9) 534 #define AXPBBIQUAD_SIZE 10 535 536 /*--------------------------------------------------------------------------* 537 IIR filter for remote speakers 538 *--------------------------------------------------------------------------*/ 539 typedef union __AXPBRMTIIR 540 { 541 AXPBLPF lpf; 542 AXPBBIQUAD biquad; 543 544 } AXPBRMTIIR; 545 546 #define AXPBRMTIIR_SIZE 10 547 548 /*--------------------------------------------------------------------------* 549 voice parameter block 550 *--------------------------------------------------------------------------*/ 551 typedef struct _AXPB 552 { 553 554 u16 nextHi; // pointer to next parameter buffer (MRAM) 555 u16 nextLo; 556 557 u16 currHi; // pointer to this parameter buffer (MRAM) 558 u16 currLo; 559 560 u16 srcSelect; // Select type of SRC (none,4-tap,linear) 561 u16 coefSelect; // Coef. to be used with 4-tap SRC 562 u32 mixerCtrl; // Mixer control bits 563 564 u16 state; // current state (see below) 565 u16 type; // type of voice (stream) 566 567 AXPBMIX mix; 568 AXPBITD itd; 569 AXPBDPOP dpop; 570 AXPBVE ve; 571 AXPBADDR addr; 572 AXPBADPCM adpcm; 573 AXPBSRC src; 574 AXPBADPCMLOOP adpcmLoop; 575 AXPBLPF lpf; 576 AXPBBIQUAD biquad; 577 578 u16 remote; 579 580 u16 rmtMixerCtrl; // Mixer control bits 581 582 AXPBRMTMIX rmtMix; 583 AXPBRMTDPOP rmtDpop; 584 AXPBRMTSRC rmtSrc; 585 AXPBRMTIIR rmtIIR; 586 587 u16 pad[12]; // 32 byte alignment 588 589 } AXPB; 590 591 // state 592 #define AX_PB_STATE_STOP 0x0000 593 #define AX_PB_STATE_RUN 0x0001 594 595 // type 596 #define AX_PB_TYPE_NORMAL 0x0000 597 #define AX_PB_TYPE_STREAM 0x0001 // no loop context programming for ADPCM 598 599 // format 600 #define AX_PB_FORMAT_PCM16 0x000A // signed 16 bit PCM mono 601 #define AX_PB_FORMAT_PCM8 0x0019 // signed 8 bit PCM mono 602 #define AX_PB_FORMAT_ADPCM 0x0000 // ADPCM encoded (both standard & extended) 603 604 // src select 605 #define AX_PB_SRCSEL_POLYPHASE 0x0000 // N64 type polyphase filter (4-tap) 606 #define AX_PB_SRCSEL_LINEAR 0x0001 // Linear interpolator 607 #define AX_PB_SRCSEL_NONE 0x0002 // No SRC (1:1) 608 609 // coef select 610 #define AX_PB_COEFSEL_8KHZ 0x0000 // 8KHz low pass response 611 #define AX_PB_COEFSEL_12KHZ 0x0001 // 12.8KHz N64 type response 612 #define AX_PB_COEFSEL_16KHZ 0x0002 // 16KHz response 613 614 // mixer ctrl for main speakers 615 #define AX_PB_MIXCTRL_L 0x00000001 // main left mix 616 #define AX_PB_MIXCTRL_R 0x00000002 // main right mix 617 #define AX_PB_MIXCTRL_LR_RAMP 0x00000004 // main bus ramp (applies to LR only) 618 #define AX_PB_MIXCTRL_S 0x00000008 // main surround mix 619 #define AX_PB_MIXCTRL_S_RAMP 0x00000010 // main bus ramp (applies to S only) 620 621 #define AX_PB_MIXCTRL_A_L 0x00010000 // AuxA left mix 622 #define AX_PB_MIXCTRL_A_R 0x00020000 // AuxA rigth mix 623 #define AX_PB_MIXCTRL_A_LR_RAMP 0x00040000 // AuxA bus ramp (applies to LR only) 624 #define AX_PB_MIXCTRL_A_S 0x00080000 // AuxA surround mix 625 #define AX_PB_MIXCTRL_A_S_RAMP 0x00100000 // AuxA bus ramp (applies to S only) 626 627 #define AX_PB_MIXCTRL_B_L 0x00200000 // AuxB left mix 628 #define AX_PB_MIXCTRL_B_R 0x00400000 // AuxB rigth mix 629 #define AX_PB_MIXCTRL_B_LR_RAMP 0x00800000 // AuxB bus ramp (applies to LR only) 630 #define AX_PB_MIXCTRL_B_S 0x01000000 // AuxB surround mix 631 #define AX_PB_MIXCTRL_B_S_RAMP 0x02000000 // AuxB bus ramp (applies to S only) 632 633 #define AX_PB_MIXCTRL_C_L 0x04000000 // AuxCleft mix 634 #define AX_PB_MIXCTRL_C_R 0x08000000 // AuxC rigth mix 635 #define AX_PB_MIXCTRL_C_LR_RAMP 0x10000000 // AuxC bus ramp (applies to LR only) 636 #define AX_PB_MIXCTRL_C_S 0x20000000 // AuxC surround mix 637 #define AX_PB_MIXCTRL_C_S_RAMP 0x40000000 // AuxC bus ramp (applies to S only) 638 #define AX_PB_MIXCTRL_C_DPL2 0x80000000 // AuxC DPL2, does not apply ITD for surrounds 639 640 // IIR filter switch 641 #define AX_PB_LPF_OFF 0x0000 // LPF switch 642 #define AX_PB_LPF_ON 0x0001 643 644 #define AX_PB_BIQUAD_OFF 0x0000 // Biquad IIR filter switch 645 #define AX_PB_BIQUAD_ON 0x0002 646 647 // output 648 #define AX_PB_REMOTE_OFF 0x0000 649 #define AX_PB_REMOTE_ON 0x0001 650 651 // mixer ctrl for remote speakers 652 #define AX_PB_MIXCTRL_MAIN0 0x0001 // main0 mix 653 #define AX_PB_MIXCTRL_MAIN0_RAMP 0x0002 // main0 mix with ramp 654 #define AX_PB_MIXCTRL_AUX0 0x0004 // aux0 655 #define AX_PB_MIXCTRL_AUX0_RAMP 0x0008 // aux0 mix with ramp 656 #define AX_PB_MIXCTRL_MAIN1 0x0010 // main1 657 #define AX_PB_MIXCTRL_MAIN1_RAMP 0x0020 // main1 mix with ramp 658 #define AX_PB_MIXCTRL_AUX1 0x0040 // aux1 659 #define AX_PB_MIXCTRL_AUX1_RAMP 0x0080 // aux1 mix with ramp 660 #define AX_PB_MIXCTRL_MAIN2 0x0100 // main2 661 #define AX_PB_MIXCTRL_MAIN2_RAMP 0x0200 // main2 mix with ramp 662 #define AX_PB_MIXCTRL_AUX2 0x0400 // aux2 663 #define AX_PB_MIXCTRL_AUX2_RAMP 0x0800 // aux2 mix with ramp 664 #define AX_PB_MIXCTRL_MAIN3 0x1000 // main3 665 #define AX_PB_MIXCTRL_MAIN3_RAMP 0x2000 // main3 mix with ramp 666 #define AX_PB_MIXCTRL_AUX3 0x4000 // aux3 667 #define AX_PB_MIXCTRL_AUX3_RAMP 0x8000 // aux3 mix with ramp 668 669 #define AX_PB_NEXTHI_OFF 0 670 #define AX_PB_NEXTLO_OFF 1 671 #define AX_PB_CURRHI_OFF 2 672 #define AX_PB_CURRLO_OFF 3 673 #define AX_PB_SRCSELECT_OFF 4 674 #define AX_PB_COEFSELECT_OFF 5 675 #define AX_PB_MIXERCTRL_OFF 6 676 #define AX_PB_STATE_OFF 8 677 #define AX_PB_TYPE_OFF 9 678 #define AXPBMIX_OFF 10 679 680 #define AXPBITD_OFF (AXPBMIX_OFF + AXPBMIX_SIZE) 681 #define AXPBDPOP_OFF (AXPBITD_OFF + AXPBITD_SIZE) 682 #define AXPBVE_OFF (AXPBDPOP_OFF + AXPBDPOP_SIZE) 683 #define AXPBADDR_OFF (AXPBVE_OFF + AXPBVE_SIZE) 684 #define AXPBADPCM_OFF (AXPBADDR_OFF + AXPBADDR_SIZE) 685 #define AXPBSRC_OFF (AXPBADPCM_OFF + AXPBADPCM_SIZE) 686 #define AXPBADPCMLOOP_OFF (AXPBSRC_OFF + AXPBSRC_SIZE) 687 #define AXPBLPF_OFF (AXPBADPCMLOOP_OFF + AXPBADPCMLOOP_SIZE) 688 #define AXPBBIQUAD_OFF (AXPBLPF_OFF + AXPBLPF_SIZE) 689 690 #define AXPBREMOTE_OFF (AXPBBIQUAD_OFF + AXPBBIQUAD_SIZE) 691 #define AXPBRMTMIXCTRL_OFF (AXPBREMOTE_OFF + 1) 692 #define AXPBRMTMIX_OFF (AXPBRMTMIXCTRL_OFF+ 1) 693 #define AXPBRMTDPOP_OFF (AXPBRMTMIX_OFF + AXPBRMTMIX_SIZE) 694 #define AXPBRMTSRC_OFF (AXPBRMTDPOP_OFF + AXPBRMTDPOP_SIZE) 695 #define AXPBRMTIIR_OFF (AXPBRMTSRC_OFF + AXPBRMTSRC_SIZE) 696 697 #define AX_PB_SIZE (AXPBRMTIIR_OFF + AXPBRMTIIR_SIZE) 698 699 /*--------------------------------------------------------------------------* 700 studio parameter block 701 *--------------------------------------------------------------------------*/ 702 703 typedef struct _AXSPB 704 { 705 u16 dpopLHi; 706 u16 dpopLLo; 707 s16 dpopLDelta; 708 u16 dpopRHi; 709 u16 dpopRLo; 710 s16 dpopRDelta; 711 u16 dpopSHi; 712 u16 dpopSLo; 713 s16 dpopSDelta; 714 715 u16 dpopALHi; 716 u16 dpopALLo; 717 s16 dpopALDelta; 718 u16 dpopARHi; 719 u16 dpopARLo; 720 s16 dpopARDelta; 721 u16 dpopASHi; 722 u16 dpopASLo; 723 s16 dpopASDelta; 724 725 u16 dpopBLHi; 726 u16 dpopBLLo; 727 s16 dpopBLDelta; 728 u16 dpopBRHi; 729 u16 dpopBRLo; 730 s16 dpopBRDelta; 731 u16 dpopBSHi; 732 u16 dpopBSLo; 733 s16 dpopBSDelta; 734 735 u16 dpopCLHi; 736 u16 dpopCLLo; 737 s16 dpopCLDelta; 738 u16 dpopCRHi; 739 u16 dpopCRLo; 740 s16 dpopCRDelta; 741 u16 dpopCSHi; 742 u16 dpopCSLo; 743 s16 dpopCSDelta; 744 745 u16 dpopMain0Hi; 746 u16 dpopMain0Lo; 747 s16 dpopMain0Delta; 748 u16 dpopAux0Hi; 749 u16 dpopAux0Lo; 750 s16 dpopAux0Delta; 751 752 u16 dpopMain1Hi; 753 u16 dpopMain1Lo; 754 s16 dpopMain1Delta; 755 u16 dpopAux1Hi; 756 u16 dpopAux1Lo; 757 s16 dpopAux1Delta; 758 759 u16 dpopMain2Hi; 760 u16 dpopMain2Lo; 761 s16 dpopMain2Delta; 762 u16 dpopAux2Hi; 763 u16 dpopAux2Lo; 764 s16 dpopAux2Delta; 765 766 u16 dpopMain3Hi; 767 u16 dpopMain3Lo; 768 s16 dpopMain3Delta; 769 u16 dpopAux3Hi; 770 u16 dpopAux3Lo; 771 s16 dpopAux3Delta; 772 773 } AXSPB; 774 775 /*---------------------------------------------------------------------------* 776 *---------------------------------------------------------------------------*/ 777 #define AX_DSP_CYCLES (OS_BUS_CLOCK / 667) 778 779 /*---------------------------------------------------------------------------* 780 *---------------------------------------------------------------------------*/ 781 #define AX_MAX_VOICES 96 782 783 #define AX_MS_PER_FRAME 3 784 785 #define AX_IN_SAMPLES_PER_MS 32 786 #define AX_IN_SAMPLES_PER_SEC (AX_IN_SAMPLES_PER_MS * 1000) 787 #define AX_IN_SAMPLES_PER_FRAME (AX_IN_SAMPLES_PER_MS * AX_MS_PER_FRAME) 788 789 /*---------------------------------------------------------------------------* 790 *---------------------------------------------------------------------------*/ 791 #define AX_RMT_SAMPLES_PER_MS 6 792 #define AX_RMT_SAMPLES_PER_SEC (AX_RMT_SAMPLES_PER_MS * 1000) 793 #define AX_RMT_SAMPLES_PER_FRAME (AX_RMT_SAMPLES_PER_MS * AX_MS_PER_FRAME) 794 795 /*---------------------------------------------------------------------------* 796 *---------------------------------------------------------------------------*/ 797 #define AX_MODE_STEREO 0 798 #define AX_MODE_SURROUND 1 799 #define AX_MODE_DPL2 2 800 801 /*---------------------------------------------------------------------------* 802 *---------------------------------------------------------------------------*/ 803 #define AX_COMPRESSOR_OFF 0 804 #define AX_COMPRESSOR_ON 1 805 806 /*---------------------------------------------------------------------------* 807 *---------------------------------------------------------------------------*/ 808 #define AX_PRIORITY_STACKS 32 809 #define AX_PRIORITY_NODROP (AX_PRIORITY_STACKS - 1) 810 #define AX_PRIORITY_LOWEST 1 811 #define AX_PRIORITY_FREE 0 812 813 /*---------------------------------------------------------------------------* 814 *---------------------------------------------------------------------------*/ 815 #define AX_SRC_TYPE_NONE 0 816 #define AX_SRC_TYPE_LINEAR 1 817 #define AX_SRC_TYPE_4TAP_8K 2 818 #define AX_SRC_TYPE_4TAP_12K 3 819 #define AX_SRC_TYPE_4TAP_16K 4 820 821 /*---------------------------------------------------------------------------* 822 *---------------------------------------------------------------------------*/ 823 #define AX_ADDR_ONESHOT 0 824 #define AX_ADDR_LOOP 1 825 826 /*---------------------------------------------------------------------------* 827 *---------------------------------------------------------------------------*/ 828 #define AX_SYNC_NONEWPARAMS 0x00000000 829 #define AX_SYNC_USER_SRCSELECT 0x00000001 830 #define AX_SYNC_USER_MIXCTRL 0x00000002 831 #define AX_SYNC_USER_STATE 0x00000004 832 #define AX_SYNC_USER_TYPE 0x00000008 833 #define AX_SYNC_USER_MIX 0x00000010 834 #define AX_SYNC_USER_ITD 0x00000020 835 #define AX_SYNC_USER_ITDTARGET 0x00000040 836 #define AX_SYNC_USER_DPOP 0x00000080 837 #define AX_SYNC_USER_VE 0x00000100 838 #define AX_SYNC_USER_VEDELTA 0x00000200 839 #define AX_SYNC_USER_ADDR 0x00000400 840 #define AX_SYNC_USER_LOOP 0x00000800 841 #define AX_SYNC_USER_LOOPADDR 0x00001000 842 #define AX_SYNC_USER_ENDADDR 0x00002000 843 #define AX_SYNC_USER_CURRADDR 0x00004000 844 #define AX_SYNC_USER_ADPCM 0x00008000 845 #define AX_SYNC_USER_SRC 0x00010000 846 #define AX_SYNC_USER_SRCRATIO 0x00020000 847 #define AX_SYNC_USER_ADPCMLOOP 0x00040000 848 #define AX_SYNC_USER_LPF 0x00080000 849 #define AX_SYNC_USER_LPF_COEF 0x00100000 850 #define AX_SYNC_USER_BIQUAD 0x00200000 851 #define AX_SYNC_USER_BIQUAD_COEF 0x00400000 852 #define AX_SYNC_USER_REMOTE 0x00800000 853 #define AX_SYNC_USER_RMTMIXCTRL 0x01000000 854 #define AX_SYNC_USER_RMTMIX 0x02000000 855 #define AX_SYNC_USER_RMTDPOP 0x04000000 856 #define AX_SYNC_USER_RMTSRC 0x08000000 857 #define AX_SYNC_USER_RMTIIR 0x10000000 858 #define AX_SYNC_USER_RMTIIR_COEF1 0x20000000 859 #define AX_SYNC_USER_RMTIIR_COEF2 0x40000000 860 861 #define AX_SYNC_USER_ALLPARAMS 0x80000000 862 863 /*---------------------------------------------------------------------------* 864 *---------------------------------------------------------------------------*/ 865 #define AX_OUTPUT_BUFFER_DOUBLE 0 866 #define AX_OUTPUT_BUFFER_TRIPLE 1 867 868 /*---------------------------------------------------------------------------* 869 callback interface 870 *---------------------------------------------------------------------------*/ 871 typedef void (*AXUserCallback) (void); 872 typedef void (*AXAuxCallback) (void *data, void *context); 873 typedef void (*AXVoiceCallback) (void *p); 874 typedef void (*AXExceedCallback) (u32 cycles); 875 876 /*---------------------------------------------------------------------------* 877 *---------------------------------------------------------------------------*/ 878 typedef struct _AXVPB 879 { 880 void *next; // used in priority stacks 881 void *prev; // used in priority stacks 882 void *next1; // used in callback stack 883 884 // these ares are used in voice allocation 885 u32 priority; // index to stack 886 AXVoiceCallback callback; // user callback for specified 887 u32 userContext; // user assigned context for callback 888 889 // vars & flags for updating and sync PBs 890 u32 index; // index of VPB in array 891 u32 sync; // bit mask for each PB item to sync 892 u32 depop; // should depop voice 893 void *itdBuffer; // pointer to itd buffer 894 AXPB pb; // write params to this PB 895 896 } AXVPB; 897 898 typedef struct _AXPBITDBUFFER 899 { 900 901 s16 data[32]; 902 903 } AXPBITDBUFFER; 904 905 /*---------------------------------------------------------------------------* 906 Header for DSPADPCM.exe header 907 *---------------------------------------------------------------------------*/ 908 typedef struct 909 { 910 u32 num_samples; // total number of RAW samples 911 u32 num_adpcm_nibbles; // number of ADPCM nibbles (including frame headers) 912 u32 sample_rate; // Sample rate, in Hz 913 u16 loop_flag; // 1=LOOPED, 0=NOT LOOPED 914 u16 format; // Always 0x0000, for ADPCM 915 u32 sa; // Start offset address for looped samples (zero for non-looped) 916 u32 ea; // End offset address for looped samples 917 u32 ca; // always zero 918 u16 coef[16]; // decode coefficients (eight pairs of 16-bit words) 919 u16 gain; // always zero for ADPCM 920 u16 ps; // predictor/scale 921 u16 yn1; // sample history 922 u16 yn2; // sample history 923 u16 lps; // predictor/scale for loop context 924 u16 lyn1; // sample history (n-1) for loop context 925 u16 lyn2; // sample history (n-2) for loop context 926 u16 pad[11]; // reserved 927 928 } DSPADPCM; 929 930 /*---------------------------------------------------------------------------* 931 *---------------------------------------------------------------------------*/ 932 void AXInit (void); 933 void AXInitEx (u32 outputBufferMode); 934 void AXInitSpecifyMem (u32 num, void* mem); 935 void AXInitExSpecifyMem (u32 num, void* mem, u32 outputBufferMode); 936 BOOL AXIsInit (void); 937 void AXQuit (void); 938 939 #define AXGetMemorySize(num) ((sizeof(AXPB) + sizeof(AXPBITDBUFFER) + sizeof(AXVPB)) * num) 940 941 u32 AXGetMaxVoices (void); 942 943 AXUserCallback AXRegisterCallback (AXUserCallback callback); 944 945 void AXSetMode (u32 mode); 946 u32 AXGetMode (void); 947 948 void AXSetMaxDspCycles (u32 cycles); 949 u32 AXGetMaxDspCycles (void); 950 u32 AXGetDspCycles (void); 951 952 void AXRegisterAuxACallback (AXAuxCallback callback, void *context); 953 void AXRegisterAuxBCallback (AXAuxCallback callback, void *context); 954 void AXRegisterAuxCCallback (AXAuxCallback callback, void *context); 955 956 void AXGetAuxACallback (AXAuxCallback *callback, void **context); 957 void AXGetAuxBCallback (AXAuxCallback *callback, void **context); 958 void AXGetAuxCCallback (AXAuxCallback *callback, void **context); 959 960 u16 AXGetMasterVolume (void); 961 void AXSetMasterVolume (u16 volume); 962 963 u16 AXGetAuxAReturnVolume (void); 964 u16 AXGetAuxBReturnVolume (void); 965 u16 AXGetAuxCReturnVolume (void); 966 void AXSetAuxAReturnVolume (u16 volume); 967 void AXSetAuxBReturnVolume (u16 volume); 968 void AXSetAuxCReturnVolume (u16 volume); 969 970 AXVPB* AXAcquireVoice ( 971 u32 priority, 972 AXVoiceCallback callback, 973 u32 userContext 974 ); 975 976 void AXFreeVoice (AXVPB *p); 977 void AXSetVoicePriority (AXVPB *p, u32 priority); 978 979 void AXSetVoiceSrcType (AXVPB *p, u32 type); 980 void AXSetVoiceState (AXVPB *p, u16 state); 981 void AXSetVoiceType (AXVPB *p, u16 type); 982 void AXSetVoiceMix (AXVPB *p, AXPBMIX *mix); 983 void AXSetVoiceItdOn (AXVPB *p); 984 void AXSetVoiceItdTarget (AXVPB *p, u16 lShift, u16 rShift); 985 void AXSetVoiceDpop (AXVPB *p, AXPBDPOP *dpop); 986 void AXSetVoiceVe (AXVPB *p, AXPBVE *ve); 987 void AXSetVoiceVeDelta (AXVPB *p, s16 delta); 988 void AXSetVoiceAddr (AXVPB *p, AXPBADDR *addr); 989 void AXSetVoiceLoop (AXVPB *p, u16 loop); 990 void AXSetVoiceLoopAddr (AXVPB *p, u32 address); 991 void AXSetVoiceEndAddr (AXVPB *p, u32 address); 992 void AXSetVoiceCurrentAddr (AXVPB *p, u32 address); 993 void AXSetVoiceAdpcm (AXVPB *p, AXPBADPCM *adpcm); 994 void AXSetVoiceSrc (AXVPB *p, AXPBSRC *src); 995 void AXSetVoiceSrcRatio (AXVPB *p, f32 ratio); 996 void AXSetVoiceAdpcmLoop (AXVPB *p, AXPBADPCMLOOP *adpcmloop); 997 void AXSetVoiceLpf (AXVPB *p, AXPBLPF *lpf); 998 void AXSetVoiceLpfCoefs (AXVPB *p, u16 a0, u16 b0); 999 void AXSetVoiceBiquad (AXVPB *p, AXPBBIQUAD *biquad); 1000 void AXSetVoiceBiquadCoefs (AXVPB *p, u16 b0, u16 b1, u16 b2, u16 a1, u16 a2); 1001 1002 void AXInitProfile (AXPROFILE *profile, u32 maxProfiles); 1003 u32 AXGetProfile (void); 1004 1005 void AXSetCompressor (u32); 1006 void AXMakeCompressorTable (f32 gain, u16 frames, u16* table); 1007 void AXSetCompressorTable (u16* table, u16 frames); 1008 1009 void AXSetStepMode (u32); 1010 1011 void AXGetLpfCoefs (u16 freq, u16 *a0, u16 *b0); 1012 1013 void AXSetVoiceRmtOn (AXVPB *p, u16 on); 1014 void AXSetVoiceRmtMix (AXVPB *p, AXPBRMTMIX *mix); 1015 void AXSetVoiceRmtDpop (AXVPB *p, AXPBRMTDPOP *dpop); 1016 void AXSetVoiceRmtSrc (AXVPB *p, AXPBRMTSRC *src); 1017 void AXSetVoiceRmtIIR (AXVPB *p, AXPBRMTIIR *iir); 1018 void AXSetVoiceRmtIIRCoefs (AXVPB *p, u16 type, ...); 1019 1020 s32 AXRmtGetSamplesLeft (void); 1021 s32 AXRmtGetSamples (s32 chan, s16* buffer, s32 samples); 1022 s32 AXRmtAdvancePtr (s32 samples); 1023 1024 void AXRegisterExceedCallback (AXExceedCallback callback); 1025 1026 s32 AXGetAdpcmOutputSize (s32 samples); 1027 s32 AXGetAdpcmWorkSize (s32 samples); 1028 s32 AXGetAdpcmData (s16* input, 1029 s32 samples, 1030 s32 rate, 1031 s32 loop_start, 1032 s32 loop_end, 1033 u8* output, 1034 DSPADPCM* info, 1035 void* work); 1036 1037 #ifdef __cplusplus 1038 } 1039 #endif 1040 1041 #endif // __AX_H__ 1042