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