1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_CurveLfo.h
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: 31311 $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NW_SND_CURVE_LFO_H_
19 #define NW_SND_CURVE_LFO_H_
20 
21 #include <nn/types.h>
22 
23 namespace nw {
24 namespace snd {
25 namespace internal {
26 
27 /* ========================================================================
28         structure definition
29    ======================================================================== */
30 
31 struct CurveLfoParam
32 {
33     f32 depth;
34     f32 speed;   // [Hz]
35     u32 delay;
36     u8  range;
37     u8  padding[3];
38 
CurveLfoParamCurveLfoParam39     CurveLfoParam() { Initialize(); }
40     void Initialize();
41 };
42 
43 /* ========================================================================
44         class definition
45    ======================================================================== */
46 
47 class CurveLfo
48 {
49     /* ------------------------------------------------------------------------
50             constant declaration
51        ------------------------------------------------------------------------ */
52 private:
53     static const int TABLE_SIZE         = 32;
54     static const int PERIOD             = TABLE_SIZE * 4;
55 
56     /* ------------------------------------------------------------------------
57             static member
58        ------------------------------------------------------------------------ */
59 private:
60     static s8 GetSinIdx( int index );
61 
62    /* ------------------------------------------------------------------------
63             class member
64        ------------------------------------------------------------------------ */
65 public:
CurveLfo()66     CurveLfo() : m_DelayCounter(0), m_Counter( 0.0f ) {}
67     void Reset();
68 
69     void Update( int msec );
70     f32  GetValue() const;
71 
SetParam(const CurveLfoParam & lfoParam)72     void SetParam( const CurveLfoParam& lfoParam ) { m_Param = lfoParam; /* copy */ }
GetParam()73     CurveLfoParam& GetParam() { return m_Param; }
GetParam()74     const CurveLfoParam& GetParam() const { return m_Param; }
75 
76 private:
77     CurveLfoParam m_Param;
78     u32      m_DelayCounter;
79     f32      m_Counter;
80 };
81 
82 } // namespace nw::snd::internal
83 } // namespace nw::snd
84 } // namespace nw
85 
86 
87 #endif /* NW_SND_CURVE_LFO_H_ */
88 
89