The first step in creating a tool for DirectMusic in C++ is to declare a class derived from IDirectMusicTool.
Here is the declaration for the sample CEchoTool class:
class CEchoTool : public IDirectMusicTool
{
public:
CEchoTool();
~CEchoTool();
public:
// IUnknown
virtual STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
virtual STDMETHODIMP_(ULONG) AddRef();
virtual STDMETHODIMP_(ULONG) Release();
// IDirectMusicTool
HRESULT STDMETHODCALLTYPE Init(
IDirectMusicGraph* pGraph);
HRESULT STDMETHODCALLTYPE GetMsgDeliveryType(
DWORD* pdwDeliveryType);
HRESULT STDMETHODCALLTYPE GetMediaTypeArraySize(
DWORD* pdwNumElements);
HRESULT STDMETHODCALLTYPE GetMediaTypes(
DWORD** padwMediaTypes,
DWORD dwNumElements);
HRESULT STDMETHODCALLTYPE ProcessPMsg(
IDirectMusicPerformance* pPerf,
DMUS_PMSG* pDMUS_PMSG);
HRESULT STDMETHODCALLTYPE Flush(
IDirectMusicPerformance* pPerf,
DMUS_PMSG* pDMUS_PMSG,
REFERENCE_TIME rtTime);
private:
long m_cRef; // Reference counter
DWORD m_dwEchoNum; // Number of echoes to generate
MUSIC_TIME m_mtDelay; // Delay time between echoes
CRITICAL_SECTION m_CrSec; // To make SetEchoNum()
// and SetDelay() thread-safe
public:
// Public class methods
void SetEchoNum(DWORD);
void SetDelay(MUSIC_TIME);
};