1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: snd_Voice.h 4 5 Copyright (C)2009 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: 35006 $ 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; // One-pole filter coefficient 70 BiquadFilterCoefficients m_BiquadFilterCoeffs; // Biquad filter coefficient 71 NN_PADDING2; 72 73 s32 m_SampleRate; // Sampling frequency 74 f32 m_Pitch; // Pitch (ratio to the SampleRate) 75 76 s32 m_Priority; // Priority 77 Voice * m_PriorVoice; // Pointer to Voice that has the highest priority 78 Voice * m_InferiorVoice; // Pointer to Voice that has the lowest priority 79 80 VoiceDropCallbackFunc m_Callback; // Callback function called when the Voice is freed by the system 81 uptr m_UserArg; // User argument when the above callback is called 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* buffer); 117 /* 118 119 */ 120 121 /* Please see man pages for details 122 123 124 */ 125 /* Please see man pages for details 126 127 128 */ 129 void SetChannelCount(s32 channelCount); 130 131 /* Please see man pages for details 132 133 134 */ 135 void SetSampleFormat(SampleFormat format); 136 137 /* Please see man pages for details 138 139 140 */ 141 void SetFrontBypassFlag(bool flag); 142 143 /* Please see man pages for details 144 145 146 */ 147 void SetStartFrameFadeInFlag(bool flag); 148 149 /* Please see man pages for details 150 151 152 */ 153 void SetSampleRate(s32 sampleRate); 154 155 /* Please see man pages for details 156 157 158 */ 159 void SetPitch(f32 pitch); 160 161 /* Please see man pages for details 162 163 164 */ 165 void SetAdpcmParam(const AdpcmParam& param); 166 167 /* Please see man pages for details 168 169 170 */ 171 void SetPriority(s32 priority); 172 173 /* Please see man pages for details 174 175 176 */ 177 void SetState(State state); 178 179 /* Please see man pages for details 180 181 182 */ 183 void SetMixParam(const MixParam& mixParam); 184 185 /* Please see man pages for details 186 187 188 */ 189 void SetVolume(f32 volume); 190 191 /* Please see man pages for details 192 193 194 */ 195 void SetInterpolationType(InterpolationType type); 196 197 /* Please see man pages for details 198 199 200 */ 201 void SetFilterType(FilterType type); 202 203 /* Please see man pages for details 204 205 206 */ 207 void EnableMonoFilter(bool enable); 208 209 /* Please see man pages for details 210 211 212 */ 213 void SetMonoFilterCoefficients(const MonoFilterCoefficients* pCoeff); 214 215 /* Please see man pages for details 216 217 218 */ 219 void SetMonoFilterCoefficients(const MonoFilterCoefficients& coeff); 220 221 /* Please see man pages for details 222 223 224 */ 225 void SetMonoFilterCoefficients(u16 cutoff); 226 227 /* Please see man pages for details 228 229 230 */ 231 void EnableBiquadFilter(bool enable); 232 233 /* Please see man pages for details 234 235 236 */ 237 void SetBiquadFilterCoefficients(const BiquadFilterCoefficients* pCoeff); 238 239 /* Please see man pages for details 240 241 242 */ 243 void SetBiquadFilterCoefficients(const BiquadFilterCoefficients& coeff); 244 /* 245 246 */ 247 248 /* Please see man pages for details 249 250 251 */ 252 /* Please see man pages for details 253 254 255 */ GetPitch()256 inline f32 GetPitch() const { return m_Pitch; } 257 258 /* Please see man pages for details 259 260 261 */ GetPriority()262 inline s32 GetPriority() const { return m_Priority; } 263 264 /* Please see man pages for details 265 266 267 */ GetState()268 inline Voice::State GetState() const { return m_State; } 269 270 /* Please see man pages for details 271 272 273 */ GetMixParam()274 inline const MixParam& GetMixParam() const { return m_MixParam; } 275 276 /* Please see man pages for details 277 278 279 */ GetVolume()280 inline f32 GetVolume() const { return m_Volume; } 281 282 /* Please see man pages for details 283 284 285 */ GetInterpolationType()286 inline InterpolationType GetInterpolationType() const { return m_InterpolationType; } 287 288 /* Please see man pages for details 289 290 291 */ GetFilterType()292 inline FilterType GetFilterType() const { return m_FilterType; } 293 294 /* Please see man pages for details 295 296 297 */ 298 void GetMonoFilterCoefficients(MonoFilterCoefficients* pCoeff); 299 300 /* Please see man pages for details 301 302 303 */ 304 void GetMonoFilterCoefficients(MonoFilterCoefficients& coeff); 305 306 /* Please see man pages for details 307 308 309 */ 310 void GetBiquadFilterCoefficients(BiquadFilterCoefficients* pCoeff); 311 312 /* Please see man pages for details 313 314 315 */ 316 void GetBiquadFilterCoefficients(BiquadFilterCoefficients& coeff); 317 /* 318 319 */ 320 321 /* Please see man pages for details 322 323 324 */ 325 /* Please see man pages for details 326 327 328 */ 329 s32 GetPlayPosition() const; 330 331 /* Please see man pages for details 332 333 334 */ 335 bool IsPlaying() const; 336 /* 337 338 */ 339 340 /* Please see man pages for details 341 342 343 */ 344 /* Please see man pages for details 345 346 347 348 349 350 351 */ 352 bool SetupBcwav(uptr addrBcwav, WaveBuffer* pWaveBuffer0, WaveBuffer* pWaveBuffer1, Bcwav::ChannelIndex channelIndex = Bcwav::CHANNEL_INDEX_L); 353 /* 354 355 */ 356 357 private: 358 void SetChannelCountCommand(s32 channelCount); 359 void SetSampleFormatCommand(SampleFormat format); 360 void SetFrontBypassFlagCommand(bool flag); 361 void SetStartFrameFadeInFlagCommand(bool flag); 362 void SetSampleRateCommand(s32 sampleRate); 363 void SetPitchCommand(f32 pitch); 364 void SetInterpolationTypeCommand(InterpolationType type); 365 void SetFilterTypeCommand(FilterType type); 366 void EnableMonoFilterCommand(bool enable); 367 void SetMonoFilterCoefficientsCommand(const MonoFilterCoefficients& coeff); 368 void SetMonoFilterCoefficientsCommand(u16 cutoff); 369 void EnableBiquadFilterCommand(bool enable); 370 void SetBiquadFilterCoefficientsCommand(const BiquadFilterCoefficients& coeff); 371 void SetAdpcmParamCommand(const AdpcmParam& param); 372 void SetStateCommand(State state); 373 void SetMixParamCommand(const MixParam& mixParam); 374 void SetVolumeCommand(f32 volume); 375 bool SetupBcwavCommand(uptr addrBcwav, WaveBuffer* pWaveBuffer0, WaveBuffer* pWaveBuffer1, Bcwav::ChannelIndex channelIndex); 376 }; // class Voice 377 378 /* Please see man pages for details 379 380 381 */ 382 /* Please see man pages for details 383 384 385 386 387 388 */ 389 Voice* AllocVoice(s32 priority, VoiceDropCallbackFunc callback, uptr userArg); 390 391 /* Please see man pages for details 392 393 394 */ 395 void FreeVoice(Voice* pVoice); 396 /* 397 398 */ 399 400 }}} // namespace nn::snd::CTR 401 402 #endif // __cplusplus 403 404 #endif //NN_SND_VOICE_H_ 405