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