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