
#ifndef _MusicBuffer_H_
#define _MusicBuffer_H_

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


typedef struct _DS3DBUFFER DS3DBUFFER;

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

class CMusicBuffer : public ISoundObject
{
protected:
    IDirectMusicSegment8 *	m_pSegment;
	IDirectMusicAudioPath8*	m_pAudioPath;
	IDirectSound3DBuffer *	m_pDS3DBuffer;
	DS3DBUFFER *			m_p3DBufferParam;
	CDirectMusic *			m_pDMusic;

	string *				m_pstrFilename;

protected:
	CMusicBuffer();
	virtual ~CMusicBuffer();

	friend CMusicBuffer *	NewMusicBuffer();
	friend void				DeleteMusicBuffer( CMusicBuffer * );

public:
	void	Create( const char * szFilename, bool b3D = false );
	void	Destroy();

	int		Play( bool bLoop );
	void	Play( DWORD dwIndex, bool bLoop );
	void	Stop( unsigned );
	void	StopAll();
	void	Reset( unsigned );
	void	ResetAll();
	HANDLE	GetEventNotify() { return 0; }
	void	HandleNotification() {}
	bool	IsAllPlaying();
	bool	IsAllFree();
	bool	IsPlaying( unsigned );
	
	void	Download();

	DWORD			GetMemoryUse();	
	bool			IsSameFile( const char * );
	const char *	GetFilename();

	eSndObjType		GetType()		{ return SNDOBJTYPE_MUSICBUFFER; }

	void			SetPosition( DWORD dwIndex, D3DVALUE x, D3DVALUE y, D3DVALUE z );
	void			SetDistance( DWORD dwIndex, D3DVALUE minDistance, D3DVALUE maxDistance );
};

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

#endif