1 /*---------------------------------------------------------------------------*
2   Project:  Mixer application for AX
3   File:     mix.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: mix.h,v $
14   Revision 1.11  2006/10/26 02:01:22  aka
15   Changed from OS_SOUND_MODE _ to SC_SOUND_MODE_.
16 
17   Revision 1.10  2006/10/23 01:51:13  aka
18   Rolled-back MIXInit().
19   Added MIXInitSpecifyMem().
20 
21   Revision 1.9  2006/10/10 04:53:47  aka
22   Removed MIXSetMemory().
23   Revised MIXInit().
24 
25   Revision 1.8  2006/10/06 08:04:14  aka
26   Added MIXGetMemorySize().
27   Added MIXSetMemory().
28 
29   Revision 1.7  2006/07/24 10:34:56  aka
30   Removed unused definitions.
31 
32   Revision 1.6  2006/07/24 10:14:45  aka
33   Removed test functions.
34 
35   Revision 1.5  2006/07/24 09:14:17  aka
36   Changed in ration to modification of AX lib.
37 
38   Revision 1.4  2006/07/19 07:50:33  aka
39   Modified to support controller speakers.
40 
41   Revision 1.3  2006/02/09 04:47:54  aka
42   Changed copyright.
43 
44   Revision 1.2  2005/11/07 06:47:18  aka
45   Changed for Revolution's audio spec.
46 
47   Revision 1.1.1.1  2005/05/12 02:41:06  yasuh-to
48   Imported from Dolphin tree.
49 
50     3     1/08/02 6:42p Billyjack
51     - Added DPL2 support
52 
53     2     5/30/01 3:09p Billyjack
54     added definitions for MIXSetSoundMode modes (stereo / mono)
55 
56     1     5/09/01 1:28p Billyjack
57     created
58 
59   $NoKeywords: $
60  *---------------------------------------------------------------------------*/
61 
62 #ifndef __MIX_H__
63 #define __MIX_H__
64 
65 #include <revolution/sc.h>
66 
67 #ifdef __cplusplus
68 extern "C" {
69 #endif
70 
71 
72 /*---------------------------------------------------------------------------*
73     mixer sound mode definitions
74  *---------------------------------------------------------------------------*/
75 #define MIX_SOUND_MODE_MONO         SC_SOUND_MODE_MONO
76 #define MIX_SOUND_MODE_STEREO       SC_SOUND_MODE_STEREO
77 #define MIX_SOUND_MODE_SURROUND     SC_SOUND_MODE_SURROUND
78 #define MIX_SOUND_MODE_DPL2         3
79 
80 /*---------------------------------------------------------------------------*
81     mixer channel mode definitions
82  *---------------------------------------------------------------------------*/
83 #define MIX_MODE_AUXA_PREFADER      0x00000001
84 #define MIX_MODE_AUXB_PREFADER      0x00000002
85 #define MIX_MODE_AUXC_PREFADER      0x00000004
86 #define MIX_MODE_MUTE               0x00000008
87 
88 #define MIX_MODE_UPDATE_INPUT       0x10000000
89 #define MIX_MODE_UPDATE_INPUT1      0x20000000
90 #define MIX_MODE_UPDATE_MIX         0x40000000
91 #define MIX_MODE_UPDATE_MIX1        0x80000000
92 
93 /*---------------------------------------------------------------------------*
94     mixer channel mode definitions for remote speakers
95  *---------------------------------------------------------------------------*/
96 #define MIX_MODE_AUX0_PREFADER      0x00000001
97 #define MIX_MODE_AUX1_PREFADER      0x00000002
98 #define MIX_MODE_AUX2_PREFADER      0x00000004
99 #define MIX_MODE_AUX3_PREFADER      0x00000008
100 
101 /*---------------------------------------------------------------------------*
102  *---------------------------------------------------------------------------*/
103 typedef struct MIXChannel
104 {
105     AXVPB   *axvpb;
106 
107     u32     mode;
108 
109     int     input;
110     int     auxA;               // AUX send A
111     int     auxB;               // AUX send B
112     int     auxC;               // AUX send C
113     int     pan;                // 0 - 127 Left - Right
114     int     span;               // 0 - 127 Front - Back
115     int     fader;              // fader
116 
117     int     l;                  // left
118     int     r;                  // right
119     int     f;                  // front
120     int     b;                  // back
121     int     l1;                 // DPL2 left rear
122     int     r1;                 // DPL2 right rear
123 
124     u16     v;
125     u16     v1;
126     u16     vL;
127     u16     vL1;
128     u16     vR;
129     u16     vR1;
130     u16     vS;
131     u16     vS1;
132     u16     vAL;
133     u16     vAL1;
134     u16     vAR;
135     u16     vAR1;
136     u16     vAS;
137     u16     vAS1;
138     u16     vBL;
139     u16     vBL1;
140     u16     vBR;
141     u16     vBR1;
142     u16     vBS;
143     u16     vBS1;
144     u16     vCL;
145     u16     vCL1;
146     u16     vCR;
147     u16     vCR1;
148     u16     vCS;
149     u16     vCS1;
150 
151 } MIXChannel;
152 
153 typedef struct MIXRmtChannel
154 {
155     u32     mode;
156 
157     int     fader0;
158     int     fader1;
159     int     fader2;
160     int     fader3;
161 
162     int     aux0;
163     int     aux1;
164     int     aux2;
165     int     aux3;
166 
167     u16     vMain0;
168     u16     vMain0_1;
169     u16     vAux0;
170     u16     vAux0_1;
171 
172     u16     vMain1;
173     u16     vMain1_1;
174     u16     vAux1;
175     u16     vAux1_1;
176 
177     u16     vMain2;
178     u16     vMain2_1;
179     u16     vAux2;
180     u16     vAux2_1;
181 
182     u16     vMain3;
183     u16     vMain3_1;
184     u16     vAux3;
185     u16     vAux3_1;
186 
187 } MIXRmtChannel;
188 
189 
190 /*---------------------------------------------------------------------------*
191     Exposed function prototypes
192  *---------------------------------------------------------------------------*/
193 
194 void    MIXInit             (void);
195 void    MIXInitSpecifyMem   (void* mem);
196 void    MIXQuit             (void);
197 void    MIXSetSoundMode     (u32 mode);
198 u32     MIXGetSoundMode     (void);
199 
200 #define MIXGetMemorySize(num)  ((sizeof(MIXChannel) + sizeof(MIXRmtChannel)) * num)
201 
202 void    MIXInitChannel      (
203                              AXVPB *p,      // pointer to voice
204                              u32 mode,      // initial aux A, B, mute modes
205                              int input,     // initial input atten / gain
206                              int auxA,      // initial aux A atten / gain
207                              int auxB,      // initial aux B atten / gain
208                              int auxC,      // initial aux C atten / gain
209                              int pan,       // initial pan
210                              int span,      // initial span
211                              int fader      // initial fader atten / gain
212                              );
213 
214 void    MIXReleaseChannel   (AXVPB *p);
215 
216 void    MIXResetControls    (AXVPB *p);
217 
218 void    MIXSetInput         (AXVPB *p, int dB);
219 void    MIXAdjustInput      (AXVPB *p, int dB);
220 int     MIXGetInput         (AXVPB *p);
221 
222 void    MIXAuxAPostFader    (AXVPB *p);
223 void    MIXAuxAPreFader     (AXVPB *p);
224 BOOL    MIXAuxAIsPostFader  (AXVPB *p);
225 void    MIXSetAuxA          (AXVPB *p, int dB);
226 void    MIXAdjustAuxA       (AXVPB *p, int dB);
227 int     MIXGetAuxA          (AXVPB *p);
228 
229 void    MIXAuxBPostFader    (AXVPB *p);
230 void    MIXAuxBPreFader     (AXVPB *p);
231 BOOL    MIXAuxBIsPostFader  (AXVPB *p);
232 void    MIXSetAuxB          (AXVPB *p, int dB);
233 void    MIXAdjustAuxB       (AXVPB *p, int dB);
234 int     MIXGetAuxB          (AXVPB *p);
235 
236 void    MIXAuxCPostFader    (AXVPB *p);
237 void    MIXAuxCPreFader     (AXVPB *p);
238 BOOL    MIXAuxCIsPostFader  (AXVPB *p);
239 void    MIXSetAuxC          (AXVPB *p, int dB);
240 void    MIXAdjustAuxC       (AXVPB *p, int dB);
241 int     MIXGetAuxC          (AXVPB *p);
242 
243 void    MIXSetPan           (AXVPB *p, int pan);
244 void    MIXAdjustPan        (AXVPB *p, int pan);
245 int     MIXGetPan           (AXVPB *p);
246 
247 void    MIXSetSPan          (AXVPB *p, int span);
248 void    MIXAdjustSPan       (AXVPB *p, int span);
249 int     MIXGetSPan          (AXVPB *p);
250 
251 void    MIXMute             (AXVPB *p);
252 void    MIXUnMute           (AXVPB *p);
253 BOOL    MIXIsMute           (AXVPB *p);
254 
255 void    MIXSetFader         (AXVPB *p, int dB);
256 void    MIXAdjustFader      (AXVPB *p, int dB);
257 int     MIXGetFader         (AXVPB *p);
258 
259 void    MIXUpdateSettings   (void);
260 
261 void    MIXRmtSetVolumes    (
262                              AXVPB *axvpb,   // pointer to voice
263                              u32    mode,    // aux0,1,2,3 modes
264                              int    fader0,  // initial fader0 atten / gain
265                              int    fader1,  // initial fader1 atten / gain
266                              int    fader2,  // initial fader2 atten / gain
267                              int    fader3,  // initial fader3 atten / gain
268                              int    aux0,    // initial aux0   atten / gain
269                              int    aux1,    // initial aux1   atten / gain
270                              int    aux2,    // initial aux2   atten / gain
271                              int    aux3     // initial aux3   atten / gain
272                             );
273 
274 void    MIXRmtAuxPostFader  (AXVPB *p, int num);
275 void    MIXRmtAuxPreFader   (AXVPB *p, int num);
276 BOOL    MIXRmtAuxIsPostFader(AXVPB *p, int num);
277 
278 void    MIXRmtSetAux        (AXVPB *p, int num, int dB);
279 void    MIXRmtAdjustAux     (AXVPB *p, int num, int dB);
280 int     MIXRmtGetAux        (AXVPB *p, int num);
281 
282 void    MIXRmtSetFader      (AXVPB *p, int num, int dB);
283 void    MIXRmtAdjustFader   (AXVPB *p, int num, int dB);
284 int     MIXRmtGetFader      (AXVPB *p, int num);
285 
286 #ifdef __cplusplus
287 }
288 #endif
289 
290 #endif // __MIX_H__
291