1 /*---------------------------------------------------------------------------* 2 Project: Cafe AX library 3 File: AX.h 4 5 Copyright (C) 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 *---------------------------------------------------------------------------*/ 14 15 #ifndef __AX_H__ 16 #define __AX_H__ 17 18 #include <cafe/os.h> 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 24 #define AX_ENABLE_REMOTE 25 26 #define AXSYNC_ERROR_IN_USE (-1) 27 #define AXSYNC_ERROR_IN_CALLBACK (-2) 28 #define AXSYNC_ERROR_NOT_PROTECTED (-3) 29 #define AXSYNC_ERROR_TOO_MANY_PROTECTS (-4) 30 31 // CAFE Audio API version definitions 32 #define CAFE_AUDIO_API_VER_2_0 20 33 #define CAFE_AUDIO_API_VERSION CAFE_AUDIO_API_VER_2_0 34 /*--------------------------------------------------------------------------* 35 profiling 36 *--------------------------------------------------------------------------*/ 37 typedef struct _AXPROFILE 38 { 39 40 OSTime axFrameStart; 41 OSTime axFrameEnd; 42 OSTime userAuxProcStart; 43 OSTime userAuxProcEnd; 44 OSTime userCallbackStart; 45 OSTime userCallbackEnd; 46 OSTime userFinalMixStart; 47 OSTime userFinalMixEnd; 48 49 u32 axNumVoices; 50 u32 axNumDspVoices; 51 OSTime axDSPStart; 52 OSTime axDSPEnd; 53 OSTime axPPCStart; 54 OSTime axPPCEnd; 55 OSTime axPPCPostStart; 56 OSTime axPPCPostEnd; 57 58 59 OSTime istLatency; 60 OSTime istPostLatency; 61 } AXPROFILE; 62 63 /*---------------------------------------------------------------------------* 64 callback interface 65 *---------------------------------------------------------------------------*/ 66 typedef void (*AXUserCallback) (void); 67 typedef void (*AXAuxCallback) (void *data, void *context); 68 typedef struct _AXAUXCBSTRUCT 69 { 70 u32 numChs; // number of channels pointed by s32 **data in cb 71 u32 numSamples; // number of samples in each of the channels 72 } AXAUXCBSTRUCT; 73 typedef void (*AXUserAuxCallback) (s32 **data, void *context, AXAUXCBSTRUCT *info); 74 typedef void (*AXVoiceCallback) (void *p); 75 typedef void (*AXExceedCallback) (u32 cycles); 76 77 /*----------------------------------------------------------------------------------------- 78 // struct for the device final mix callback 79 // data ----> chBufPtrs[numChnsIn*numDevices] --> chBuf[i][j][numSamples]; 80 // (i=0:numChnsIn-1), (j=0:numDevices-1) 81 -----------------------------------------------------------------------------------------*/ 82 typedef struct _AX_FINAL_MIX_CB_STRUCT 83 { 84 s32 **data; // pointer to an array of pointers; each pointer points to 85 u16 numChnsIn; 86 u16 numSamples; 87 u16 numDevices; 88 u16 numChnsOut; // when AX invokes callback, numChnsOut = numChnsIn; 89 // callback can tell AX how many of outputs to pick from processed samples 90 } AX_FINAL_MIX_CB_STRUCT; 91 typedef void (*AXUserFinalMixCallback) (AX_FINAL_MIX_CB_STRUCT *info); 92 93 94 /*--------------------------------------------------------------------------* 95 volume envelope 96 *--------------------------------------------------------------------------*/ 97 typedef struct _AXPBVE 98 { 99 u16 currentVolume; 100 s16 currentDelta; 101 }AXPBVE; 102 #define AXPBVE_CURRENTVOLUME_OFF AXPBVE_OFF 103 #define AXPBVE_CURRENTDELTA_OFF (AXPBVE_OFF+1) 104 #define AXPBVE_SIZE 2 105 /**********************************************************/ 106 /* The following are the new API structure, definitions */ 107 /* etc */ 108 /**********************************************************/ 109 110 // basic element of the mix structure 111 // vol - the target volume 112 // delta - the ramp for value 113 typedef struct _AXPBCHVE 114 { 115 u16 vol; 116 s16 volDelta; 117 }AXPBCHVE; 118 119 // define the buses in this enum 120 typedef enum _AXPBBusType 121 { 122 AX_MAIN_BUS=0, 123 AX_MAX_NUM_RMT_BUSES, 124 AX_AUXA_BUS = 1, 125 AX_AUXB_BUS, 126 AX_AUXC_BUS, 127 AX_MAX_NUM_BUSES 128 } AXPBBusType; 129 130 // basic channel mix structures for buses 131 // each channel has mix gains for each of the buses 132 typedef struct _AXPBCHMIX 133 { 134 AXPBCHVE bus[AX_MAX_NUM_BUSES]; 135 } AXPBCHMIX ; 136 137 // enumerate the device types we support here 138 typedef enum { 139 AX_DEVICE_TV=0, 140 AX_DEVICE_DRC, 141 AX_DEVICE_RMT, 142 AX_MAX_NUM_DEVICES 143 } AXPBDeviceType; 144 145 // enumerate the remotes supported here 146 typedef enum{ 147 AX_RMT_ID0 = 0, 148 AX_RMT_ID1, 149 AX_RMT_ID2, 150 AX_RMT_ID3, 151 AX_MAX_NUM_RMTS 152 } AXPB_RMT_ID; 153 154 // enumerate the DRCs supported 155 typedef enum 156 { 157 AX_DRC_ID0=0, 158 AX_DRC_ID1, 159 AX_MAX_NUM_DRCS 160 } AXPB_DRC_ID; 161 162 // enumerate the channels here 163 typedef enum 164 { 165 AX_CH_LEFT=0, 166 AX_MAX_NUM_RMT_CHS, 167 AX_CH_RIGHT = AX_MAX_NUM_RMT_CHS, 168 AX_CH_SUR_LEFT, 169 AX_CH_SUR_RIGHT, 170 AX_MAX_NUM_DRC_CHS, 171 AX_CH_FC = AX_MAX_NUM_DRC_CHS, 172 AX_CH_LFE, 173 AX_MAX_NUM_TV_CHS 174 } AXPB_CH_ID; 175 176 // enumerate the tvs supported 177 typedef enum 178 { 179 AX_TV_ID0=0, 180 AX_MAX_NUM_TVS 181 } AXPB_TV_ID; 182 183 // enumerate the aux ids here 184 typedef enum 185 { 186 AX_AUX_ID_A=0, 187 AX_AUX_ID_B, 188 AX_AUX_ID_C, 189 AX_AUX_ID_MAX_NUM 190 } AXPB_AUX_ID; 191 192 193 // enumerate the error types here. 194 typedef enum{ 195 AXPB_ERROR_NONE=0, 196 AXPB_ERROR_DEVICE_TYPE=-1, 197 AXPB_ERROR_DEVICE_ID=-2, 198 AXPB_ERROR_NULL_MIX_PTR=-3, 199 AXPB_ERROR_NULL_VOICE_PTR=-4, 200 AXPB_ERROR_AUX_ID=-5, 201 AXPB_ERROR_ILLEGAL_COMPRESSOR_SETTINGS=-6, 202 AXPB_ERROR_REMIX_ILLEGAL_IN_CHANNELS=-7, 203 AXPB_ERROR_REMIX_ILLEGAL_OUT_CHANNELS=-8, 204 AXPB_ERRIR_REMIX_EXCEED_MAX_ALLOWED=-9, 205 AXPB_ERRIR_REMIX_MATRIX_UNINITIALIZED=-10, 206 AXPB_ERROR_FINAL_OUTSIZE = -11, 207 AXPB_ERROR_DRCVS_CONFIG = -12, 208 AXPB_ERROR_DRCVS_MODE = -13, 209 AXPB_ERROR_FRAMECB_TRY_AGAIN = -14, 210 AXPB_ERROR_FRAMECB_MAX_DEPTH_REACHED = -15, 211 AXPB_ERROR_FRAMECB_NOT_FOUND = -16, 212 AXPB_ERROR_FRAMECB_NULL_FUNC = -17, 213 AXPB_ERROR_VOICE_IS_RUNNING = -18, 214 AXPB_ERROR_INITIAL_TIME_DELAY_IS_TOO_BIG = -19, 215 AXPB_ERROR_MULTI_VOICE_COUNT_EXCEEDED = -20, 216 AXPB_ERROR_MULTI_VOICE_INVALID_CHANNEL_COUNT = -21, 217 AXPB_ERROR_MULTI_VOICE_UNABLE_TO_ALLOCATE_ALL_VOICES = -22, 218 AXPB_ERROR_MULTI_VOICE_INVALID_FORMAT = -23, 219 } AXPB_ERROR_CODE; 220 221 222 /*--------------------------------------------------------------------------* 223 buffer addressing 224 *--------------------------------------------------------------------------*/ 225 // bug 568: make samples const void * 226 // also moved to top of struct for other compatibility reasons 227 typedef struct _AXPBOFFSET { 228 u16 format; // AX_PB_FORMAT_ADPCM, AX_PB_FORMAT_PCM8, or AX_PB_FORMAT_PCM16 229 u16 loopFlag; 230 u32 loopOffset; // sample offsets into samples data 231 u32 endOffset; 232 u32 currentOffset; 233 const void *samples; // effective address of Sample Offset 0 234 } AXPBOFFSET; 235 236 #define AXPBADDR_LOOP_OFF 0 // States for loopFlag field 237 #define AXPBADDR_LOOP_ON 1 238 239 /*--------------------------------------------------------------------------* 240 ADPCM decoder state 241 *--------------------------------------------------------------------------*/ 242 typedef struct _AXPBADPCM 243 { 244 245 u16 a[8][2]; // coef table a1[0],a2[0],a1[1],a2[1].... 246 247 u16 gain; // gain to be applied (0 for ADPCM, 0x0800 for PCM16 and 0x0100 for PCM8) 248 249 u16 pred_scale; // predictor / scale combination (nibbles, as in hardware) 250 u16 yn1; // y[n - 1] 251 u16 yn2; // y[n - 2] 252 253 } AXPBADPCM; 254 255 #define AXPBADPCM_A1 AXPBADPCM_OFF 256 #define AXPBADPCM_A2 (AXPBADPCM_OFF+8) 257 #define AXPBADPCM_GAIN (AXPBADPCM_OFF+16 258 #define AXPBADPCM_PRED_SCALE (AXPBADPCM_OFF+17) 259 #define AXPBADPCM_YN1 (AXPBADPCM_OFF+18) 260 #define AXPBADPCM_YN2 (AXPBADPCM_OFF+19) 261 #define AXPBADPCM_SIZE 20 262 263 /*--------------------------------------------------------------------------* 264 sample rate converter state 265 *--------------------------------------------------------------------------*/ 266 typedef struct _AXPBSRC 267 { 268 269 u16 ratioHi; // sampling ratio, integer 270 u16 ratioLo; // sampling ratio, fraction 271 272 u16 currentAddressFrac; // current fractional sample position 273 274 u16 last_samples[4]; // last 4 input samples 275 276 } AXPBSRC; 277 278 #define AXPBSRC_RATIOHI_OFF AXPBSRC_OFF 279 #define AXPBSRC_RATIOLO_OFF (AXPBSRC_OFF+1) 280 #define AXPBSRC_CURRENTADDRESSFRAC_OFF (AXPBSRC_OFF+2) 281 #define AXPBSRC_LAST_SAMPLES_OFF (AXPBSRC_OFF+3) // 4 words 282 #define AXPBSRC_SIZE 7 283 284 /*--------------------------------------------------------------------------* 285 sample rate converter state for remote speakers 286 *--------------------------------------------------------------------------*/ 287 typedef struct _AXPBRMTSRC 288 { 289 290 u16 currentAddressFrac; // current fractional sample position 291 292 u16 last_samples[4]; // last 4 input samples 293 294 } AXPBRMTSRC; 295 296 #define AXPBRMTSRC_SIZE 5 297 298 /*--------------------------------------------------------------------------* 299 ADPCM loop parameters 300 *--------------------------------------------------------------------------*/ 301 typedef struct _AXPBADPCMLOOP 302 { 303 304 u16 loop_pred_scale; // predictor / scale combination (nibbles, as in hardware) 305 u16 loop_yn1; // y[n - 1] 306 u16 loop_yn2; // y[n - 2] 307 308 } AXPBADPCMLOOP; 309 310 #define AXPBADPCMLOOP_PRED_SCALE AXPBADPCMLOOP_OFF 311 #define AXPBADPCMLOOP_YN1 (AXPBADPCMLOOP_OFF+1) 312 #define AXPBADPCMLOOP_YN2 (AXPBADPCMLOOP_OFF+2) 313 #define AXPBADPCMLOOP_SIZE 3 314 315 /*--------------------------------------------------------------------------* 316 IIR filter parameters (low pass) 317 *--------------------------------------------------------------------------*/ 318 typedef struct _AXPBLPF 319 { 320 321 u16 on; 322 u16 yn1; 323 u16 a0; 324 u16 b0; 325 326 } AXPBLPF; 327 328 #define AXPBLPF_ON AXPBLPF_OFF 329 #define AXPBLPF_YN1 (AXPBLPF_OFF+1) 330 #define AXPBLPF_A0 (AXPBLPF_OFF+2) 331 #define AXPBLPF_B0 (AXPBLPF_OFF+3) 332 #define AXPBLPF_SIZE 4 333 334 /*--------------------------------------------------------------------------* 335 Biquad IIR filter parameters 336 *--------------------------------------------------------------------------*/ 337 typedef struct _AXPBBIQUAD 338 { 339 340 u16 on; 341 s16 xn1; 342 s16 xn2; 343 s16 yn1; 344 s16 yn2; 345 s16 b0; 346 s16 b1; 347 s16 b2; 348 s16 a1; 349 s16 a2; 350 351 } AXPBBIQUAD; 352 353 #define AXPBBIQUAD_ON AXPBBIQUAD_OFF 354 #define AXPBBIQUAD_XN1 (AXPBBIQUAD_OFF+1) 355 #define AXPBBIQUAD_XN2 (AXPBBIQUAD_OFF+2) 356 #define AXPBBIQUAD_YN1 (AXPBBIQUAD_OFF+3) 357 #define AXPBBIQUAD_YN2 (AXPBBIQUAD_OFF+4) 358 #define AXPBBIQUAD_B0 (AXPBBIQUAD_OFF+5) 359 #define AXPBBIQUAD_B1 (AXPBBIQUAD_OFF+6) 360 #define AXPBBIQUAD_B2 (AXPBBIQUAD_OFF+7) 361 #define AXPBBIQUAD_A1 (AXPBBIQUAD_OFF+8) 362 #define AXPBBIQUAD_A2 (AXPBBIQUAD_OFF+9) 363 #define AXPBBIQUAD_SIZE 10 364 365 /*--------------------------------------------------------------------------* 366 IIR filter for remote speakers 367 *--------------------------------------------------------------------------*/ 368 typedef union __AXPBRMTIIR 369 { 370 AXPBLPF lpf; 371 AXPBBIQUAD biquad; 372 373 } AXPBRMTIIR; 374 375 #define AXPBRMTIIR_SIZE 10 376 377 // state 378 #define AX_PB_STATE_STOP 0x0000 379 #define AX_PB_STATE_RUN 0x0001 380 381 // type 382 #define AX_PB_TYPE_NORMAL 0x0000 383 #define AX_PB_TYPE_STREAM 0x0001 // use only pred & scale. ignore histories. 384 385 // format 386 #define AX_PB_FORMAT_PCM16 0x000A // signed 16 bit PCM mono 387 #define AX_PB_FORMAT_PCM8 0x0019 // signed 8 bit PCM mono 388 #define AX_PB_FORMAT_ADPCM 0x0000 // ADPCM encoded (both standard & extended) 389 390 // src select 391 #define AX_PB_SRCSEL_POLYPHASE 0x0000 // N64 game console polyphase filter (4-tap) 392 #define AX_PB_SRCSEL_LINEAR 0x0001 // Linear interpolator 393 #define AX_PB_SRCSEL_NONE 0x0002 // No SRC (1:1) 394 395 // coef select 396 #define AX_PB_COEFSEL_8KHZ 0x0000 // 8KHz low pass response 397 #define AX_PB_COEFSEL_12KHZ 0x0001 // 12.8 KHz N64 game console response 398 #define AX_PB_COEFSEL_16KHZ 0x0002 // 16KHz response 399 400 // mixer control for main speakers 401 #define AX_PB_MIXCTRL_L 0x00000001 // main left mix 402 #define AX_PB_MIXCTRL_R 0x00000002 // main right mix 403 #define AX_PB_MIXCTRL_LR_RAMP 0x00000004 // main bus ramp (applies to LR only) 404 #define AX_PB_MIXCTRL_S 0x00000008 // main surround mix 405 #define AX_PB_MIXCTRL_S_RAMP 0x00000010 // main bus ramp (applies to S only) 406 407 #define AX_PB_MIXCTRL_A_L 0x00010000 // AuxA left mix 408 #define AX_PB_MIXCTRL_A_R 0x00020000 // AuxA right mix 409 #define AX_PB_MIXCTRL_A_LR_RAMP 0x00040000 // AuxA bus ramp (applies to LR only) 410 #define AX_PB_MIXCTRL_A_S 0x00080000 // AuxA surround mix 411 #define AX_PB_MIXCTRL_A_S_RAMP 0x00100000 // AuxA bus ramp (applies to S only) 412 413 #define AX_PB_MIXCTRL_B_L 0x00200000 // AuxB left mix 414 #define AX_PB_MIXCTRL_B_R 0x00400000 // AuxB right mix 415 #define AX_PB_MIXCTRL_B_LR_RAMP 0x00800000 // AuxB bus ramp (applies to LR only) 416 #define AX_PB_MIXCTRL_B_S 0x01000000 // AuxB surround mix 417 #define AX_PB_MIXCTRL_B_S_RAMP 0x02000000 // AuxB bus ramp (applies to S only) 418 419 #define AX_PB_MIXCTRL_C_L 0x04000000 // AuxCleft mix 420 #define AX_PB_MIXCTRL_C_R 0x08000000 // AuxC right mix 421 #define AX_PB_MIXCTRL_C_LR_RAMP 0x10000000 // AuxC bus ramp (applies to LR only) 422 #define AX_PB_MIXCTRL_C_S 0x20000000 // AuxC surround mix 423 #define AX_PB_MIXCTRL_C_S_RAMP 0x40000000 // AuxC bus ramp (applies to S only) 424 #define AX_PB_MIXCTRL_C_DPL2 0x80000000 // AuxC DPL2, does not apply ITD for surrounds 425 426 // Mixer Management (PPC or DSP) 427 428 #define AX_PB_RENDERER_SELECT_DSP 0 429 #define AX_PB_RENDERER_SELECT_PPC 1 430 #define AX_PB_RENDERER_SELECT_DSP_OR_PPC 2 431 #define AX_PB_MIXER_SELECT_DSP AX_PB_RENDERER_SELECT_DSP 432 #define AX_PB_MIXER_SELECT_PPC AX_PB_RENDERER_SELECT_PPC 433 434 435 #define AXMIX_DSP_ENABLE 1 436 #define AXMIX_PPC_ENABLE 2 437 438 // IIR filter switch 439 #define AX_PB_LPF_OFF 0x0000 // LPF switch 440 #define AX_PB_LPF_ON 0x0001 441 442 #define AX_PB_BIQUAD_OFF 0x0000 // Biquad IIR filter switch 443 #define AX_PB_BIQUAD_ON 0x0002 444 445 // output 446 #define AX_PB_REMOTE_OFF 0x0000 447 #define AX_PB_REMOTE_ON 0x0001 448 449 // mixer control for remote speakers 450 #define AX_PB_MIXCTRL_MAIN0 0x0001 // main0 mix 451 #define AX_PB_MIXCTRL_MAIN0_RAMP 0x0002 // main0 mix with ramp 452 #define AX_PB_MIXCTRL_AUX0 0x0004 // aux0 453 #define AX_PB_MIXCTRL_AUX0_RAMP 0x0008 // aux0 mix with ramp 454 #define AX_PB_MIXCTRL_MAIN1 0x0010 // main1 455 #define AX_PB_MIXCTRL_MAIN1_RAMP 0x0020 // main1 mix with ramp 456 #define AX_PB_MIXCTRL_AUX1 0x0040 // aux1 457 #define AX_PB_MIXCTRL_AUX1_RAMP 0x0080 // aux1 mix with ramp 458 #define AX_PB_MIXCTRL_MAIN2 0x0100 // main2 459 #define AX_PB_MIXCTRL_MAIN2_RAMP 0x0200 // main2 mix with ramp 460 #define AX_PB_MIXCTRL_AUX2 0x0400 // aux2 461 #define AX_PB_MIXCTRL_AUX2_RAMP 0x0800 // aux2 mix with ramp 462 #define AX_PB_MIXCTRL_MAIN3 0x1000 // main3 463 #define AX_PB_MIXCTRL_MAIN3_RAMP 0x2000 // main3 mix with ramp 464 #define AX_PB_MIXCTRL_AUX3 0x4000 // aux3 465 #define AX_PB_MIXCTRL_AUX3_RAMP 0x8000 // aux3 mix with ramp 466 467 /*---------------------------------------------------------------------------* 468 *---------------------------------------------------------------------------*/ 469 #define AX_DSP_CYCLES (OS_BUS_CLOCK / 667) 470 471 /*---------------------------------------------------------------------------* 472 *---------------------------------------------------------------------------*/ 473 #define AX_MAX_APP_FRAME_CBS 64 474 475 #define AX_MAX_VOICES 96 476 477 478 #define AX_MS_PER_FRAME 3 479 #define AX_IN_SAMPLES_PER_MS 32 480 #define AX_IN_SAMPLES_PER_SEC (AX_IN_SAMPLES_PER_MS * 1000) 481 #define AX_IN_SAMPLES_PER_FRAME (AX_IN_SAMPLES_PER_MS * AX_MS_PER_FRAME) 482 483 /*---------------------------------------------------------------------------* 484 *---------------------------------------------------------------------------*/ 485 #define AX_RMT_SAMPLES_PER_MS 6 486 #define AX_RMT_SAMPLES_PER_SEC (AX_RMT_SAMPLES_PER_MS * 1000) 487 #define AX_RMT_SAMPLES_PER_FRAME (AX_RMT_SAMPLES_PER_MS * AX_MS_PER_FRAME) 488 489 /*---------------------------------------------------------------------------* 490 *---------------------------------------------------------------------------*/ 491 #define AX_MODE_STEREO 0 492 #define AX_MODE_SURROUND 1 493 #define AX_MODE_DPL2 2 494 // placeholder def for now, will become =3 when all systems are ready for it 495 #define AX_MODE_6CHAN 3 496 497 #define AX_MODE_MONO 5 498 499 /*---------------------------------------------------------------------------* 500 *---------------------------------------------------------------------------*/ 501 #define AX_COMPRESSOR_OFF 0 502 #define AX_COMPRESSOR_ON 1 503 504 /*---------------------------------------------------------------------------* 505 *---------------------------------------------------------------------------*/ 506 #define AX_PRIORITY_STACKS 32 507 #define AX_PRIORITY_NODROP (AX_PRIORITY_STACKS - 1) 508 #define AX_PRIORITY_LOWEST 1 509 #define AX_PRIORITY_FREE 0 510 511 /*---------------------------------------------------------------------------* 512 *---------------------------------------------------------------------------*/ 513 #define AX_SRC_TYPE_NONE 0 514 #define AX_SRC_TYPE_LINEAR 1 515 #define AX_SRC_TYPE_4TAP_8K 2 516 #define AX_SRC_TYPE_4TAP_12K 3 517 #define AX_SRC_TYPE_4TAP_16K 4 518 519 // return codes from AXSetVoiceSrcRatio() 520 #define AX_SRC_RATIO_OK 0 521 #define AX_SRC_RATIO_TOO_SMALL -1 522 #define AX_SRC_RATIO_TOO_LARGE -2 523 524 /*---------------------------------------------------------------------------* 525 *---------------------------------------------------------------------------*/ 526 #define AX_ADDR_ONESHOT 0 527 #define AX_ADDR_LOOP 1 528 529 /*---------------------------------------------------------------------------* 530 *---------------------------------------------------------------------------*/ 531 #define AX_SYNC_NONEWPARAMS 0x00000000 532 #define AX_SYNC_USER_SRCSELECT 0x00000001 533 #define AX_SYNC_USER_MIXCTRL 0x00000002 534 #define AX_SYNC_USER_STATE 0x00000004 535 #define AX_SYNC_USER_TYPE 0x00000008 536 #define AX_SYNC_USER_MIX 0x00000010 537 #define AX_SYNC_USER_ITD 0x00000020 538 #define AX_SYNC_USER_ITDTARGET 0x00000040 539 #define AX_SYNC_USER_DPOP 0x00000080 540 #define AX_SYNC_USER_VE 0x00000100 541 #define AX_SYNC_USER_VEDELTA 0x00000200 542 #define AX_SYNC_USER_ADDR 0x00000400 543 #define AX_SYNC_USER_LOOP 0x00000800 544 #define AX_SYNC_USER_LOOPADDR 0x00001000 545 #define AX_SYNC_USER_ENDADDR 0x00002000 546 #define AX_SYNC_USER_CURRADDR 0x00004000 547 #define AX_SYNC_USER_ADPCM 0x00008000 548 #define AX_SYNC_USER_SRC 0x00010000 549 #define AX_SYNC_USER_SRCRATIO 0x00020000 550 #define AX_SYNC_USER_ADPCMLOOP 0x00040000 551 #define AX_SYNC_USER_LPF 0x00080000 552 #define AX_SYNC_USER_LPF_COEF 0x00100000 553 #define AX_SYNC_USER_BIQUAD 0x00200000 554 #define AX_SYNC_USER_BIQUAD_COEF 0x00400000 555 #define AX_SYNC_USER_REMOTE 0x00800000 556 #define AX_SYNC_USER_RMTMIXCTRL 0x01000000 557 #define AX_SYNC_USER_RMTMIX 0x02000000 558 #define AX_SYNC_USER_RMTDPOP 0x04000000 559 #define AX_SYNC_USER_RMTSRC 0x08000000 560 #define AX_SYNC_USER_RMTIIR 0x10000000 561 #define AX_SYNC_USER_RMTIIR_COEF1 0x20000000 562 #define AX_SYNC_USER_RMTIIR_COEF2 0x40000000 563 #define AX_SYNC_USER_DRCDPOP 0x80000000 564 565 #define AX_SYNC_USER_ALLPARAMS 0xffffffff 566 567 /*---------------------------------------------------------------------------* 568 *---------------------------------------------------------------------------*/ 569 #define AX_OUTPUT_BUFFER_DOUBLE 0 570 #define AX_OUTPUT_BUFFER_TRIPLE 1 571 572 /*---------------------------------------------------------------------------* 573 *---------------------------------------------------------------------------*/ 574 // new Drop Voice callback API for SDK 2.0.5+ 575 #define AXVCB_REASON_NO_RESOURCES 1 576 #define AXVCB_REASON_SEG_VIOLATION 2 577 578 typedef void (*AXVoiceCallbackEx)(void *p, u32 context, u32 reason); 579 580 /*---------------------------------------------------------------------------* 581 *---------------------------------------------------------------------------*/ 582 typedef struct _AXVPB 583 { 584 // useful user information 585 u32 index; // index of VPB in array 586 u32 state; // mirrored from the underlying state 587 u32 currentVolume; // mirrored from the underlying state 588 u32 mixerSelect; // DSP or PPC mixer for this voice 589 590 // stuff the user does not need and should never touch 591 592 // Voice stack linkages 593 void *next; // used in priority stacks 594 void *prev; // used in priority stacks 595 void *next1; // used in callback stack 596 597 // these ares are used in voice allocation 598 u32 priority; // index to stack 599 AXVoiceCallback callback; // user callback for specified voice (deprecated) 600 u32 userContext; // user assigned context for callback 601 602 // vars & flags for updating and sync PBs 603 u32 sync; // bit mask for each PB item to sync 604 u32 depop; // should depop voice 605 void *itdBuffer; // pointer to itd buffer 606 607 AXPBOFFSET offsets; // stash AXSetVoiceOffsets() settings here for AX reference 608 609 // new for 2.0.5 610 AXVoiceCallbackEx callbackex; // includes context and reason arguments 611 u32 cb_reason; // an AXVCB_REASON code 612 613 f32 dspLoadEstimate; 614 f32 ppcLoadEstimate; 615 } AXVPB; 616 617 /*---------------------------------------------------------------------------* 618 AX Multi-Voice Priority-Based 619 620 Keeps track of up to 6 AVBPB structures. The API is similar to the AXVPB 621 API except this API will act on up to 6 voices equivalently. 622 *---------------------------------------------------------------------------*/ 623 #define AX_MV_PB_MAX_VOICES 6 624 625 typedef struct _AXMVPB 626 { 627 BOOL active; 628 u32 count; // 1 to 6 629 AXVPB *voices[AX_MV_PB_MAX_VOICES]; // Array of AVVPBs 630 } AXMVPB; 631 632 /*---------------------------------------------------------------------------* 633 Header for DSPADPCM.exe header 634 *---------------------------------------------------------------------------*/ 635 typedef struct 636 { 637 u32 num_samples; // total number of RAW samples 638 u32 num_adpcm_nibbles; // number of ADPCM nibbles (including frame headers) 639 u32 sample_rate; // Sample rate, in Hz 640 u16 loop_flag; // 1=LOOPED, 0=NOT LOOPED 641 u16 format; // Always 0x0000, for ADPCM 642 u32 sa; // Start offset address for looped samples (zero for non-looped) 643 u32 ea; // End offset address for looped samples 644 u32 ca; // always offset of first sample (2 for ADPCM) 645 u16 coef[16]; // decode coefficients (eight pairs of 16-bit words) 646 u16 gain; // always zero for ADPCM 647 u16 ps; // predictor/scale 648 u16 yn1; // sample history 649 u16 yn2; // sample history 650 u16 lps; // predictor/scale for loop context 651 u16 lyn1; // sample history (n-1) for loop context 652 u16 lyn2; // sample history (n-2) for loop context 653 u16 multi_ch_count; // number of interleaved adpcm channels (1 through 6) or 0 for single channel 654 u16 block_frame_count; // Number of ADPCM frames (8 bytes per frame) in each interleaved channel block. Default is currently 1024 resulting in 8192 bytes per interleaved channel block. 655 u16 pad[9]; // reserved 656 } DSPADPCM; 657 658 /*---------------------------------------------------------------------------* 659 *---------------------------------------------------------------------------*/ 660 void AXInit (void); 661 BOOL AXIsInit (void); 662 void AXQuit (void); 663 664 u32 AXGetMaxVoices (void); 665 666 u16 AXGetMasterVolume (void); 667 void AXSetMasterVolume (u16 volume); 668 669 AXVPB* AXAcquireVoice ( 670 u32 priority, 671 AXVoiceCallback callback, 672 u32 userContext 673 ); 674 675 void AXFreeVoice (AXVPB *p); 676 void AXSetVoicePriority (AXVPB *p, u32 priority); 677 678 void AXSetVoiceSrcType (AXVPB *p, u32 type); 679 void AXSetVoiceState (AXVPB *p, u16 state); 680 void AXSetVoiceType (AXVPB *p, u16 type); 681 void AXSetVoiceVe (AXVPB *p, const AXPBVE *ve); 682 void AXSetVoiceVeDelta (AXVPB *p, s16 delta); 683 void AXSetVoiceLoop (AXVPB *p, u16 loop); 684 685 // Cafe -- new APIs 686 void AXSetVoiceOffsets (AXVPB *p, const AXPBOFFSET *addr); 687 void AXSetVoiceLoopOffset (AXVPB *p, u32 offset); 688 void AXSetVoiceEndOffset (AXVPB *p, u32 offset); 689 void AXSetVoiceCurrentOffset (AXVPB *p, u32 offset); 690 void AXGetVoiceOffsets (AXVPB *p, AXPBOFFSET *addr); 691 BOOL AXIsVoiceRunning (AXVPB *p); 692 BOOL AXIsAudioOutReady (void); 693 694 void AXSetVoiceSamplesAddr (AXVPB *p, const void *samples); 695 u32 AXGetVoiceLoopCount (AXVPB *p); 696 697 void AXSetVoiceAdpcm (AXVPB *p, const AXPBADPCM *adpcm); 698 void AXSetVoiceSrc (AXVPB *p, const AXPBSRC *src); 699 s32 AXSetVoiceSrcRatio (AXVPB *p, f32 ratio); 700 void AXSetVoiceAdpcmLoop (AXVPB *p, const AXPBADPCMLOOP *adpcmloop); 701 void AXSetVoiceLpf (AXVPB *p, const AXPBLPF *lpf); 702 void AXSetVoiceLpfCoefs (AXVPB *p, u16 a0, u16 b0); 703 void AXSetVoiceBiquad (AXVPB *p, const AXPBBIQUAD *biquad); 704 void AXSetVoiceBiquadCoefs (AXVPB *p, u16 b0, u16 b1, u16 b2, u16 a1, u16 a2); 705 706 void AXInitProfile (AXPROFILE *profile, u32 maxProfiles); 707 u32 AXGetProfile (void); 708 u32 AXGetSwapProfile (AXPROFILE *profile, u32 maxProfiles); 709 710 void AXSetStepMode (u32); 711 712 void AXComputeLpfCoefs (u16 freq, u16 *a0, u16 *b0); 713 714 void AXSetVoiceRmtOn (AXVPB *p, u16 on); 715 void AXSetVoiceRmtSrc (AXVPB *p, const AXPBRMTSRC *src); 716 void AXSetVoiceRmtIIR (AXVPB *p, const AXPBRMTIIR *iir); 717 void AXSetVoiceRmtIIRCoefs (AXVPB *p, u16 type, ...); 718 719 s32 AXRmtGetSamplesLeft (void); 720 s32 AXRmtGetSamples (s32 chan, s16* buffer, s32 samples); 721 s32 AXRmtAdvancePtr (s32 samples); 722 723 void AXRegisterExceedCallback (AXExceedCallback callback); 724 725 s32 AXGetAdpcmOutputSize (s32 samples); 726 s32 AXGetAdpcmWorkSize (s32 samples); 727 s32 AXGetAdpcmData (const s16* input, 728 s32 samples, 729 s32 rate, 730 s32 loop_start, 731 s32 loop_end, 732 u8* output, 733 DSPADPCM* info, 734 void* work); 735 s32 AXDecodeAdpcmData (const u8* input, 736 DSPADPCM* info, 737 s32 samples, 738 s16* output); 739 740 s32 AXUserBegin (void); 741 s32 AXUserEnd (void); 742 BOOL AXUserIsProtected (void); 743 s32 AXVoiceBegin (AXVPB *p); 744 s32 AXVoiceEnd (AXVPB *p); 745 BOOL AXVoiceIsProtected (AXVPB *p); 746 747 748 // still keeping the old mixer select functions 749 #define AXSetDefaultRenderer AXSetDefaultMixerSelect 750 #define AXGetDefaultRenderer AXGetDefaultMixerSelect 751 #define AXSetVoiceRenderer AXSetVoiceMixerSelect 752 #define AXGetVoiceRenderer AXGetVoiceMixerSelect 753 754 u32 AXSetDefaultRenderer (u32 mixerSelect); 755 u32 AXGetDefaultRenderer (void); 756 u32 AXSetVoiceRenderer (AXVPB *p, u32 mixerSelect); 757 u32 AXGetVoiceRenderer (AXVPB *p); 758 u32 __AXGetMixMode (void); 759 760 BOOL AXIsVoiceRunning(AXVPB *pvpb); 761 s16 AXGetVoiceVolume(AXVPB *pvpb); 762 763 /******************************************************/ 764 /******************************************************/ 765 766 /* 767 * All the new API prototypes 768 */ 769 770 771 AXPB_ERROR_CODE AXSetVoiceDeviceMix(AXVPB *voice, AXPBDeviceType device, u32 Id, AXPBCHMIX *mix); 772 // - AXPBDeviceType will specify for which device you are setting the mix 773 // - the mode set previously will dictate what the device channels are set to. 774 // - deviceId = 0 for TV, 0,1 for DRC, 0,1,2,3 for RMT ; gives finer control on the mixing 775 // - we could have enums and make sure deviceId is within bounds 776 // - mix is a pointer to array of AXPBCHMIx, number depending on the mode and device 777 // - one consistent interface for all the devices now and that may be added in future. 778 779 // new APIs 780 void AXSetMaxVoices(u32 num); 781 // does not change memory allocation, only the max number of voices usable 782 783 AXPB_ERROR_CODE AXSetDeviceMode(AXPBDeviceType device, u32 mode); 784 // sets the output mode for the device (stereo, dpl2, dpl?, 6ch) 785 786 AXPB_ERROR_CODE AXGetDeviceMode(AXPBDeviceType device, u32 *mode); 787 // gets the output mode for the device (stereo, dpl2, dpl?, 6ch) 788 789 AXPB_ERROR_CODE AXGetDeviceChannelCount(AXPBDeviceType device, u32 Id, u32 *count); 790 // gets the number of active channels for the device 791 792 AXUserCallback AXRegisterFrameCallback(AXUserCallback fcb); 793 // callback function to control AX per frame 794 795 AXPB_ERROR_CODE AXRegisterAppFrameCallback(AXUserCallback fcb); 796 // callback function to control AX per frame 797 AXPB_ERROR_CODE AXDeregisterAppFrameCallback(AXUserCallback fcb); 798 // callback function to control AX per frame 799 800 AXPB_ERROR_CODE AXRegisterAuxCallback(AXPBDeviceType device, u32 Id, u32 auxId, AXUserAuxCallback fcb, void *context); 801 // registers a callback for aux on a device, called once each frame 802 803 AXPB_ERROR_CODE AXGetAuxCallback(AXPBDeviceType device, u32 Id, u32 auxId, AXUserAuxCallback *fcb, void **context); 804 // gets the callback for aux on a device 805 806 AXPB_ERROR_CODE AXSetDeviceVolume(AXPBDeviceType device, u32 Id, u16 volume); 807 // sets the device volume 808 809 AXPB_ERROR_CODE AXGetDeviceVolume(AXPBDeviceType device, u32 Id, u16 *volume); 810 // gets the current volume of the device 811 812 AXPB_ERROR_CODE AXSetAuxReturnVolume(AXPBDeviceType device, u32 Id, u32 auxId, u16 volume); 813 // sets the return volume of the aux specified by auxId on the device 814 815 AXPB_ERROR_CODE AXGetAuxReturnVolume(AXPBDeviceType device, u32 Id, u32 auxId, u16 *volume); 816 // gets the return volume of the aux specified by auxId on the device 817 818 AXPB_ERROR_CODE AXSetDeviceCompressor(AXPBDeviceType device, u16 on_off); 819 // turns ON/OFF the compressor on a particular device 820 821 AXPB_ERROR_CODE AXSetDeviceCompressorTable(AXPBDeviceType device, u16* table, u16 frames); 822 // sets the tables for compressor to be used for this particular device 823 void AXMakeCompressorTable (f32 gain, u16 frames, u16* table); 824 // Function to create compressor table with user preferences 825 826 // new APIs for access to final mix 827 AXPB_ERROR_CODE AXRegisterDeviceFinalMixCallback(AXPBDeviceType device, AXUserFinalMixCallback fcb); 828 // sets the callback function to be called after the final mix of main and aux buses is done for this device 829 830 AXPB_ERROR_CODE AXGetDeviceFinalMixCallback(AXPBDeviceType device, AXUserFinalMixCallback *fcb); 831 // gets the callback function to be called after the final mix of main and aux buses is done for this device 832 833 AXPB_ERROR_CODE AXSetDeviceRemixMatrix(AXPBDeviceType device, u32 const numInChns, u32 const numOutChns, f32 const *matrixPtr); 834 // sets the matrix for remixing numInChns to numOutChns for the device 835 AXPB_ERROR_CODE AXGetDeviceRemixMatrix(AXPBDeviceType device, u32 const numInChns, u32 const numOutChns, f32 const **matrixPtr); 836 // gets the matrix for remixing numInChns to numOutChns for the device 837 838 AXPB_ERROR_CODE AXGetDeviceUpsampleStage(AXPBDeviceType device, BOOL *post); 839 // gets the current setting of upsample stage for the device 840 AXPB_ERROR_CODE AXSetDeviceUpsampleStage(AXPBDeviceType device, BOOL post); 841 // sets the current setting of upsample stage for the device 842 // 843 typedef struct { 844 u32 numChannels; 845 u32 sampFreq; 846 u32 numDevices; 847 u32 format; 848 u32 length; 849 }AXDEVICEFINALOUTPUTSTRUCT ; 850 // gets the final output samples for the device 851 AXPB_ERROR_CODE AXGetDeviceFinalOutput(AXPBDeviceType device, s16 *dataPtr, u32 const size, AXDEVICEFINALOUTPUTSTRUCT *axDeviceFinalOutputStruct); 852 853 AXPB_ERROR_CODE AXSetDeviceLinearUpsampler(AXPBDeviceType device, u32 deviceId, BOOL flag); 854 855 // Returns 0 for a segment violation, else nonzero. 856 AXVPB* AXAcquireVoiceEx ( 857 u32 priority, 858 AXVoiceCallbackEx callback, 859 u32 userContext 860 ); 861 862 863 /*--------------------------------------------------------------------------* 864 Multi Voice DB APIs 865 *--------------------------------------------------------------------------*/ 866 AXPB_ERROR_CODE AXAcquireMultiVoice (u32 priority, AXVoiceCallbackEx callback, u32 userContext, DSPADPCM *mdsp, AXMVPB **mvp); 867 void AXFreeMultiVoice (AXMVPB *mv); 868 void AXSetMultiVoicePriority (AXMVPB *mv, u32 priority); 869 870 void AXSetMultiVoiceSrcType (AXMVPB *mv, u32 type); 871 void AXSetMultiVoiceState (AXMVPB *mv, u16 state); 872 void AXSetMultiVoiceType (AXMVPB *mv, u16 type); 873 void AXSetMultiVoiceVe (AXMVPB *mv, const AXPBVE *ve); 874 void AXSetMultiVoiceVeDelta (AXMVPB *mv, s16 delta); 875 void AXSetMultiVoiceOffsets (AXMVPB *mv, AXPBOFFSET *offsets); 876 void AXSetMultiVoiceLoop (AXMVPB *mv, u16 loop); 877 void AXSetMultiVoiceAdpcm (AXMVPB *mv, DSPADPCM *data); 878 void AXSetMultiVoiceSrc (AXMVPB *mv, const AXPBSRC *src); 879 s32 AXSetMultiVoiceSrcRatio (AXMVPB *mv, f32 ratio); 880 void AXSetMultiVoiceAdpcmLoop (AXMVPB *mv, AXPBADPCMLOOP *loops); 881 void AXSetMultiVoiceLpf (AXMVPB *mv, const AXPBLPF *lpf); 882 void AXSetMultiVoiceLpfCoefs (AXMVPB *mv, u16 a0, u16 b0); 883 void AXSetMultiVoiceBiquad (AXMVPB *mv, const AXPBBIQUAD *biquad); 884 void AXSetMultiVoiceBiquadCoefs (AXMVPB *mv, u16 b0, u16 b1, u16 b2, u16 a1, u16 a2); 885 u32 AXSetMultiVoiceRenderer (AXMVPB *mv, u32 mixerSelect); 886 u32 AXGetMultiVoiceRenderer (AXMVPB *mv); 887 void AXSetMultiVoiceLoopOffset (AXMVPB *mv, u32 offset); 888 void AXSetMultiVoiceEndOffset (AXMVPB *mv, u32 offset); 889 void AXSetMultiVoiceCurrentOffset(AXMVPB *mv, u32 offset); 890 void AXGetMultiVoiceOffsets (AXMVPB *mv, AXPBOFFSET *addr); 891 BOOL AXIsMultiVoiceRunning (AXMVPB *mv); 892 893 AXPB_ERROR_CODE AXSetMultiVoiceDeviceMix (AXMVPB *mv, AXPBDeviceType device, u32 Id, AXPBBusType bus, u16 vol, s16 volDelta); 894 895 AXPB_ERROR_CODE AXGetMultiVoiceReformatBufferSize (u32 format, u32 num_chans, u32 num_bytes, u32 *size); 896 897 898 899 900 /******************************************************/ 901 /******************************************************/ 902 903 u32 AXCheckVoiceOffsets(const AXPBOFFSET *maddr); 904 905 // Get/set DSP voice allocation limit 906 // set nonzero to override load calculations as reason to shed 907 u32 AXGetMaxDspVoices(void); 908 void AXSetMaxDspVoices(u32 max_voices); 909 910 // set load calculating shed thresholds 911 // DSP Load Limit controls when to shed to PPC Renderer 912 // or drop if the voice is pinned to DSP but cannot be allocated 913 // range is 0.0% to 100.0% (but allow margin for jitter!) 914 void AXSetDspLoadLimit(f32 limit); 915 f32 AXGetDspLoadLimit(void); 916 // PPC Load Limit controls when to drop the voice 917 void AXSetPpcLoadLimit(f32 limit); 918 f32 AXGetPpcLoadLimit(void); 919 920 // Check current frame load computations and allocations 921 // call in User Frame Callback only 922 f32 AXGetPpcLoad(void); 923 f32 AXGetDspLoad(void); 924 u32 AXGetNumVoices(void); 925 u32 AXGetNumDspVoices(void); 926 u32 AXGetDroppedVoiceCount(void); 927 928 // Virtualization functions for DRC 929 typedef enum { 930 AX_DRC_VS_OFF = 0, 931 AX_DRC_VS_ON_NORMAL, 932 AX_DRC_VS_ON_FRONT_BYPASS 933 } AXDRCVSModeType; 934 935 typedef enum 936 { 937 AX_DRC_VS_OUTPUT_SPEAKER = 0, 938 AX_DRC_VS_OUTPUT_HEADPHONE, 939 AX_DRC_VS_OUTPUT_NUM 940 } AXDRCVSOutputMode; 941 typedef enum 942 { 943 AX_DRC_VS_SPEAKER_POS_WIDE = 0, 944 AX_DRC_VS_SPEAKER_POS_SQUARE, 945 AX_DRC_VS_SPEAKER_POS_NUM 946 } AXDRCVSSpeakerPosition; 947 948 typedef enum 949 { 950 AX_DRC_VS_SLEV_1_0 = 0, 951 AX_DRC_VS_SLEV_0_707, 952 AX_DRC_VS_SLEV_0_5, 953 AX_DRC_VS_SLEV_NUM 954 } AXDRCVSSurroundLevelGain; 955 956 typedef enum 957 { 958 AX_DRC_VS_LC_NOT_USE = 0, 959 AX_DRC_VS_LC_USE, 960 AX_DRC_VS_LC_USE_MAX, 961 AX_DRC_VS_LC_NUM 962 } AXDRCVSLCMode; 963 964 AXPB_ERROR_CODE AXSetDRCVSMode(AXDRCVSModeType mode); 965 AXPB_ERROR_CODE AXGetDRCVSMode(AXDRCVSModeType *mode); 966 AXPB_ERROR_CODE AXSetDRCVSLC(AXDRCVSLCMode mode); 967 AXPB_ERROR_CODE AXSetDRCVSSpeakerPosition(AXDRCVSOutputMode output, AXDRCVSSpeakerPosition pos); 968 AXPB_ERROR_CODE AXSetDRCVSSurroundDepth(AXDRCVSOutputMode output, f32 depth); 969 AXPB_ERROR_CODE AXSetDRCVSDownmixBalance(AXDRCVSOutputMode output, f32 balance); 970 AXPB_ERROR_CODE AXSetDRCVSSurroundLevelGain(AXDRCVSSurroundLevelGain gain); 971 AXPB_ERROR_CODE AXSetDRCVSOutputGain(AXDRCVSOutputMode output, f32 gain); 972 AXPB_ERROR_CODE AXSetDRCVSLimiter(BOOL enable); 973 AXPB_ERROR_CODE AXSetDRCVSLimiterThreshold(f32 level); 974 975 /************************************************************************ 976 * UNUSED STRUCTURES AND ENUMS * 977 ************************************************************************/ 978 // AXSetMode() 979 // definitions compatible with original definitions in ax.h 980 // 981 typedef enum { 982 AX_MODE_STEREO_32K=0, 983 AX_MODE_SURROUND_32K, 984 AX_MODE_4CHAN_32K, 985 AX_MODE_6CHAN_32K, 986 AX_MODE_STEREO_48K, 987 AX_MODE_SURROUND_48K, 988 AX_MODE_4CHAN_48K, 989 AX_MODE_6CHAN_48K, 990 AX_TV_MAX_MODES 991 } AXPBTvModeType; 992 993 typedef enum { 994 // AXSetDrcMode() 995 // DRC mode definitions 996 AX_DRC_MODE_MONO=0, 997 AX_DRC_MODE_STEREO, 998 AX_DRC_MODE_DUAL_MONO, 999 AX_DRC_MODE_DUAL_STEREO, 1000 AX_DRC_MAX_MODES 1001 } AXPBDrcModeType; 1002 1003 /************************************************************************ 1004 * DEPRECATED SECTION: DO NOT USE THESE IF YOU ARE WRITING NEW CODE * 1005 * USE THE REPLACEMENT FUNCTIONS & STRUCTS PROVIDED. CHECK MAN PAGES * 1006 ************************************************************************/ 1007 /*----------------------------------------------------------------------* 1008 *----------------------------------------------------------------------*/ 1009 //aliases for enum 1010 #define AXPBMIXMOV AXPBDRCMIX 1011 #define AXPBDPOPMOV AXPBDRCDPOP 1012 1013 //aliases for API 1014 #define AXRegisterMovCallback AXRegisterDRCCallback 1015 #define AXGetMasterMOVVolume AXGetMasterDRCVolume 1016 #define AXSetMasterMOVVolume AXSetMasterDRCVolume 1017 #define AXRegisterAuxMOVCallback AXRegisterAuxDRCCallback 1018 #define AXGetAuxMOVCallback AXGetAuxDRCCallback 1019 #define AXGetMOVAuxReturnVolume AXGetDRCAuxReturnVolume 1020 #define AXSetMOVAuxReturnVolume AXSetDRCAuxReturnVolume 1021 #define AXSetVoiceMOVMix AXSetVoiceDRCMix 1022 #define AXSetVoiceMOVDpop AXSetVoiceDRCDpop 1023 1024 /************************************************************** 1025 DSP Re-write To Be Deprecated Public AX Voice Data Definitions 1026 *************************************************************/ 1027 // bug 581 - use signed deltas 1028 typedef struct _AXPBMIX 1029 { 1030 // mixing values in .15, 0x8000 = ca. 1.0 1031 1032 u16 vL; 1033 s16 vDeltaL; 1034 u16 vR; 1035 s16 vDeltaR; 1036 1037 u16 vAuxAL; 1038 s16 vDeltaAuxAL; 1039 u16 vAuxAR; 1040 s16 vDeltaAuxAR; 1041 1042 u16 vAuxBL; 1043 s16 vDeltaAuxBL; 1044 u16 vAuxBR; 1045 s16 vDeltaAuxBR; 1046 1047 u16 vAuxCL; 1048 s16 vDeltaAuxCL; 1049 u16 vAuxCR; 1050 s16 vDeltaAuxCR; 1051 1052 u16 vS; 1053 s16 vDeltaS; 1054 u16 vAuxAS; 1055 s16 vDeltaAuxAS; 1056 u16 vAuxBS; 1057 s16 vDeltaAuxBS; 1058 u16 vAuxCS; 1059 s16 vDeltaAuxCS; 1060 1061 } AXPBMIX; 1062 1063 typedef struct _AXPBDRCMIX 1064 { 1065 // mixing values in .15, 0x8000 = ca. 1.0 1066 1067 u16 vL; 1068 s16 vDeltaL; 1069 u16 vR; 1070 s16 vDeltaR; 1071 1072 u16 vAuxL; 1073 s16 vDeltaAuxL; 1074 u16 vAuxR; 1075 s16 vDeltaAuxR; 1076 1077 u16 vS; 1078 s16 vDeltaS; 1079 u16 vAuxS; 1080 s16 vDeltaAuxS; 1081 1082 } AXPBDRCMIX; 1083 1084 #define AXPBMIX_VL_OFF AXPBMIX_OFF 1085 #define AXPBMIX_VDELTAL_OFF (AXPBMIX_OFF+1) 1086 #define AXPBMIX_VR_OFF (AXPBMIX_OFF+2) 1087 #define AXPBMIX_VDELTAR_OFF (AXPBMIX_OFF+3) 1088 1089 #define AXPBMIX_VAUXAL_OFF (AXPBMIX_OFF+4) 1090 #define AXPBMIX_VDELTAAUXAL_OFF (AXPBMIX_OFF+5) 1091 #define AXPBMIX_VAUXAR_OFF (AXPBMIX_OFF+6) 1092 #define AXPBMIX_VDELTAAUXAR_OFF (AXPBMIX_OFF+7) 1093 1094 #define AXPBMIX_VAUXBL_OFF (AXPBMIX_OFF+8) 1095 #define AXPBMIX_VDELTAAUXBL_OFF (AXPBMIX_OFF+9) 1096 #define AXPBMIX_VAUXBR_OFF (AXPBMIX_OFF+10) 1097 #define AXPBMIX_VDELTAAUXBR_OFF (AXPBMIX_OFF+11) 1098 1099 #define AXPBMIX_VAUXCL_OFF (AXPBMIX_OFF+12) 1100 #define AXPBMIX_VDELTAAUXCL_OFF (AXPBMIX_OFF+13) 1101 #define AXPBMIX_VAUXCR_OFF (AXPBMIX_OFF+14) 1102 #define AXPBMIX_VDELTAAUXCR_OFF (AXPBMIX_OFF+15) 1103 1104 #define AXPBMIX_VS_OFF (AXPBMIX_OFF+16) 1105 #define AXPBMIX_VDELTAS_OFF (AXPBMIX_OFF+17) 1106 #define AXPBMIX_VAUXAS_OFF (AXPBMIX_OFF+18) 1107 #define AXPBMIX_VDELTAAUXAS_OFF (AXPBMIX_OFF+19) 1108 #define AXPBMIX_VAUXBS_OFF (AXPBMIX_OFF+20) 1109 #define AXPBMIX_VDELTAAUXBS_OFF (AXPBMIX_OFF+21) 1110 #define AXPBMIX_VAUXCS_OFF (AXPBMIX_OFF+22) 1111 #define AXPBMIX_VDELTAAUXCS_OFF (AXPBMIX_OFF+23) 1112 1113 #define AXPBMIX_SIZE 24 1114 1115 // mixer control for DRC speakers 1116 #define AX_PB_MIXCTRL_DL 0x00000020 // DRC left mix 1117 #define AX_PB_MIXCTRL_DR 0x00000040 // DRC right mix 1118 #define AX_PB_MIXCTRL_DLR_RAMP 0x00000080 // DRC bus ramp (applies to LR only) 1119 #define AX_PB_MIXCTRL_DS 0x00000100 // DRC surround mix 1120 #define AX_PB_MIXCTRL_DS_RAMP 0x00000200 // DRC bus ramp (applies to S only) 1121 1122 #define AX_PB_MIXCTRL_DA_L 0x00000400 // DRC Aux left mix 1123 #define AX_PB_MIXCTRL_DA_R 0x00000800 // DRC Aux rigth mix 1124 #define AX_PB_MIXCTRL_DA_LR_RAMP 0x00001000 // DRC Aux bus ramp (applies to LR only) 1125 #define AX_PB_MIXCTRL_DA_S 0x00002000 // DRC Aux surround mix 1126 #define AX_PB_MIXCTRL_DA_S_RAMP 0x00004000 // DRC Aux bus ramp (applies to S only) 1127 1128 #define AX_PB_MOV_MIX_ALL AX_PB_DRC_MIX_ALL 1129 #define AX_PB_DRC_MIX_ALL 0x00007fe0 1130 1131 1132 /****************************************************************** 1133 End DSP Re-write To Be Deprecated Public AX Voice Data Definitions 1134 ******************************************************************/ 1135 /*--------------------------------------------------------------------------* 1136 mixing for remote speaker 1137 *--------------------------------------------------------------------------*/ 1138 typedef struct _AXPBRMTMIX 1139 { 1140 1141 u16 vMain0; 1142 s16 vDeltaMain0; 1143 u16 vAux0; 1144 s16 vDeltaAux0; 1145 1146 u16 vMain1; 1147 s16 vDeltaMain1; 1148 u16 vAux1; 1149 s16 vDeltaAux1; 1150 1151 u16 vMain2; 1152 s16 vDeltaMain2; 1153 u16 vAux2; 1154 s16 vDeltaAux2; 1155 1156 u16 vMain3; 1157 s16 vDeltaMain3; 1158 u16 vAux3; 1159 s16 vDeltaAux3; 1160 1161 } AXPBRMTMIX; 1162 1163 #define AXPBRMTMIX_SIZE 16 1164 1165 /*--------------------------------------------------------------------------* 1166 initial time delay 1167 *--------------------------------------------------------------------------*/ 1168 typedef struct _AXPBITD 1169 { 1170 1171 u16 flag; // on or off for this voice 1172 u16 bufferHi; // MRAM buffer 1173 u16 bufferLo; // 1174 u16 shiftL; // phase shift samples left (current) 1175 u16 shiftR; // phase shift samples right (current) 1176 u16 targetShiftL; // phase shift samples left (target) 1177 u16 targetShiftR; // phase shift samples right (target) 1178 1179 } AXPBITD; 1180 1181 // flag 1182 #define AX_PB_ITD_OFF 0x0000 1183 #define AX_PB_ITD_ON 0x0001 1184 1185 #define AXPBITD_FLAG_OFF AXPBITD_OFF 1186 #define AXPBITD_BUFFERHI_OFF (AXPBITD_OFF+1) 1187 #define AXPBITD_BUFFERLO_OFF (AXPBITD_OFF+2) 1188 #define AXPBITD_SHIFTL_OFF (AXPBITD_OFF+3) 1189 #define AXPBITD_SHIFTR_OFF (AXPBITD_OFF+4) 1190 #define AXPBITD_TARGETSHIFTL_OFF (AXPBITD_OFF+5) 1191 #define AXPBITD_TARGETSHIFTR_OFF (AXPBITD_OFF+6) 1192 #define AXPBITD_SIZE 7 1193 1194 typedef struct _AXPBITDBUFFER 1195 { 1196 1197 s16 data[32]; 1198 1199 } AXPBITDBUFFER; 1200 1201 /*--------------------------------------------------------------------------* 1202 depop data (last amplitudes mixed into buffers) 1203 *--------------------------------------------------------------------------*/ 1204 typedef struct _AXPBDPOP 1205 { 1206 1207 s16 aL; 1208 s16 aAuxAL; 1209 s16 aAuxBL; 1210 s16 aAuxCL; 1211 1212 s16 aR; 1213 s16 aAuxAR; 1214 s16 aAuxBR; 1215 s16 aAuxCR; 1216 1217 s16 aS; 1218 s16 aAuxAS; 1219 s16 aAuxBS; 1220 s16 aAuxCS; 1221 1222 } AXPBDPOP; 1223 1224 typedef struct _AXPBDRCDPOP 1225 { 1226 1227 s16 aL; 1228 s16 aAuxL; 1229 1230 s16 aR; 1231 s16 aAuxR; 1232 1233 s16 aS; 1234 s16 aAuxS; 1235 1236 } AXPBDRCDPOP; 1237 1238 #define AXPBDPOP_AL_OFF AXPBDPOP_OFF 1239 #define AXPBDPOP_AAUXAL_OFF (AXPBDPOP_OFF+1) 1240 #define AXPBDPOP_AAUXBL_OFF (AXPBDPOP_OFF+2) 1241 #define AXPBDPOP_AAUXCL_OFF (AXPBDPOP_OFF+3) 1242 1243 #define AXPBDPOP_AR_OFF (AXPBDPOP_OFF+4) 1244 #define AXPBDPOP_AAUXAR_OFF (AXPBDPOP_OFF+5) 1245 #define AXPBDPOP_AAUXBR_OFF (AXPBDPOP_OFF+6) 1246 #define AXPBDPOP_AAUXCR_OFF (AXPBDPOP_OFF+7) 1247 1248 #define AXPBDPOP_AS_OFF (AXPBDPOP_OFF+8) 1249 #define AXPBDPOP_AAUXAS_OFF (AXPBDPOP_OFF+9) 1250 #define AXPBDPOP_AAUXBS_OFF (AXPBDPOP_OFF+10) 1251 #define AXPBDPOP_AAUXCS_OFF (AXPBDPOP_OFF+11) 1252 1253 #define AXPBDPOP_SIZE 12 1254 1255 /*--------------------------------------------------------------------------* 1256 depop data for remote speakers 1257 *--------------------------------------------------------------------------*/ 1258 typedef struct _AXPBRMTDPOP 1259 { 1260 1261 s16 aMain0; 1262 s16 aMain1; 1263 s16 aMain2; 1264 s16 aMain3; 1265 1266 s16 aAux0; 1267 s16 aAux1; 1268 s16 aAux2; 1269 s16 aAux3; 1270 1271 } AXPBRMTDPOP; 1272 1273 #define AXPBRMTDPOP_SIZE 8 1274 1275 #define AXGetMemorySize(num) ((sizeof(AXPBITDBUFFER) + sizeof(AXVPB)) * num) 1276 1277 void AXInitEx (u32 outputBufferMode); // deprecated 1278 void AXInitSpecifyMem (u32 num, void* mem); 1279 void AXInitExSpecifyMem (u32 num, void* mem, u32 outputBufferMode); 1280 AXUserCallback AXRegisterCallback (AXUserCallback callback); 1281 1282 AXUserCallback AXRegisterDRCCallback(AXUserCallback callback); 1283 void AXSetMode (u32 mode); 1284 u32 AXGetMode (void); 1285 1286 void AXSetMaxDspCycles (u32 cycles); 1287 u32 AXGetMaxDspCycles (void); 1288 u32 AXGetDspCycles (void); 1289 1290 void AXRegisterAuxACallback (AXAuxCallback callback, void *context); 1291 void AXRegisterAuxBCallback (AXAuxCallback callback, void *context); 1292 void AXRegisterAuxCCallback (AXAuxCallback callback, void *context); 1293 1294 void AXGetAuxACallback (AXAuxCallback *callback, void **context); 1295 void AXGetAuxBCallback (AXAuxCallback *callback, void **context); 1296 void AXGetAuxCCallback (AXAuxCallback *callback, void **context); 1297 1298 u16 AXGetAuxAReturnVolume (void); 1299 u16 AXGetAuxBReturnVolume (void); 1300 u16 AXGetAuxCReturnVolume (void); 1301 void AXSetAuxAReturnVolume (u16 volume); 1302 void AXSetAuxBReturnVolume (u16 volume); 1303 void AXSetAuxCReturnVolume (u16 volume); 1304 1305 void AXSetVoiceMix (AXVPB *p, const AXPBMIX *mix); 1306 void AXSetVoiceItdOn (AXVPB *p); 1307 void AXSetVoiceItdTarget (AXVPB *p, u16 lShift, u16 rShift); 1308 1309 void AXPrepareEfxData (const void *samples, u32 size); 1310 1311 // deprecating these 1312 void AXGetVoiceOffsetsEx (AXVPB *p, AXPBOFFSET *addr, const void *samples); 1313 void AXSetVoiceOffsetsEx (AXVPB *p, const AXPBOFFSET *addr, const void *samples); 1314 void AXSetVoiceLoopOffsetEx (AXVPB *p, u32 offset, const void *samples); 1315 void AXSetVoiceEndOffsetEx (AXVPB *p, u32 offset, const void *samples); 1316 void AXSetVoiceCurrentOffsetEx (AXVPB *p, u32 offset, const void *samples); 1317 u32 AXGetVoiceCurrentOffsetEx (AXVPB *p, const void *samples); 1318 // 1319 u16 AXGetMasterDRCVolume (void); 1320 void AXSetMasterDRCVolume (u16 volume); 1321 1322 void AXRegisterAuxDRCCallback (AXAuxCallback callback, void *context); 1323 void AXGetAuxDRCCallback (AXAuxCallback *callback, void **context); 1324 1325 u16 AXGetDRCAuxReturnVolume (void); 1326 void AXSetDRCAuxReturnVolume (u16 volume); 1327 1328 void AXSetVoiceDRCMix (AXVPB *p, const AXPBDRCMIX *mix); 1329 void AXSetVoiceRmtMix (AXVPB *p, const AXPBRMTMIX *mix); 1330 1331 /*---------------------------------------------------------------------------* 1332 Sound 2 1333 *---------------------------------------------------------------------------*/ 1334 #define AX_TOTAL_NUM_OF_CHUNKS 1 1335 1336 #define AX_SAMPLES_PER_AUDIO_FRAME_48 144 1337 1338 /* AX Initialization related enumerated types */ 1339 typedef enum { 1340 AX_32K_RENDERER = 0, 1341 AX_48K_RENDERER = 1 1342 } AX_RENDERER_FREQ_ENUM; 1343 1344 typedef enum { 1345 AX_3MS_FRAME = 0 1346 } AX_FRAMESIZE_ENUM; 1347 1348 typedef enum { 1349 AX_SINGLE_PIPELINE_STAGE = 0, 1350 AX_FOUR_PIPELINE_STAGE = 1 1351 } AX_PIPELINE_STAGES_ENUM; 1352 1353 typedef struct { 1354 AX_RENDERER_FREQ_ENUM rendererFreq; 1355 AX_FRAMESIZE_ENUM frameSize; 1356 AX_PIPELINE_STAGES_ENUM pipelineStages; // <-- this is replacing the latency. 1357 }AXINITPARAMS; 1358 1359 typedef enum { 1360 AXINIT_OK = 0, 1361 AXINIT_ALREADY_INITIALIZED = -1, 1362 AXINIT_INVALID_RENDERER = -2, 1363 AXINIT_INVALID_FRAMESIZE = -3, 1364 AXINIT_INVALID_PIPELINE_STAGE = -4 1365 } AXINIT_ERROR_CODE; 1366 1367 1368 AXINIT_ERROR_CODE AXInitWithParams (AXINITPARAMS *initParams); 1369 void AXGetCurrentParams (AXINITPARAMS *currentParams); 1370 AX_RENDERER_FREQ_ENUM AXGetRendererFreq (void); 1371 u32 AXGetInputSamplesPerFrame (void); 1372 u32 AXGetInputSamplesPerSec (void); 1373 u32 AXGetLibraryVersion (void); 1374 AXPB_ERROR_CODE AXSetVoiceInitialTimeDelay (AXVPB *p, u16 timeDelay); 1375 1376 #ifdef __cplusplus 1377 } 1378 #endif 1379 1380 #endif // __AX_H__ 1381