1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     snd_BasicSoundPlayer.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: 22340 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NW_SND_BASIC_SOUND_PLAYER_H_
17 #define NW_SND_BASIC_SOUND_PLAYER_H_
18 
19 #include <nn/types.h>
20 #include <nw/snd/snd_Global.h>
21 
22 namespace nw {
23 namespace snd {
24 namespace internal {
25 namespace driver {
26 
27 /* ========================================================================
28         class definition
29    ======================================================================== */
30 
31 // ------------------------------------------------------------------------
32 // プレイヤーパラメータセット
33 struct PlayerParamSet
34 {
35     float volume;
36     float pitch;
37     float pan;
38     float surroundPan;
39     float lpfFreq;
40     float biquadValue;
41     u8 biquadType;
42     u8 padding;
43     bool isFrontBypass;
44     float mainSend;
45     PanMode panMode;
46     PanCurve panCurve;
47     float fxSend[ AUX_BUS_NUM ];
48 
PlayerParamSetPlayerParamSet49     PlayerParamSet() { Initialize(); }
50     void Initialize();
51 };
52 
53 class BasicSoundPlayer
54 {
55   public:
56     BasicSoundPlayer();
~BasicSoundPlayer()57     virtual ~BasicSoundPlayer() {};
58 
59     virtual void Initialize();
60     virtual void Finalize();
61 
62     virtual void Start() = 0;
63     virtual void Stop() = 0;
64     virtual void Pause( bool flag ) = 0;
65 
IsActive()66     bool IsActive() const { return m_ActiveFlag; }
IsStarted()67     bool IsStarted() const { return m_StartedFlag; }
IsPause()68     bool IsPause() const { return m_PauseFlag; }
IsPlayFinished()69     bool IsPlayFinished() const { return m_FinishFlag; }
70 
71     void UpdateStatus();
72 
73     //------------------------------------------------------------------
74     // プレイヤーパラメータ
SetVolume(float volume)75     void SetVolume( float volume ) { m_PlayerParamSet.volume = volume; }
SetPitch(float pitch)76     void SetPitch( float pitch ) { m_PlayerParamSet.pitch = pitch; }
SetPan(float pan)77     void SetPan( float pan ) { m_PlayerParamSet.pan = pan; }
SetLpfFreq(float lpfFreq)78     void SetLpfFreq( float lpfFreq ) { m_PlayerParamSet.lpfFreq = lpfFreq; }
79     void SetBiquadFilter( int type, float value );
SetPanMode(PanMode panMode)80     void SetPanMode( PanMode panMode ) { m_PlayerParamSet.panMode = panMode; }
SetPanCurve(PanCurve panCurve)81     void SetPanCurve( PanCurve panCurve ) { m_PlayerParamSet.panCurve = panCurve; }
SetSurroundPan(float surroundPan)82     void SetSurroundPan( float surroundPan ) { m_PlayerParamSet.surroundPan = surroundPan; }
SetFrontBypass(bool frontBypass)83     void SetFrontBypass( bool frontBypass ) { m_PlayerParamSet.isFrontBypass = frontBypass; }
84 
GetVolume()85     float GetVolume() const { return m_PlayerParamSet.volume; }
GetPitch()86     float GetPitch() const { return m_PlayerParamSet.pitch; }
GetPan()87     float GetPan() const { return m_PlayerParamSet.pan; }
GetLpfFreq()88     float GetLpfFreq() const { return m_PlayerParamSet.lpfFreq; }
GetBiquadFilterType()89     int GetBiquadFilterType() const { return m_PlayerParamSet.biquadType; }
GetBiquadFilterValue()90     float GetBiquadFilterValue() const { return m_PlayerParamSet.biquadValue; }
GetPanMode()91     PanMode GetPanMode() const { return m_PlayerParamSet.panMode; }
GetPanCurve()92     PanCurve GetPanCurve() const { return m_PlayerParamSet.panCurve; }
GetSurroundPan()93     float GetSurroundPan() const { return m_PlayerParamSet.surroundPan; }
IsFrontBypass()94     bool IsFrontBypass() const { return m_PlayerParamSet.isFrontBypass; }
95 
96     //------------------------------------------------------------------
97     // 出力パラメータ
SetMainSend(float send)98     void SetMainSend( float send ) { m_PlayerParamSet.mainSend = send; }
99     void SetFxSend( AuxBus bus, float send );
100 
GetMainSend()101     float GetMainSend() const { return m_PlayerParamSet.mainSend; }
102     float GetFxSend( AuxBus bus ) const;
103 
TryWaitInstanceFree()104     bool TryWaitInstanceFree() { return m_Event.TryWait(); }
WaitInstanceFree()105     void WaitInstanceFree() { m_Event.Wait(); }
106 
107   protected:
108     nn::os::LightEvent m_Event;
109     bool m_ActiveFlag; // ディスポースコールバック登録されているかどうか
110     bool m_StartedFlag; // プレイヤーコールバック登録されているかどうか
111     bool m_PauseFlag;
112     bool m_FinishFlag;
113 
114   private:
115     PlayerParamSet m_PlayerParamSet;
116 };
117 
118 } // namespace nw::snd::internal::driver
119 } // namespace nw::snd::internal
120 } // namespace nw::snd
121 } // namespace nw
122 
123 
124 #endif /* NW_SND_BASIC_SOUND_PLAYER_H_ */
125 
126