www.pudn.com > audioTest.rar > Wave.h


// Wave.h: interface for the CWave class. 
//the base class for loading or saving wave files. 
// You can also build your own wave format for recording. 
 
////////////////////////////////////////////////////////////////////// 
 
#if !defined(AFX_WAVE_H__B316BF94_9928_4069_8F32_9F9569DA1843__INCLUDED_) 
#define AFX_WAVE_H__B316BF94_9928_4069_8F32_9F9569DA1843__INCLUDED_ 
 
#if _MSC_VER > 1000 
#pragma once 
#endif // _MSC_VER > 1000 
 
#include  
#pragma comment(lib,"winmm.lib") //这个务必要加上的 
#include  
#include "WaveBuffer.h" 
 
class CWave : public CObject   
{ 
	DECLARE_SERIAL(CWave) 
public: 
	//Copy or link the data buffer pBuffer of dwNumSamples samples to the  
	//internal wave data buffer 
	void SetBuffer(void *pBuffer,DWORD dwNumSamples,bool bCopy=false); 
	//Load a wave file 
	void Load(const CString &strFile); 
	//Save the current instance to a wave file 
	void Save(const CString &strFile); 
	//Return the internal buffer length in bytes 
	DWORD GetBufferLength() const; 
	//Return the internal buffer length in samples 
	DWORD GetNumSamples() const; 
	//Return a link to the internal data buffer 
	void  *GetBuffer() const; 
	//Save the current instance to a wave file 
	void Save(CFile *f); 
	//Load a wave file 
	void Load(CFile *f); 
	//return the MS Windows wave format needed for some other functions 
	WAVEFORMATEX GetFormat() const; 
	// Build a MS Windows wave format from parameters (channels, sample  
	// rate, 8 or 16 bits). 
	void BuildFormat(WORD nChannels,DWORD nFrequency,WORD nBits); 
	CWave(); 
	CWave(const CWave ©); 
	CWave & operator =(const CWave &wave); 
	virtual ~CWave(); 
	virtual void Serialize(CArchive &archive); 
private: 
	CWaveBuffer m_buffer; 
	WAVEFORMATEX m_pcmWaveFormat; 
}; 
 
#endif // !defined(AFX_WAVE_H__B316BF94_9928_4069_8F32_9F9569DA1843__INCLUDED_)