www.pudn.com > GameEngine.rar > GameEngine_Sound.h, change:2005-10-17,size:1568b
#ifndef GameEngine_Sound_Include
#define GameEngine_Sound_Include
typedef struct sWaveHeader_tag {
char RiffID[4]; //'RIFF'块
long WaveformChunkSize; //4个字节
char WaveID[4]; //.wav文件应为'WAVE'类型
char FormatID[4]; //'fmt '块(末尾有一个空格)
long FormatChunkSize; //16个字节
short FormatTag; //.wav文件应为WAVE_FORMAT_PCM
short Channels; //声道数
long SampleRate; //采样频率
long BytesPerSec; //每秒采样的字节数
short BlockAlign; //块对齐大小
short BitsPerSample; //bit位数(8bit或16bit)
char DataID[4]; //'data'块
long DataSize; //data块的大小(实际的声音数据)
}sWaveHeader;
class CGameEngine_SoundManager{
private:
static CGameEngine_SoundManager* m_pSoundManager;
IDirectSound8 *m_pDirectSound;
public:
CGameEngine_SoundManager();
~CGameEngine_SoundManager();
bool Init(HWND hWnd,DWORD dwCoopLevel=DSSCL_NORMAL);
static CGameEngine_SoundManager* GetSoundManager(){return m_pSoundManager;}
inline IDirectSound8* GetDirectSound(){return m_pDirectSound;}
bool SetPrimaryBufferFormat(WORD wChannels=1,DWORD dwSamplesPerSec=22050,WORD wBitsPerSample=16);
};
class CGameEngine_Sound{
private:
IDirectSoundBuffer8 *m_pDirectSoundBuf8;
bool GetSecondaryBuffer(FILE* fp);
bool LoadDataInBuffer(FILE* fp);
public:
CGameEngine_Sound();
~CGameEngine_Sound();
bool LoadWaveFile(TCHAR* szWaveFile);
bool Play(bool bLoop);
bool SetVolume(long lVolume=DSBVOLUME_MAX);
bool Stop();
};
#endif