1 /*---------------------------------------------------------------------------* 2 Project: Mixer application for AX 3 File: mix.h 4 5 Copyright (C)1998-2011 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 __MIX_H__ 16 #define __MIX_H__ 17 18 #include <cafe/ax.h> 19 // #include <cafe/sc.h> 20 // ***TBD*** temporarily copy the bits needed from sc.h here 21 // sc functionality yet to be implemented 22 #define SC_SOUND_MODE_MONO 0u 23 #define SC_SOUND_MODE_STEREO 1u 24 #define SC_SOUND_MODE_SURROUND 2u 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 /*---------------------------------------------------------------------------* 30 MOV aliases for enum 31 *---------------------------------------------------------------------------*/ 32 #define movFader drcFader 33 #define movPan drcPan 34 #define movAux drcAux 35 36 #define MIXMOVInitChannel MIXDRCInitChannel 37 #define MIXMOVAuxPostFader MIXDRCAuxPostFader 38 #define MIXMOVAuxPreFader MIXDRCAuxPreFader 39 #define MIXMOVAuxIsPostFader MIXDRCAuxIsPostFader 40 #define MIXMOVSetAux MIXDRCSetAux 41 #define MIXMOVAdjustAux MIXDRCAdjustAux 42 #define MIXMOVGetAux MIXDRCGetAux 43 #define MIXMOVSetPan MIXDRCSetPan 44 #define MIXMOVSetSPan MIXDRCSetSPan 45 #define MIXMOVAdjustPan MIXDRCAdjustPan 46 #define MIXMOVGetPan MIXDRCGetPan 47 #define MIXMOVSetFader MIXDRCSetFader 48 #define MIXMOVAdjustFader MIXDRCAdjustFader 49 #define MIXMOVGetFader MIXDRCGetFader 50 51 52 /*---------------------------------------------------------------------------* 53 mixer sound mode definitions 54 *---------------------------------------------------------------------------*/ 55 #define MIX_SOUND_MODE_MONO SC_SOUND_MODE_MONO 56 #define MIX_SOUND_MODE_STEREO SC_SOUND_MODE_STEREO 57 #define MIX_SOUND_MODE_SURROUND SC_SOUND_MODE_SURROUND 58 #define MIX_SOUND_MODE_DPL2 3 59 #define MIX_SOUND_MODE_6CHAN 4 60 61 /*---------------------------------------------------------------------------* 62 mixer channel mode definitions 63 *---------------------------------------------------------------------------*/ 64 #define MIX_MODE_AUXA_PREFADER 0x00000001 65 #define MIX_MODE_AUXB_PREFADER 0x00000002 66 #define MIX_MODE_AUXC_PREFADER 0x00000004 67 #define MIX_MODE_MUTE 0x00000008 68 #define MIX_MODE_MOV_PREFADER MIX_MODE_DRC_PREFADER 69 #define MIX_MODE_DRC_PREFADER 0x00000010 70 71 #define MIX_MODE_UPDATE_INPUT 0x10000000 72 #define MIX_MODE_UPDATE_INPUT1 0x20000000 73 #define MIX_MODE_UPDATE_TARGET_INPUT MIX_MODE_UPDATE_INPUT1 74 #define MIX_MODE_UPDATE_MIX 0x40000000 75 #define MIX_MODE_UPDATE_MIX1 0x80000000 76 #define MIX_MODE_UPDATE_TARGET_MIX MIX_MODE_UPDATE_MIX1 77 78 /*---------------------------------------------------------------------------* 79 mixer channel mode definitions for remote speakers 80 *---------------------------------------------------------------------------*/ 81 #define MIX_MODE_AUX0_PREFADER 0x00000001 82 #define MIX_MODE_AUX1_PREFADER 0x00000002 83 #define MIX_MODE_AUX2_PREFADER 0x00000004 84 #define MIX_MODE_AUX3_PREFADER 0x00000008 85 86 /*---------------------------------------------------------------------------* 87 *---------------------------------------------------------------------------*/ 88 89 typedef struct MIXRmtChannel 90 { 91 u32 mode; 92 93 int fader0; 94 int fader1; 95 int fader2; 96 int fader3; 97 98 int aux0; 99 int aux1; 100 int aux2; 101 int aux3; 102 103 u16 vMain0; 104 u16 vMain0_1; 105 u16 vAux0; 106 u16 vAux0_1; 107 108 u16 vMain1; 109 u16 vMain1_1; 110 u16 vAux1; 111 u16 vAux1_1; 112 113 u16 vMain2; 114 u16 vMain2_1; 115 u16 vAux2; 116 u16 vAux2_1; 117 118 u16 vMain3; 119 u16 vMain3_1; 120 u16 vAux3; 121 u16 vAux3_1; 122 123 } MIXRmtChannel; 124 125 126 /*---------------------------------------------------------------------------* 127 Exposed function prototypes 128 *---------------------------------------------------------------------------*/ 129 130 void MIXInit (void); 131 void MIXInitSpecifyMem (void* mem); 132 void MIXQuit (void); 133 void MIXSetSoundMode (u32 mode); 134 u32 MIXGetSoundMode (void); 135 136 #define MIXGetMemorySize(num) ((sizeof(MIXChannel) + sizeof(MIXRmtChannel)) * num) 137 138 void MIXInitChannel ( 139 AXVPB *p, // pointer to voice 140 u32 mode, // initial aux A, B, mute modes 141 int input, // initial input atten / gain 142 int auxA, // initial aux A atten / gain 143 int auxB, // initial aux B atten / gain 144 int auxC, // initial aux C atten / gain 145 int pan, // initial pan 146 int span, // initial span 147 int fader // initial fader atten / gain 148 ); 149 150 void MIXReleaseChannel (AXVPB *p); 151 152 void MIXResetControls (AXVPB *p); 153 154 void MIXSetInput (AXVPB *p, int dB); 155 void MIXAdjustInput (AXVPB *p, int dB); 156 int MIXGetInput (AXVPB *p); 157 158 void MIXAuxAPostFader (AXVPB *p); 159 void MIXAuxAPreFader (AXVPB *p); 160 BOOL MIXAuxAIsPostFader (AXVPB *p); 161 void MIXSetAuxA (AXVPB *p, int dB); 162 void MIXAdjustAuxA (AXVPB *p, int dB); 163 int MIXGetAuxA (AXVPB *p); 164 165 void MIXAuxBPostFader (AXVPB *p); 166 void MIXAuxBPreFader (AXVPB *p); 167 BOOL MIXAuxBIsPostFader (AXVPB *p); 168 void MIXSetAuxB (AXVPB *p, int dB); 169 void MIXAdjustAuxB (AXVPB *p, int dB); 170 int MIXGetAuxB (AXVPB *p); 171 172 void MIXAuxCPostFader (AXVPB *p); 173 void MIXAuxCPreFader (AXVPB *p); 174 BOOL MIXAuxCIsPostFader (AXVPB *p); 175 void MIXSetAuxC (AXVPB *p, int dB); 176 void MIXAdjustAuxC (AXVPB *p, int dB); 177 int MIXGetAuxC (AXVPB *p); 178 179 void MIXSetPan (AXVPB *p, int pan); 180 void MIXAdjustPan (AXVPB *p, int pan); 181 int MIXGetPan (AXVPB *p); 182 183 void MIXSetSPan (AXVPB *p, int span); 184 void MIXAdjustSPan (AXVPB *p, int span); 185 int MIXGetSPan (AXVPB *p); 186 187 void MIXMute (AXVPB *p); 188 void MIXUnMute (AXVPB *p); 189 BOOL MIXIsMute (AXVPB *p); 190 191 void MIXSetFader (AXVPB *p, int dB); 192 void MIXAdjustFader (AXVPB *p, int dB); 193 int MIXGetFader (AXVPB *p); 194 195 // Deprecated 196 void MIXDRCInitChannel ( 197 AXVPB *p, // pointer to voice 198 u32 mode, // initial aux mode 199 int aux, // initial aux atten / gain 200 int pan, // initial pan 201 int fader // initial fader atten / gain 202 ); 203 204 void MIXDRCInitVoice (AXVPB *p, // pointer to voice 205 u32 id, // device id 206 u32 mode, // initial aux mode 207 int aux, // initial aux atten / gain 208 int pan, // initial pan 209 int span, // initial span 210 int fader); // initial fader atten / gain 211 212 void MIXDRCAuxPostFader (AXVPB *p); 213 void MIXDRCAuxPreFader (AXVPB *p); 214 BOOL MIXDRCAuxIsPostFader (AXVPB *p); 215 void MIXDRCSetAux (AXVPB *p, int dB); 216 void MIXDRCAdjustAux (AXVPB *p, int dB); 217 int MIXDRCGetAux (AXVPB *p); 218 219 void MIXDRCSetPan (AXVPB *p, int pan); 220 void MIXDRCAdjustPan (AXVPB *p, int pan); 221 int MIXDRCGetPan (AXVPB *p); 222 223 void MIXDRCSetFader (AXVPB *p, int dB); 224 void MIXDRCAdjustFader (AXVPB *p, int dB); 225 int MIXDRCGetFader (AXVPB *p); 226 227 void MIXDRCSetSPan (AXVPB *p, int span); 228 void MIXDRCAdjustSPan (AXVPB *p, int span); 229 int MIXDRCGetSPan (AXVPB *p); 230 231 void MIXUpdateSettings (void); 232 233 void MIXRmtSetVolumes ( 234 AXVPB *axvpb, // pointer to voice 235 u32 mode, // aux0,1,2,3 modes 236 int fader0, // initial fader0 atten / gain 237 int fader1, // initial fader1 atten / gain 238 int fader2, // initial fader2 atten / gain 239 int fader3, // initial fader3 atten / gain 240 int aux0, // initial aux0 atten / gain 241 int aux1, // initial aux1 atten / gain 242 int aux2, // initial aux2 atten / gain 243 int aux3 // initial aux3 atten / gain 244 ); 245 246 void MIXRmtAuxPostFader (AXVPB *p, int num); 247 void MIXRmtAuxPreFader (AXVPB *p, int num); 248 BOOL MIXRmtAuxIsPostFader(AXVPB *p, int num); 249 250 void MIXRmtSetAux (AXVPB *p, int num, int dB); 251 void MIXRmtAdjustAux (AXVPB *p, int num, int dB); 252 int MIXRmtGetAux (AXVPB *p, int num); 253 254 void MIXRmtSetFader (AXVPB *p, int num, int dB); 255 void MIXRmtAdjustFader (AXVPB *p, int num, int dB); 256 int MIXRmtGetFader (AXVPB *p, int num); 257 258 259 260 /* 261 * NEW APIs to go with the new AX APIs. The library is getting expanded to 262 * handle multiple devices and multiple channels 263 */ 264 typedef struct { 265 u16 curVol; 266 u16 targetVol; 267 }MIXCHVOLSTRUCT; 268 269 typedef struct { 270 s16 aux[AX_AUX_ID_MAX_NUM]; // aux send values in 0.1dB 271 s16 pan; 272 s16 span; 273 s16 fader; 274 s16 lfe; 275 }MIXCntrlStruct; 276 277 // each device TV, DRC, RMT can be in a different mode 278 typedef struct _MIXChannel 279 { 280 // pos16er to the voice assigned to this channel 281 AXVPB *axvpb; 282 283 u32 mixUpdate; 284 s16 inputLevel; 285 286 MIXCHVOLSTRUCT inpVol; 287 //define the individual settings for channels 288 // MixCntr, individual channels, input levels, volume holders for 289 // all channels and buses 290 MIXCntrlStruct tvMixCntrl[AX_MAX_NUM_TVS]; 291 s16 tvChns[AX_MAX_NUM_TVS][AX_MAX_NUM_TV_CHS]; 292 MIXCHVOLSTRUCT tvChVol[AX_MAX_NUM_TVS][AX_MAX_NUM_BUSES][AX_MAX_NUM_TV_CHS]; 293 u32 tvMode[AX_MAX_NUM_TVS]; 294 295 296 // define input level for individual devices types.. 297 MIXCHVOLSTRUCT drcChVol[AX_MAX_NUM_DRCS][AX_MAX_NUM_BUSES][AX_MAX_NUM_DRC_CHS]; 298 MIXCntrlStruct drcMixCntrl[AX_MAX_NUM_DRCS]; 299 s16 drcChns[AX_MAX_NUM_DRCS][AX_MAX_NUM_DRC_CHS]; 300 u32 drcMode[AX_MAX_NUM_DRCS]; 301 302 // define input level for individual devices types.. 303 MIXCHVOLSTRUCT rmtChVol[AX_MAX_NUM_RMTS][AX_MAX_NUM_BUSES][AX_MAX_NUM_RMT_CHS]; 304 MIXCntrlStruct rmtMixCntrl[AX_MAX_NUM_RMTS]; 305 s16 rmtChns[AX_MAX_NUM_RMTS][AX_MAX_NUM_RMT_CHS]; 306 u32 rmtMode[AX_MAX_NUM_RMTS]; 307 308 } MIXChannel; 309 310 311 // new APIs 312 // Init function to initialize a voice to a channel 313 // Initialize a mixer channel to a particular device 314 void MIXAssignChannel(AXVPB *p); 315 void MIXInitDeviceControl(AXVPB *p, AXPBDeviceType device, u32 Id, MIXCntrlStruct *mcPtr, u32 mode); 316 void MIXResetDeviceControl(AXVPB *p, AXPBDeviceType device, u32 Id); 317 void MIXResetAllDeviceControls(AXVPB *p); 318 319 void MIXDeviceAuxPostFader(AXVPB *p, AXPBDeviceType device, u32 Id, u32 auxId); 320 void MIXDeviceAuxPreFader(AXVPB *p, AXPBDeviceType device, u32 Id, u32 auxId); 321 BOOL MIXDeviceAuxIsPostFader(AXVPB *p, AXPBDeviceType device, u32 Id, u32 auxId); 322 323 void MIXSetDeviceAux(AXVPB *p, AXPBDeviceType device, u32 Id, u32 auxId, s16 dB); 324 void MIXAdjustDeviceAux(AXVPB *p, AXPBDeviceType device, u32 Id, u32 auxId, s16 dB); 325 s16 MIXGetDeviceAux(AXVPB *p, AXPBDeviceType device, u32 Id, u32 auxId); 326 327 void MIXSetDevicePan(AXVPB *p, AXPBDeviceType device, u32 Id, s16 pan); 328 void MIXAdjustDevicePan(AXVPB *p, AXPBDeviceType device, u32 Id, s16 pan); 329 s16 MIXGetDevicePan(AXVPB *p, AXPBDeviceType device, u32 Id); 330 331 void MIXSetDeviceSPan(AXVPB *p, AXPBDeviceType device, u32 Id, s16 span); 332 void MIXAdjustDeviceSPan(AXVPB *p, AXPBDeviceType device, u32 Id, s16 span); 333 s16 MIXGetDeviceSPan(AXVPB *p, AXPBDeviceType device, u32 Id); 334 335 void MIXSetDeviceFader(AXVPB *p, AXPBDeviceType device, u32 Id, s16 fader); 336 void MIXAdjustDeviceFader(AXVPB *p, AXPBDeviceType device, u32 Id, s16 fader); 337 s16 MIXGetDeviceFader(AXVPB *p, AXPBDeviceType device, u32 Id); 338 339 void MIXSetDeviceLFE(AXVPB *p, AXPBDeviceType device, u32 Id, s16 lfe); 340 void MIXAdjustDeviceLFE(AXVPB *p, AXPBDeviceType device, u32 Id, s16 lfe); 341 s16 MIXGetDeviceLFE(AXVPB *p, AXPBDeviceType device, u32 Id); 342 343 void MIXSetDeviceSoundMode(AXPBDeviceType device, u32 mode); 344 u32 MIXGetDeviceSoundMode(AXPBDeviceType device); 345 346 void MIXInitInputControl(AXVPB *voice, s16 input, u32 mode); 347 348 #ifdef __cplusplus 349 } 350 #endif 351 352 #endif // __MIX_H__ 353