读书人

VC++ 中WAV音频文件操作,该怎么解决

发布时间: 2013-11-02 19:41:10 作者: rapoo

VC++ 中WAV音频文件操作
VC++中WAV音频文件操作的方法,谁能给一个封装好的类了,包括读写操作。
谢谢! wav
[解决办法]
头文件:

#ifndef CLASS_WAV_FILE_H_
#define CLASS_WAV_FILE_H_

#define WAVEFILE_READ 1
#define WAVEFILE_WRITE 2
#include <Windows.h>
#include <MMSystem.h>
#pragma comment(lib,"winmm.lib")

class CWaveFile
{
public:
WAVEFORMATEX* m_pwfx; // Pointer to WAVEFORMATEX structure
HMMIO m_hmmio; // MM I/O handle for the WAVE
MMCKINFO m_ck; // Multimedia RIFF chunk
MMCKINFO m_ckRiff; // Use in opening a WAVE file
DWORD m_dwSize; // The size of the wave file
MMIOINFO m_mmioinfoOut;
DWORD flag_;
BYTE* m_pbData;
BYTE* m_pbDataCur;
ULONG m_ulDataSize;
CHAR* m_pResourceBuffer;
WAVEFORMATEX wave_format_;

protected:
HRESULT ReadMMIO();
HRESULT WriteMMIO( WAVEFORMATEX *pwfxDest );

public:
CWaveFile();

~CWaveFile();

HRESULT Open(
LPTSTR filename,
DWORD flag,
UINT channels,
ULONG samples_per_sec,
UINT bits_per_sample);

HRESULT Close();

HRESULT Read( BYTE* pBuffer, DWORD dwSizeToRead, DWORD* pdwSizeRead );

HRESULT Write( UINT nSizeToWrite, BYTE* pbData, UINT* pnSizeWrote );

DWORD GetSize();

HRESULT ResetFile();

WAVEFORMATEX* GetFormat() { return m_pwfx; };
};

#endif // ! CLASS_WAV_FILE_H_



[/code]

读书人网 >VC/MFC

热点推荐