WaveFile.h
资源名称:DXGuide.zip [点击查看]
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:2k
源码类别:
DirextX编程
开发平台:
Visual C++
- // Copyright (C) 1998-1999 DXGuide. All Rights Reserved.
- // File: WaveFile.h
- #ifndef _WAVEFILE__H
- #define _WAVEFILE__H
- #if _MSC_VER >= 1000
- #pragma once
- #endif // _MSC_VER >= 1000
- // turn off warnings for /W4
- #pragma warning(disable: 4201)
- #include <mmsystem.h>
- #pragma warning(default: 4201)
- class CPackFileManager;
- class CWaveFile
- {
- public:
- CWaveFile(void);
- ~CWaveFile();
- public:
- bool Load(LPCTSTR lpszFilename,
- CPackFileManager* pPackFileManager = NULL, bool bLoadMem = false);
- bool Load(CFile* pFile, bool bLoadMem = false);
- bool Load(HFILE hFile, bool bLoadMem = false);
- bool LoadResource(WORD wID, bool bLoadMem = false, LPCTSTR lpType = NULL);
- protected:
- bool Load(HMMIO hmmio);
- public:
- bool Cue(void);
- UINT ReadWaveData(BYTE* pbDest, UINT cbSize);
- UINT GetNumBytesRemaining(void) const;
- UINT GetAvgDataRate(void) const;
- UINT GetBlockAlign(void) const;
- UINT GetDataSize(void) const; // size of data chunk
- UINT GetNumBytesPlayed(void) const;
- UINT GetDuration(void) const;
- WAVEFORMATEX* GetWaveFormat(void) const;
- BYTE GetSilenceData(void);
- protected:
- WAVEFORMATEX* m_pwfmt;
- BYTE* m_pWaveData;
- bool m_bLoadMem;
- HMMIO m_hmmio;
- bool m_bAutoClose;
- static const LPCTSTR m_lpcszDefaultWaveTypeName;
- MMCKINFO m_mmckiRiff;
- MMCKINFO m_mmckiFmt;
- MMCKINFO m_mmckiData;
- UINT m_nDuration; // duration of sound in msec
- UINT m_nBytesPlayed; // offset into data chunk
- protected:
- bool Create(PCMWAVEFORMAT* pFmt);
- bool Create(int nSampRate = 11025, int nSampSize = 8);
- public:
- bool SaveFile(LPCTSTR lpszFilename,
- UINT cbSize, DWORD dwSamples, BYTE* pbData);
- bool SaveFile(LPCTSTR lpszfilename, DWORD dwSamples = 0);
- protected:
- bool LoadToMem(void);
- bool CreateFile(LPCTSTR lpszFilename);
- UINT WriteFile(UINT cbWrite, BYTE* pbSrc,
- MMIOINFO* pmmioinfoOut);
- bool StartDataWrite(MMIOINFO* pmmioinfoOut);
- bool CloseWriteFile(MMIOINFO* pmmioinfoOut, DWORD dwSamples);
- };
- #include "WaveFile.inl"
- #endif // _WAVEFILE__H