
#ifndef _DirectMusic_H_
#define _DirectMusic_H_

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

class CMusicBuffer;

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

class CDirectMusic
{
private:
	CDirectMusic( const CDirectMusic & );								//사용 못하도록 막아놓음.
	CDirectMusic & operator=( const CDirectMusic & );

protected:
	CDirectMusic();

protected:
	IDirectMusicLoader8 *		m_pWavLoader;
	IDirectMusicLoader8 *		m_pOggLoader;
    IDirectMusicPerformance8 *	m_pPerformance;
	bool						m_bCOMInitialized;

	IDirectSound3DListener *	m_pDSListener;

	typedef std::set<CMusicBuffer*>	MUSICBUFFERS;
	
	MUSICBUFFERS *				m_pMusicBuffers;

protected:
	void			ClearMusicBuffers();
	void			Get3DListener();

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

	void			Create( HWND, DWORD dwPChannels = 128 );
	void			Destroy();

	void			SetSearchDirectory( const char * );
	void			CollectGarbage();

	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 );

	CMusicBuffer &	NewMusicBuffer();
	void			DeleteMusicBuffer( CMusicBuffer & musicBuffer );

	IDirectMusicLoader8 *		GetWavLoader()		{ return m_pWavLoader; }
	IDirectMusicLoader8 *		GetOggLoader()		{ return m_pOggLoader; }
	IDirectMusicPerformance8 *	GetPerformance()	{ return m_pPerformance; }
};

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

#endif