
#ifndef _DirectSound_H_
#define _DirectSound_H_

#include "SoundGlobal.h"
#include "STL.h"

/////////////////////////////////////////////////////////////////////////////////////////
//	다이렉트 사운드 객체

class CDirectSound
{
	IDirectSound8 *				m_pDSound;
	IDirectSound3DListener *	m_p3DListener;
	bool						m_bDSoundCreated;
	
	typedef std::vector<ISoundObject*> SOUNDBUFFERLIST;
	SOUNDBUFFERLIST *			m_pSoundBufferList;

private:
	CDirectSound( const CDirectSound & );												//사용하지 못하도록 막아놨음.
	CDirectSound & operator=( const CDirectSound & );

protected:
	IDirectSound3DListener *	Get3DListenerInterface();
	CDirectSound();
	void	SetPrimaryBufferFormat( DWORD, DWORD, DWORD );

public:
	static CDirectSound & GetInstance();
	~CDirectSound();

	void	Create( IDirectSound8 * );
	void	Create( HWND,
					DWORD,
					DWORD dwPrimaryChannels = 2,
					DWORD dwPrimaryFreq = 22050,
					DWORD dwPrimaryBitRate = 16 );
	void	Destroy();

	void	Enable3DSound();															//처음에는 Disable된 상태임

	void	SetDoppler( D3DVALUE distance, D3DVALUE doppler );
	void	SetRolloff( D3DVALUE rolloff );
	void	Set3DOrientation( D3DVALUE xFront,	D3DVALUE yFront,	D3DVALUE zFront
							, D3DVALUE xTop,	D3DVALUE yTop,		D3DVALUE zTop );
	void	SetVelocity( D3DVALUE x, D3DVALUE y, D3DVALUE z );
	void	SetPosition( D3DVALUE x, D3DVALUE y, D3DVALUE z );

	void	RegisterSoundBuffer( ISoundObject * );											//사운드 버퍼를 제 때에 파괴해주기 위해 등록을 함.(파괴와 동시에 할당됐던 메모리를 반환함)

	IDirectSound8 *			GetDS()		{ return m_pDSound; }
};

/////////////////////////////////////////////////////////////////////////////////////////

#endif