1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: snd_CurveLfo.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. 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 $Revision: 13145 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_SND_CURVE_LFO_H_ 17 #define NW_SND_CURVE_LFO_H_ 18 19 #include <nn/types.h> 20 21 namespace nw { 22 namespace snd { 23 namespace internal { 24 25 /* ======================================================================== 26 structure definition 27 ======================================================================== */ 28 29 struct CurveLfoParam 30 { 31 f32 depth; 32 f32 speed; // [Hz] 33 u32 delay; 34 u8 range; 35 u8 padding[3]; 36 CurveLfoParamCurveLfoParam37 CurveLfoParam() { Initialize(); } 38 void Initialize(); 39 }; 40 41 /* ======================================================================== 42 class definition 43 ======================================================================== */ 44 45 class CurveLfo 46 { 47 /* ------------------------------------------------------------------------ 48 constant declaration 49 ------------------------------------------------------------------------ */ 50 private: 51 static const int TABLE_SIZE = 32; 52 static const int PERIOD = TABLE_SIZE * 4; 53 54 /* ------------------------------------------------------------------------ 55 static member 56 ------------------------------------------------------------------------ */ 57 private: 58 static s8 GetSinIdx( int index ); 59 60 /* ------------------------------------------------------------------------ 61 class member 62 ------------------------------------------------------------------------ */ 63 public: CurveLfo()64 CurveLfo() : m_DelayCounter(0), m_Counter( 0.0f ) {} 65 void Reset(); 66 67 void Update( int msec ); 68 f32 GetValue() const; 69 SetParam(const CurveLfoParam & lfoParam)70 void SetParam( const CurveLfoParam& lfoParam ) { m_Param = lfoParam; /* copy */ } GetParam()71 CurveLfoParam& GetParam() { return m_Param; } GetParam()72 const CurveLfoParam& GetParam() const { return m_Param; } 73 74 private: 75 CurveLfoParam m_Param; 76 u32 m_DelayCounter; 77 f32 m_Counter; 78 }; 79 80 } // namespace nw::snd::internal 81 } // namespace nw::snd 82 } // namespace nw 83 84 85 #endif /* NW_SND_CURVE_LFO_H_ */ 86 87