Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cSoundManager.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cSoundManager_H
7 #define _INC_cSoundManager_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 
12 #include "cDirectSound.h"
13 #include "cSoundDef.h"
14 
15 #ifdef USE_DX9
20 
21 namespace GrayLib
22 {
23  class cMatrix4x4f;
24 };
25 
26 namespace Gray3D
27 {
28  class GRAY3D_LINK cSoundManageList
29  {
32 
33  public:
34  cVariant m_vPlayList;
35 
36  cTimeSys m_tLastUpdate;
37  cStringF m_sFileNamePlaying;
38 
39  cStringF m_sFileNameNext;
40  bool m_bLoopNext;
41  // float m_fSegueNext; //!< seconds to seque < 0 = seque out, > 0 = seque in.
42 
43  cDirectShowFile m_Obj;
44 
45  public:
46  cSoundManageList();
47  ~cSoundManageList();
48 
49  bool IsPlaying( cStringF sFile ) const;
50  void SegueTo( cStringF sFile, float fSegueTime );
51  void SetPlayList( cVariant& vPlayList, float fSegueTime );
52 
53  void UpdateTick( TIMESYS_t timeNow, SOUND_VOL_t nVol );
54  bool PlayNext( SOUND_VOL_t nVol );
55  void AdvancePlayList();
56  };
57 
58  class GRAY3D_LINK cSoundManager
59  : public cDirectSoundMgr // cSingletonStatic based
60  {
64 
65  friend class cSoundManageList;
66  typedef cDirectSoundMgr SUPER_t;
67 
68  public:
70  cDirectShowFile m_Speech;
71 
73  cSoundManageList m_Music;
74 
76  cSoundManageList m_AmbientSound;
77 
78  // Config Params.
79  bool m_bVolMuteAll;
80  SOUND_VOL_t m_nVolMusic;
81  SOUND_VOL_t m_nVolSpeech;
82  bool m_bVolMuteAmbient;
83  SOUND_VOL_t m_nVolAmbient;
84 
85  cArraySortName<cSoundDef> m_aSoundDefs;
86 
87  private:
88  HWND m_hWndEvents;
89  WINMSG_t m_uMsgEvents;
90 
91  public:
92  cSoundManager();
93  ~cSoundManager();
94 
96  static cStringF CheckSoundFileName( cStringF sSoundFile );
97 
98  HRESULT InitSoundMgr( HWND hWndEvents, WINMSG_t uMsgEvents );
99  void Unload();
100  void onTickSound( const cMatrix4x4f* pmInvView );
101  void ClearAll();
102 
103  cSoundDefPtr LoadSoundDef( const FILECHAR_t* pszFileName );
104 
106  cDirectSoundInstPtr PlaySound( const FILECHAR_t* pszFileName, SOUND_POWER_t fPower, const cVector3f* ppt=nullptr, int iRepeat=0, SOUND_VOL_t nVol = cSoundBase::k_VOL_MAX );
107 
108  void put_VolMuteAll( bool bVolMuteAll )
109  {
110  m_bVolMuteAll = bVolMuteAll;
111  m_AmbientSound.m_Obj.Stop();
112  m_Music.m_Obj.Stop();
113  }
114 
115  UNITTEST_FRIEND(cSoundManager);
116  };
117 
118  extern GRAY3D_LINK cSoundManager g_SoundManager; // GET RID OF THIS singleton
119 };
120 
121 #endif
122 #endif
#define GRAY3D_LINK
Definition: Gray3D.h:15
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
UINT WINMSG_t
Supplement _WIN32 "windows.h".
Definition: WinTypes.h:111
#define UNITTEST_FRIEND(n)
Define this in the class body to be unit tested. Allow the unit test to access private/protected stuf...
Definition: cUnitTestDecl.h:17
Definition: Gray3D.cpp:12
float SOUND_POWER_t
Power of the sound. This roughly corresponds to hearing distance, but THIS IS NOT CUT-OFF DISTANCE.
Definition: cDirectSound.h:26
Definition: cMesh.h:22
class __DECL_IMPORT cMatrix4x4f
Definition: cVector.h:22
WORD SOUND_VOL_t
Mono Attenuation of the audio. linear perception 0 to k_VOL_MAX(0xffff). NOT decibels.
Definition: cSoundBase.h:29
class __DECL_IMPORT cVariant
Definition: cJSONWriter.h:19
cStringT< FILECHAR_t > cStringF
A file name. checks USE_UNICODE_FN. related to cFilePath.
Definition: cFilePath.h:17
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22
UINT32 TIMESYS_t
TIMESYS_t = The normal system tick timer. milli-seconds since start of system/app ?
Definition: cTimeSys.h:27
static const SOUND_VOL_t k_VOL_MAX
mono linear max perceived volume from waveOutGetVolume() M$ docs. NOT decibels which is logarithmic w...
Definition: cSoundBase.h:49