⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 soundbuffer.h

📁 C人工智能游戏开发的一些实例源代码 C Game development in artificial intelligence source code of some examples
💻 H
字号:
//----------------------------------------------------------------------------------------------
// Sequential Prediction Demo: The positioning pattern
// 
// Author:  Fri Mommersteeg
// Date:    10-09-2001
// File:    SoundBuffer.h
//----------------------------------------------------------------------------------------------

#ifndef __SOUNDBUFFER_H
#define __SOUNDBUFFER_H

//----------------------------------------------------------------------------------------------
// Include files
//----------------------------------------------------------------------------------------------

#include "DirectSound.h"

//----------------------------------------------------------------------------------------------
// Defined constants
//----------------------------------------------------------------------------------------------

#define WAVEVERSION 		1
#define ER_MEM 				0xe000
#define ER_CANNOTOPEN 		0xe100
#define ER_NOTWAVEFILE 		0xe101
#define ER_CANNOTREAD 		0xe102
#define ER_CORRUPTWAVEFILE	0xe103
#define ER_CANNOTWRITE		0xe104
#define DSB_DEFAULT			0

//----------------------------------------------------------------------------------------------
// CSoundBuffer: Convenient wrapper class for a DirectSound buffer
//----------------------------------------------------------------------------------------------

class CSoundBuffer {
public:
						CSoundBuffer();
						~CSoundBuffer();

public:
	void				Create(LPDS lpds, DWORD dwBufferSize, DWORD dwFrequency = 22050, WORD nChannels = 2, WORD wBitsPerSample = 8, DWORD dwFlags = DSB_DEFAULT);
	void				CreateWave(LPDS lpds, LPSTR strWave, DWORD dwFlags = DSB_DEFAULT);
	void				CreateCopy(LPDS lpds, LPDSB lpDSB);
	void				CreateDuplicate(LPDS lpds, LPDSB lpDSB);

	void				Release();
	void				ReleaseCopy();

	void				Play(BOOL bLooping = FALSE);
	void				Stop();
	void				Silence();

private:
	int					WaveOpenFile(TCHAR*, HMMIO *, WAVEFORMATEX **, MMCKINFO *);
	int					WaveStartDataRead(HMMIO *, MMCKINFO *, MMCKINFO *);
	int					WaveReadFile(HMMIO, UINT, BYTE *, MMCKINFO *, UINT *);
	int					WaveCloseReadFile(HMMIO *, WAVEFORMATEX **);
	int					WaveLoadFile(TCHAR*, UINT *, WAVEFORMATEX **, BYTE **);

private:
	WAVEFORMATEX *		pwfx;			  // Wave format info.
	HMMIO				hmmio;            // File handle.
	MMCKINFO			mmckinfo;         // Chunk info.
	MMCKINFO			mmckinfoParent;   // Parent chunk info.

	LPDS				lpDS;
	LPDSB				lpDSB;
};

//----------------------------------------------------------------------------------------------
#endif // __SOUNDBUFFER_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -