6 #ifndef _INC_cDirectSound_H
7 #define _INC_cDirectSound_H
11 #include "../Gray3D.h"
34 MIDL_INTERFACE(
"279AFA86-4981-11CE-A521-0020AF0BE560") IDirectSound3DBuffer;
35 MIDL_INTERFACE("279AFA85-4981-11CE-A521-0020AF0BE560") IDirectSoundBuffer;
39 template class GRAY3D_LINK cIUnkPtr<IDirectSoundBuffer>;
40 template class GRAY3D_LINK cIUnkPtr<IDirectSound3DBuffer>;
43 class GRAY3D_LINK cDirectSoundInst :
public cRefBase,
public cHeapObject
48 friend class cDirectSoundMgr;
50 cDirectSoundInst( ISoundObject* pSoundObj,
bool bUse3D=
true,
SOUND_POWER_t fPower=k_SOUND_POWER_DEF );
51 cDirectSoundInst(
const cWaveFormatEx* pwf,
size_t dwDataSize,
const void* pWaveData,
bool bUse3D=
true,
SOUND_POWER_t fPower=k_SOUND_POWER_DEF );
52 virtual ~cDirectSoundInst();
54 bool isValid()
const noexcept
56 return m_pDSBuffer.isValidPtr();
59 HRESULT SetupBuffer(
const cWaveFormatEx* pwf,
size_t dwDataSize,
const void* pWaveData );
60 HRESULT SetupBuffer( ISoundObject* pSoundObj );
62 DWORD get_StatusFlags()
const;
63 bool isPlaying()
const
65 return(( get_StatusFlags() & DSBSTATUS_PLAYING ) ?
true :
false );
67 bool isLooping()
const
69 return(( get_StatusFlags() & DSBSTATUS_LOOPING ) ?
true :
false );
72 bool Play(
const cVector3f* ppt=
nullptr,
SOUND_VOL_t nVolMax=cSoundBase::k_VOL_MAX,
int iRepeat=0 );
75 IDirectSoundBuffer* get_Buffer()
const
76 {
return m_pDSBuffer;}
77 IDirectSound3DBuffer* get_Buffer3D()
const
78 {
return m_pDS3DBuffer; }
80 bool UpdatePos(
const cVector3f& vPos,
const cVector3f& vVelocity );
84 HRESULT WriteBuffer(
const void* pWaveData,
size_t& dwDataSize );
85 HRESULT CreateBuffer(
const cWaveFormatEx* pwf,
size_t dwDataSize,
bool bUseDX3D );
87 void Update3D(
bool bFirst );
95 cVector3f m_vVelocity;
102 cIUnkPtr<IDirectSoundBuffer> m_pDSBuffer;
103 cIUnkPtr<IDirectSound3DBuffer> m_pDS3DBuffer;
104 cIUnkPtr<ISoundObject> m_pSoundObj;
107 typedef cRefPtr<cDirectSoundInst> cDirectSoundInstPtr;
110 :
public cSingletonStatic<cDirectSoundMgr>
115 friend class cDirectSoundInst;
117 cDirectSoundMgr(
bool bUseDX3D=
false,
int iMaxSounds=8 );
120 HRESULT InitSoundMgr( HWND hWnd,
const cVector3f* ptEarPosition );
121 void CloseSoundMgr();
125 const cVector3f& get_EarPosition()
const
127 return m_vEarPosition;
129 void put_EarPosition(
const cVector3f& ptEarPosition );
130 void put_EarFrontDir(
const cVector3f& ptEarOrient );
131 void put_EarTopDir(
const cVector3f& ptEarOrient );
132 void put_EarVelocity(
const cVector3f& ptEarVelocity );
134 cDirectSoundInstPtr PlaySound( ISoundObject* pSoundObj,
SOUND_POWER_t fPower=k_SOUND_POWER_DEF,
const cVector3f* ppt=
nullptr,
int iRepeat=0,
SOUND_VOL_t nVolMax=cSoundBase::k_VOL_MAX );
137 return( m_pDS !=
nullptr );
139 IDirectSound* get_DS()
const
142 bool UpdateSounds(
bool bForceUpdate =
false );
145 bool CheckMaxSounds();
155 cVector3f m_vEarPosition;
156 cVector3f m_vEarVelocity;
157 cVector3f m_vEarFrontDir;
158 cVector3f m_vEarTopDir;
160 cTimeSys m_TimeLastUpdate;
164 cIUnkPtr<IDirectSound8> m_pDS;
165 cIUnkPtr<IDirectSound3DListener> m_pDS3DListener;
166 cArrayRef<cDirectSoundInst> m_aSoundInsts;
MIDL_INTERFACE("7ED943DD-52E8-40b5-A8D8-76685C406330") ID3DXBaseMesh
#define GRAY3D_LINK
Definition: Gray3D.h:15
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define CHEAPOBJECT_IMPL
Definition: cHeapObject.h:32
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
WORD SOUND_VOL_t
Mono Attenuation of the audio. linear perception 0 to k_VOL_MAX(0xffff). NOT decibels.
Definition: cSoundBase.h:29
INT32 TIMESYSD_t
Time delta. signed milli-Seconds Span. cTimeSys::k_DMAX, cTimeSys::k_INF = MAILSLOT_WAIT_FOREVER.
Definition: cTimeSys.h:28