1 /*---------------------------------------------------------------------------* 2 Project: Revolution AXART library 3 File: axart.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: axart.h,v $ 14 Revision 1.7 2007/09/07 05:55:35 aka 15 Added AXARTRemoveArticulator(). 16 17 Revision 1.6 2006/10/16 11:21:41 aka 18 Added 3 articulators for remote speakers. 19 Added AXARTInitArtRmt(). 20 Added AXARTInitArtRmtFader(). 21 Added AXARTInitArtRmtAuxVolume(). 22 23 Revision 1.5 2006/09/29 05:55:44 aka 24 Added AXART_FADER. 25 Added AXARTInitArtFader(). 26 27 Revision 1.4 2006/02/09 04:44:57 aka 28 Changed copyright. 29 30 Revision 1.3 2006/02/04 13:05:46 hashida 31 (none) 32 33 Revision 1.2 2005/11/07 06:47:11 aka 34 Changed for Revolution's audio spec. 35 36 Revision 1.1.1.1 2005/05/12 02:41:06 yasuh-to 37 Imported from Dolphin tree. 38 39 7 02/08/21 6:38p Akagi 40 - Set #pragma warn_padding off around the AXART_3D{} definition. 41 - Set #pragma warn_padding off around the AXART_PANNING{} definition. 42 - Set #pragma warn_padding off around the AXART_SRCTYPE{} definition. 43 44 6 8/15/02 11:03a Billyjack 45 added low pass filter articulator 46 47 5 4/11/02 1:58p Billyjack 48 - added IIR articulator, code commented out 49 50 4 1/08/02 6:40p Billyjack 51 - Added AXARTInitSound() 52 53 3 9/26/01 3:44p Billyjack 54 extern'd lfo samples for ANSI C compatibility 55 56 2 8/20/01 6:15p Billyjack 57 added comments 58 59 1 8/15/01 1:11p Billyjack 60 created 61 62 $NoKeywords: $ 63 *---------------------------------------------------------------------------*/ 64 65 #include <revolution.h> 66 67 #ifndef __AXART_H__ 68 #define __AXART_H__ 69 70 #ifdef __cplusplus 71 extern "C" { 72 #endif 73 74 75 /*---------------------------------------------------------------------------* 76 AXART_ART generic articulator header 77 *---------------------------------------------------------------------------*/ 78 typedef struct 79 { 80 81 void *next; 82 u32 type; 83 84 } AXART_ART; 85 86 // articulator types 87 #define AXART_TYPE_3D 1 88 #define AXART_TYPE_PANNING 2 89 #define AXART_TYPE_ITD 3 90 #define AXART_TYPE_SRCTYPE 4 91 #define AXART_TYPE_PITCH 5 92 #define AXART_TYPE_PITCH_ENV 6 93 #define AXART_TYPE_PITCH_MOD 7 94 #define AXART_TYPE_VOLUME 8 95 #define AXART_TYPE_AUXA_VOLUME 9 96 #define AXART_TYPE_AUXB_VOLUME 10 97 #define AXART_TYPE_AUXC_VOLUME 11 98 #define AXART_TYPE_VOLUME_ENV 12 99 #define AXART_TYPE_AUXA_VOLUME_ENV 13 100 #define AXART_TYPE_AUXB_VOLUME_ENV 14 101 #define AXART_TYPE_AUXC_VOLUME_ENV 15 102 #define AXART_TYPE_VOLUME_MOD 16 103 #define AXART_TYPE_AUXA_VOLUME_MOD 17 104 #define AXART_TYPE_AUXB_VOLUME_MOD 18 105 #define AXART_TYPE_AUXC_VOLUME_MOD 19 106 #define AXART_TYPE_LPF 20 107 #define AXART_TYPE_FADER 21 108 #define AXART_TYPE_RMT 22 109 #define AXART_TYPE_RMT_FADER 24 110 #define AXART_TYPE_RMT_AUX_VOLUME 25 111 112 113 /*---------------------------------------------------------------------------* 114 LFO used with modulation articulators 115 *---------------------------------------------------------------------------*/ 116 typedef struct 117 { 118 119 f32 *lfo; // lfo samples in RAM 120 u32 length; // lfo samples for 1 period 121 f32 delta; // lfo delta per 5ms 122 123 u32 sampleIndex; // lfo sample index 124 f32 counter; // lfo counter 125 f32 sample1; // lfo last sample for interpolation 126 f32 sample; // lfo sample 127 f32 output; // lfo output 128 129 } AXART_LFO; 130 131 #define AXART_SINE_SAMPLES 64 132 #define AXART_SQUARE_SAMPLES 64 133 #define AXART_SAW_SAMPLES 64 134 #define AXART_REVERSESAW_SAMPLES 64 135 #define AXART_TRIANGLE_SAMPLES 64 136 #define AXART_NOISE_SAMPLES 64 137 138 extern f32 AXARTSine[AXART_SINE_SAMPLES]; 139 extern f32 AXARTSquare[AXART_SQUARE_SAMPLES]; 140 extern f32 AXARTSaw[AXART_SAW_SAMPLES]; 141 extern f32 AXARTReverseSaw[AXART_REVERSESAW_SAMPLES]; 142 extern f32 AXARTTriangle[AXART_TRIANGLE_SAMPLES]; 143 extern f32 AXARTNoise[AXART_NOISE_SAMPLES]; 144 145 146 /*---------------------------------------------------------------------------* 147 articulators 148 *---------------------------------------------------------------------------*/ 149 150 #ifdef __MWERKS__ 151 #pragma warn_padding off 152 #endif 153 154 typedef struct 155 { 156 AXART_ART art; 157 158 // runtime user params 159 160 f32 hAngle; // horzontal angle 161 f32 vAngle; // vertical angle 162 f32 dist; // distance from listener 163 f32 closingSpeed; // for doppler 164 u32 update; // set to true after changing params 165 166 // do not write to these params 167 168 u8 pan; 169 u8 span; 170 u8 src; 171 u16 itdL; 172 u16 itdR; 173 f32 pitch; 174 s32 attenuation; 175 176 } AXART_3D; 177 178 typedef struct 179 { 180 AXART_ART art; 181 182 // runtime user params 183 184 u8 pan; // left - right 0 - 127, 64 is center 185 u8 span; // rear - front 0 - 127, 127 is front 186 187 } AXART_PANNING; 188 189 typedef struct 190 { 191 192 AXART_ART art; 193 194 // runtime user params 195 196 u8 src; // use one of the following 197 // AX_SRC_TYPE_NONE 198 // AX_SRC_TYPE_LINEAR 199 // AX_SRC_TYPE_4TAP_8K 200 // AX_SRC_TYPE_4TAP_12K 201 // AX_SRC_TYPE_4TAP_16K 202 203 } AXART_SRCTYPE; 204 205 #ifdef __MWERKS__ 206 #pragma warn_padding reset 207 #endif 208 209 typedef struct 210 { 211 AXART_ART art; 212 213 // runtime user params 214 215 u16 itdL; // sample shift left, 0 - 31 216 u16 itdR; // sample shift right, 0 - 31 217 218 } AXART_ITD; 219 220 typedef struct 221 { 222 AXART_ART art; 223 224 // runtime user params 225 226 s32 cents; 227 228 } AXART_PITCH; 229 230 typedef struct 231 { 232 AXART_ART art; 233 234 // runtime user params 235 236 s32 delta; 237 s32 target; 238 s32 cents; 239 240 } AXART_PITCH_ENV; 241 242 typedef struct 243 { 244 AXART_ART art; 245 AXART_LFO lfo; 246 247 // runtime user params 248 249 s32 cents; 250 251 } AXART_PITCH_MOD; 252 253 typedef struct 254 { 255 AXART_ART art; 256 257 // runtime user params 258 259 s32 attenuation; 260 261 } AXART_VOLUME; 262 263 typedef struct 264 { 265 AXART_ART art; 266 267 // runtime user params 268 269 s32 attenuation; 270 271 } AXART_AUXA_VOLUME; 272 273 typedef struct 274 { 275 AXART_ART art; 276 277 // runtime user params 278 279 s32 attenuation; 280 281 } AXART_AUXB_VOLUME; 282 283 typedef struct 284 { 285 AXART_ART art; 286 287 // runtime user params 288 289 s32 attenuation; 290 291 } AXART_AUXC_VOLUME; 292 293 typedef struct 294 { 295 AXART_ART art; 296 297 // runtime user params 298 299 s32 delta; 300 s32 target; 301 s32 attenuation; 302 303 } AXART_VOLUME_ENV; 304 305 typedef struct 306 { 307 AXART_ART art; 308 309 // runtime user params 310 311 s32 delta; 312 s32 target; 313 s32 attenuation; 314 315 } AXART_AUXA_VOLUME_ENV; 316 317 typedef struct 318 { 319 AXART_ART art; 320 321 // runtime user params 322 323 s32 delta; 324 s32 target; 325 s32 attenuation; 326 327 } AXART_AUXB_VOLUME_ENV; 328 329 typedef struct 330 { 331 AXART_ART art; 332 333 // runtime user params 334 335 s32 delta; 336 s32 target; 337 s32 attenuation; 338 339 } AXART_AUXC_VOLUME_ENV; 340 341 typedef struct 342 { 343 AXART_ART art; 344 AXART_LFO lfo; 345 346 // runtime user params 347 348 s32 attenuation; 349 350 } AXART_VOLUME_MOD; 351 352 typedef struct 353 { 354 AXART_ART art; 355 AXART_LFO lfo; 356 357 // runtime user params 358 359 s32 attenuation; 360 361 } AXART_AUXA_VOLUME_MOD; 362 363 typedef struct 364 { 365 AXART_ART art; 366 AXART_LFO lfo; 367 368 // runtime user params 369 370 s32 attenuation; 371 372 } AXART_AUXB_VOLUME_MOD; 373 374 typedef struct 375 { 376 AXART_ART art; 377 AXART_LFO lfo; 378 379 // runtime user params 380 381 s32 attenuation; 382 383 } AXART_AUXC_VOLUME_MOD; 384 385 typedef struct 386 { 387 AXART_ART art; 388 u32 initLPF; 389 390 // runtime user params 391 u32 frequency; // indexed roll off frequency, see below 392 u32 update; // set to TRUE after changing type or frequency 393 394 } AXART_LPF; 395 396 #define AXART_LPF_FREQ_16000_HZ 0 397 #define AXART_LPF_FREQ_12800_HZ 1 398 #define AXART_LPF_FREQ_10240_HZ 2 399 #define AXART_LPF_FREQ_8000_HZ 3 400 #define AXART_LPF_FREQ_6400_HZ 4 401 #define AXART_LPF_FREQ_5120_HZ 5 402 #define AXART_LPF_FREQ_4000_HZ 6 403 #define AXART_LPF_FREQ_3200_HZ 7 404 #define AXART_LPF_FREQ_2560_HZ 8 405 #define AXART_LPF_FREQ_2000_HZ 9 406 #define AXART_LPF_FREQ_1600_HZ 10 407 #define AXART_LPF_FREQ_1280_HZ 11 408 #define AXART_LPF_FREQ_1000_HZ 12 409 #define AXART_LPF_FREQ_800_HZ 13 410 #define AXART_LPF_FREQ_640_HZ 14 411 #define AXART_LPF_FREQ_500_HZ 15 412 #define AXART_LPF_FREQ_400_HZ 16 413 #define AXART_LPF_FREQ_320_HZ 17 414 #define AXART_LPF_FREQ_256_HZ 18 415 #define AXART_LPF_FREQ_200_HZ 19 416 #define AXART_LPF_FREQ_160_HZ 20 417 #define AXART_LPF_FREQ_128_HZ 21 418 #define AXART_LPF_FREQ_100_HZ 22 419 #define AXART_LPF_FREQ_80_HZ 23 420 421 typedef struct 422 { 423 AXART_ART art; 424 425 // runtime user params 426 427 s32 attenuation; 428 429 } AXART_FADER; 430 431 432 /*---------------------------------------------------------------------------* 433 articulators for remote speakers 434 *---------------------------------------------------------------------------*/ 435 436 // enable/disable flag of remote outputs 437 typedef struct 438 { 439 AXART_ART art; 440 441 // runtime user params 442 443 u16 on; 444 445 } AXART_RMT; 446 447 // fader value 448 typedef struct 449 { 450 AXART_ART art; 451 452 // runtime user params 453 454 s32 attenuation0; 455 s32 attenuation1; 456 s32 attenuation2; 457 s32 attenuation3; 458 459 } AXART_RMT_FADER; 460 461 // aux send level 462 typedef struct 463 { 464 AXART_ART art; 465 466 // runtime user params 467 468 s32 attenuation0; 469 s32 attenuation1; 470 s32 attenuation2; 471 s32 attenuation3; 472 473 } AXART_RMT_AUX_VOLUME; 474 475 476 /*---------------------------------------------------------------------------* 477 AXART_SOUND struct used per sound in sound list to articulate 478 *---------------------------------------------------------------------------*/ 479 typedef struct 480 { 481 482 void *next; // next sound in list 483 void *prev; // prev sound in list 484 485 AXVPB *axvpb; // user acquired voice 486 f32 sampleRate; // normal sample rate 487 488 AXART_ART *articulators; // list of articulators 489 490 } AXART_SOUND; 491 492 493 /*---------------------------------------------------------------------------* 494 function prototypes 495 *---------------------------------------------------------------------------*/ 496 497 void AXARTInit (void); 498 void AXARTQuit (void); 499 void AXARTServiceSounds (void); 500 void AXARTInitSound (AXART_SOUND *sound, AXVPB *voice, u32 sampleRate); 501 void AXARTAddSound (AXART_SOUND *sound); 502 void AXARTRemoveSound (AXART_SOUND *sound); 503 void AXARTSet3DDistanceScale (f32 scale); 504 void AXARTSet3DDopplerScale (f32 scale); 505 void AXARTAddArticulator (AXART_SOUND *sound, AXART_ART *articulator); 506 BOOL AXARTRemoveArticulator (AXART_SOUND *sound, AXART_ART *articulator); 507 508 void AXARTInitLfo (AXART_LFO *lfo, f32 *samples, u32 length, f32 delta); 509 510 void AXARTInitArt3D (AXART_3D *articulator); 511 void AXARTInitArtPanning (AXART_PANNING *articulator); 512 void AXARTInitArtItd (AXART_ITD *articulator); 513 void AXARTInitArtSrctype (AXART_SRCTYPE *articulator); 514 515 void AXARTInitArtPitch (AXART_PITCH *articulator); 516 void AXARTInitArtPitchEnv (AXART_PITCH_ENV *articulator); 517 void AXARTInitArtPitchMod (AXART_PITCH_MOD *articulator); 518 519 void AXARTInitArtVolume (AXART_VOLUME *articulator); 520 void AXARTInitArtAuxAVolume (AXART_AUXA_VOLUME *articulator); 521 void AXARTInitArtAuxBVolume (AXART_AUXB_VOLUME *articulator); 522 void AXARTInitArtAuxCVolume (AXART_AUXC_VOLUME *articulator); 523 524 void AXARTInitArtVolumeEnv (AXART_VOLUME_ENV *articulator); 525 void AXARTInitArtAuxAVolumeEnv (AXART_AUXA_VOLUME_ENV *articulator); 526 void AXARTInitArtAuxBVolumeEnv (AXART_AUXB_VOLUME_ENV *articulator); 527 void AXARTInitArtAuxCVolumeEnv (AXART_AUXC_VOLUME_ENV *articulator); 528 529 void AXARTInitArtVolumeMod (AXART_VOLUME_MOD *articulator); 530 void AXARTInitArtAuxAVolumeMod (AXART_AUXA_VOLUME_MOD *articulator); 531 void AXARTInitArtAuxBVolumeMod (AXART_AUXB_VOLUME_MOD *articulator); 532 void AXARTInitArtAuxCVolumeMod (AXART_AUXC_VOLUME_MOD *articulator); 533 534 void AXARTInitArtLpf (AXART_LPF *articulator); 535 void AXARTInitArtFader (AXART_FADER *articulator); 536 537 void AXARTInitArtRmt (AXART_RMT *articulator); 538 void AXARTInitArtRmtFader (AXART_RMT_FADER *articulator); 539 void AXARTInitArtRmtAuxVolume (AXART_RMT_AUX_VOLUME *articulator); 540 541 542 #ifdef __cplusplus 543 } 544 #endif 545 546 #endif // __AXART_H__ 547