Click here to Skip to main content
15,881,380 members
Articles / Multimedia / DirectX

DirectSound Wrapper Classes

Rate me:
Please Sign up or sign in to vote.
4.79/5 (20 votes)
6 Aug 2006CPOL4 min read 129.8K   4.5K   38  
An article on multimedia - playing Waves by using the DirectSound component.
// Wave.h
#ifndef __WAVE_H__
#define __WAVE_H__

#include <MMSystem.h>


class AFX_EXT_CLASS CWave : public CObject
{
	BYTE* m_pImageData;
	DWORD m_dwImageLen;
	BOOL  m_bResource;
public:
	CWave();
	CWave(LPCTSTR lpszFileName);
	CWave(UINT nResID, HMODULE hMod = AfxGetInstanceHandle());
	virtual ~CWave();

public:
	BOOL    Create(LPCTSTR lpszFileName);
	BOOL    Create(UINT uiResID, HMODULE hMod =	AfxGetInstanceHandle());
	BOOL    IsValid() const { return (m_pImageData ? TRUE :	FALSE); };
	BOOL    Play(BOOL bAsync = TRUE, BOOL bLooped = FALSE) const;
	BOOL    GetFormat(WAVEFORMATEX& wfFormat) const;
	DWORD   GetDataLen() const;
	DWORD   GetData(BYTE*& pWaveData, DWORD dwMaxToCopy) const;

protected:
	BOOL    Free();
};

#endif // __WAVE_H__

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer 13
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions