1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     snd_Voice.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  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   $Rev: 46364 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_SND_VOICE_H_
17 #define NN_SND_VOICE_H_
18 
19 #include <nn/os.h>
20 #include <nn/Result.h>
21 
22 #include <nn/snd/CTR/Common/snd_Types.h>
23 
24 #ifdef __cplusplus
25 
26 /* Please see man pages for details
27 
28 */
29 
30 namespace nn  { namespace snd { namespace CTR {
31 
32 /* Please see man pages for details
33 
34 
35 
36 */
37 typedef void (*VoiceDropCallbackFunc)(class Voice *, uptr userArg);
38 
39 class VoiceImpl;
40 class VoiceManager;
41 
42 /* Please see man pages for details
43 
44  */
45 class Voice
46 {
47     friend class VoiceManager;
48 
49 public:
50 
51     /* Please see man pages for details
52 
53      */
54     enum State
55     {
56         STATE_PLAY,  //
57         STATE_STOP,  //
58         STATE_PAUSE  //
59     };
60 
61 private:
62     const s32                           m_Id;                  // Voice number (for management)
63 
64     util::SizedEnum1<State>             m_State;               // Status
65     util::SizedEnum1<InterpolationType> m_InterpolationType;   // Interpolation method
66     NN_PADDING1;
67 
68     util::SizedEnum1<FilterType>        m_FilterType;          // Filter type
69     MonoFilterCoefficients              m_MonoFilterCoeffs;    // Monopole filter coefficient
70     BiquadFilterCoefficients            m_BiquadFilterCoeffs;  // Bipolar filter coefficient
71     NN_PADDING2;
72 
73     s32                                 m_SampleRate;          // Sampling frequency
74     f32                                 m_Pitch;               // Pitch (ratio for SampleRate)
75 
76     s32                                 m_Priority;            // Priority
77     Voice *                             m_PriorVoice;          // Pointer to the Voice with high priority
78     Voice *                             m_InferiorVoice;       // Pointer to the Voice with low priority
79 
80     VoiceDropCallbackFunc               m_Callback;            // Callback function called when Voice is deallocated by the system
81     uptr                                m_UserArg;             // User argument when calling the above callback
82 
83     MixParam                            m_MixParam;            // Gain for each channel
84     f32                                 m_Volume;              // Volume
85 
86     VoiceImpl*                          m_pImpl;
87 
88     void Initialize();
89     void UpdateStatus(const void* pVars);
90     void UpdateWaveBufferList();
GetId()91     s32 GetId() const { return m_Id; }
GetImpl()92     VoiceImpl* GetImpl() const { return m_pImpl; }
93 
94     /* Please see man pages for details
95 
96 
97 
98 
99      */
100     explicit Voice(s32 id);
101 
102     /* Please see man pages for details
103 
104      */
105     ~Voice();
106 
107 public:
108     /* Please see man pages for details
109 
110 
111      */
112     /* Please see man pages for details
113 
114 
115      */
116     void AppendWaveBuffer(WaveBuffer* pBuffer);
117 
118     /* Please see man pages for details
119 
120 
121      */
122     void DeleteWaveBuffer(WaveBuffer* pBuffer);
123 
124     /* Please see man pages for details
125 
126 
127      */
128     void UpdateWaveBuffer(WaveBuffer* pBuffer);
129 
130     /*
131 
132 */
133 
134     /* Please see man pages for details
135 
136 
137      */
138     /* Please see man pages for details
139 
140 
141      */
142     void SetChannelCount(s32 channelCount);
143 
144     /* Please see man pages for details
145 
146 
147      */
148     void SetSampleFormat(SampleFormat format);
149 
150     /* Please see man pages for details
151 
152 
153      */
154     void SetFrontBypassFlag(bool flag);
155 
156     void Set3dSurroundPreprocessed(bool flag);
157 
158     /* Please see man pages for details
159 
160 
161      */
162     void SetStartFrameFadeInFlag(bool flag);
163 
164     /* Please see man pages for details
165 
166 
167      */
168     void SetSampleRate(s32 sampleRate);
169 
170     /* Please see man pages for details
171 
172 
173      */
174     void SetPitch(f32 pitch);
175 
176     /* Please see man pages for details
177 
178 
179      */
180     void SetAdpcmParam(const AdpcmParam& param);
181 
182     /* Please see man pages for details
183 
184 
185      */
186     void SetPriority(s32 priority);
187 
188     /* Please see man pages for details
189 
190 
191      */
192     void SetState(State state);
193 
194     /* Please see man pages for details
195 
196 
197      */
198     void SetMixParam(const MixParam& mixParam);
199 
200     /* Please see man pages for details
201 
202 
203      */
204     void SetVolume(f32 volume);
205 
206     /* Please see man pages for details
207 
208 
209      */
210     void SetInterpolationType(InterpolationType type);
211 
212     /* Please see man pages for details
213 
214 
215      */
216     void SetFilterType(FilterType type);
217 
218     /* Please see man pages for details
219 
220 
221      */
222     void EnableMonoFilter(bool enable);
223 
224     /* Please see man pages for details
225 
226 
227      */
228     void SetMonoFilterCoefficients(const MonoFilterCoefficients* pCoeff) NN_ATTRIBUTE_DEPRECATED;
229 
230     /* Please see man pages for details
231 
232 
233      */
234     void SetMonoFilterCoefficients(const MonoFilterCoefficients& coeff);
235 
236     /* Please see man pages for details
237 
238 
239      */
240     void SetMonoFilterCoefficients(u16 cutoff);
241 
242     /* Please see man pages for details
243 
244 
245      */
246     void EnableBiquadFilter(bool enable);
247 
248     /* Please see man pages for details
249 
250 
251      */
252     void SetBiquadFilterCoefficients(const BiquadFilterCoefficients* pCoeff) NN_ATTRIBUTE_DEPRECATED;
253 
254     /* Please see man pages for details
255 
256 
257      */
258     void SetBiquadFilterCoefficients(const BiquadFilterCoefficients& coeff);
259     /*
260 
261 */
262 
263     /* Please see man pages for details
264 
265 
266      */
267     /* Please see man pages for details
268 
269 
270      */
GetPitch()271     inline f32 GetPitch() const { return m_Pitch; }
272 
273     /* Please see man pages for details
274 
275 
276      */
GetPriority()277     inline s32 GetPriority() const { return m_Priority; }
278 
279     /* Please see man pages for details
280 
281 
282      */
GetState()283     inline Voice::State GetState() const { return m_State; }
284 
285     /* Please see man pages for details
286 
287 
288      */
GetMixParam()289     inline const MixParam& GetMixParam() const { return m_MixParam; }
290 
291     /* Please see man pages for details
292 
293 
294      */
GetVolume()295     inline f32 GetVolume() const { return m_Volume; }
296 
297     /* Please see man pages for details
298 
299 
300      */
GetInterpolationType()301     inline InterpolationType GetInterpolationType() const { return m_InterpolationType; }
302 
303     /* Please see man pages for details
304 
305 
306      */
GetFilterType()307     inline FilterType GetFilterType() const { return m_FilterType; }
308 
309     /* Please see man pages for details
310 
311 
312      */
313     void GetMonoFilterCoefficients(MonoFilterCoefficients* pCoeff) NN_ATTRIBUTE_DEPRECATED;
314 
315     /* Please see man pages for details
316 
317 
318      */
319     void GetMonoFilterCoefficients(MonoFilterCoefficients& coeff);
320 
321     /* Please see man pages for details
322 
323 
324      */
325     void GetBiquadFilterCoefficients(BiquadFilterCoefficients* pCoeff) NN_ATTRIBUTE_DEPRECATED;
326 
327     /* Please see man pages for details
328 
329 
330      */
331     void GetBiquadFilterCoefficients(BiquadFilterCoefficients& coeff);
332     /*
333 
334 */
335 
336     /* Please see man pages for details
337 
338 
339      */
340     /* Please see man pages for details
341 
342 
343      */
344     s32 GetPlayPosition() const;
345 
346     /* Please see man pages for details
347 
348 
349      */
350     bool IsPlaying() const;
351     /*
352 
353 */
354 
355     /* Please see man pages for details
356 
357 
358      */
359     /* Please see man pages for details
360 
361 
362 
363 
364 
365 
366      */
367     bool SetupBcwav(uptr addrBcwav, WaveBuffer* pWaveBuffer0, WaveBuffer* pWaveBuffer1, Bcwav::ChannelIndex channelIndex = Bcwav::CHANNEL_INDEX_L);
368     /*
369 
370 */
371 }; // class Voice
372 
373 /* Please see man pages for details
374 
375 
376  */
377 /* Please see man pages for details
378 
379 
380 
381 
382 
383  */
384 Voice* AllocVoice(s32 priority, VoiceDropCallbackFunc callback, uptr userArg);
385 
386 /* Please see man pages for details
387 
388 
389  */
390 void FreeVoice(Voice* pVoice);
391 
392 /* Please see man pages for details
393 
394  */
395 enum VoiceDropMode
396 {
397     VOICE_DROP_MODE_DEFAULT = 0,   //
398     VOICE_DROP_MODE_REAL_TIME = 1  //
399 };
400 
401 /* Please see man pages for details
402 
403 
404 
405 
406 
407 
408 
409 
410 
411 
412 
413  */
414 void SetVoiceDropMode(VoiceDropMode mode);
415 
416 /*
417 
418 */
419 
420 }}} // namespace nn::snd::CTR
421 
422 #endif // __cplusplus
423 
424 #endif //NN_SND_VOICE_H_
425