DSBuffer.h
资源名称:DXGuide.zip [点击查看]
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:4k
源码类别:
DirextX编程
开发平台:
Visual C++
- // Copyright (C) 1998-1999 DXGuide. All Rights Reserved.
- // File: DSBuffer.h
- #ifndef _DSBUFFER__H
- #define _DSBUFFER__H
- #if _MSC_VER >= 1000
- #pragma once
- #endif // _MSC_VER >= 1000
- class CWaveFile;
- class CDS3DListener;
- class CPackFileManager;
- class CDirectSound;
- enum CDirectSound::WAVEFORMATCODE;
- class CDSBuffer
- {
- friend class CDirectSound;
- friend class CDS3DListener;
- friend class CDirectMusic;
- public:
- enum DSB_FLAG2
- {
- DSB2_LOOP = 1L,
- DSB2_NO_FILE = 2L,
- };
- public:
- CDSBuffer(void);
- virtual ~CDSBuffer();
- protected:
- bool Create(CDirectSound* pDS); // primary
- public:
- virtual bool Create(CDirectSound* pDS, LPCTSTR lpszFileName,
- CPackFileManager* pPackFileManager = NULL,
- int nBuffer = 1,
- DWORD dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STATIC);
- bool Create(CDirectSound* pDS, WORD wID,
- int nBuffer = 1,
- DWORD dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STATIC);
- protected:
- bool Create(CDirectSound* pDS, CWaveFile* pWaveFile,
- int nBuffer, DWORD dwFlags);
- bool CreatePrimarySoundBuffer(void);
- virtual bool CreateSecondarySoundBuffer(void);
- protected:
- bool CreateSoundBuffer(
- DWORD dwBufSize,
- DWORD dwFreq,
- DWORD dwBitsPerSample,
- WORD wBlkAlign,
- bool bStereo);
- bool CreateSoundBuffer(DWORD dwBufSize,
- WAVEFORMATEX* pWaveFormatEX);
- public:
- void GetFormat(void);
- bool SetFormat(CDirectSound::WAVEFORMATCODE waveFormatCode);
- virtual HRESULT FillSoundDataBuffer(DWORD dwWriteBytes = 0);
- HRESULT GetCaps(LPDSBCAPS lpDSBufferCaps) const;
- protected:
- static CString FormatCodeToText(CDirectSound::WAVEFORMATCODE waveFormatCode);
- static bool FormatCodeToWFX(CDirectSound::WAVEFORMATCODE waveFormatCode, PWAVEFORMATEX pwfx);
- bool FindHighestFormat(void);
- public:
- CDirectSound::WAVEFORMATCODE CalcWaveFormatCode(PWAVEFORMATEX pwfx);
- public:
- virtual bool Play(void);
- virtual bool Stop(int nIndex = 0);
- virtual void SetLoop(bool bLoop);
- LONG GetVolume(int nIndex = 0) const;
- HRESULT SetVolume(LONG lVolume, int nIndex = 0);
- LONG GetPan(int nIndex = 0) const;
- HRESULT SetPan(LONG lPan, int nIndex = 0);
- DWORD GetFrequency(int nIndex = 0) const;
- HRESULT SetFrequency(DWORD dwFrequency, int nIndex = 0);
- public:
- // Batch parameter manipulation
- HRESULT GetAllParameters(DS3DBUFFER* pDS3DBuffer, int nIndex = 0) const;
- HRESULT SetAllParameters(const DS3DBUFFER* pDS3DBuffer, DWORD dwApply, int nIndex = 0);
- // Distance
- HRESULT GetMaxDistance(D3DVALUE* pflMaxDistance, int nIndex = 0) const;
- HRESULT SetMaxDistance(D3DVALUE pflMaxDistance, DWORD dwApply, int nIndex = 0);
- HRESULT GetMinDistance(D3DVALUE* pflMaxDistance, int nIndex = 0) const;
- HRESULT SetMinDistance(D3DVALUE pflMaxDistance, DWORD dwApply, int nIndex = 0);
- // Operation mode
- HRESULT GetMode(DWORD* dwMode, int nIndex = 0) const;
- HRESULT SetMode(DWORD dwMode, DWORD dwApply, int nIndex = 0);
- // Position
- HRESULT GetPosition(D3DVECTOR* vPosition, int nIndex = 0) const;
- HRESULT SetPosition(D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply, int nIndex = 0);
- // Sound Projection Cones
- HRESULT GetConeAngles(DWORD* dwInsideConeAngle, DWORD* dwOutsideConeAngle, int nIndex = 0) const;
- HRESULT SetConeAngles(DWORD dwInsideConeAngle, DWORD dwOutsideConeAngle, DWORD dwApply, int nIndex = 0);
- HRESULT GetConeOrientation(D3DVECTOR* vOrientation, int nIndex = 0) const;
- HRESULT SetConeOrientation(D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply, int nIndex = 0);
- HRESULT GetConeOutsideVolume(LONG* lConeOutsideVolume, int nIndex = 0) const;
- HRESULT SetConeOutsideVolume(LONG lConeOutsideVolume, DWORD dwApply, int nIndex = 0);
- // Velocity
- HRESULT GetVelocity(D3DVECTOR* vVelocity, int nIndex = 0) const;
- HRESULT SetVelocity(D3DVALUE x, D3DVALUE y, D3DVALUE z, DWORD dwApply, int nIndex = 0);
- protected:
- LPDIRECTSOUNDBUFFER GetFreeBuffer(void);
- HRESULT ReLoadSoundBuffer(void);
- public:
- #ifdef _DEBUG
- static ULONG m_ulDSBufferCounter;
- #endif // _DEBUG
- protected:
- CDirectSound* m_pDS;
- LPDIRECTSOUNDBUFFER* m_ppDSB;
- union
- {
- LPDIRECTSOUND3DBUFFER* m_ppDS3DB;
- CDS3DListener* m_pDS3DListener;
- };
- protected:
- int m_nBuffers;
- int m_nCurrent;
- union
- {
- CWaveFile* m_pWaveFile;
- WAVEFORMATEX* m_pWfxFormat;
- };
- CDirectSound::WAVEFORMATCODE m_waveFormatCode;
- DWORD m_dwDSBFlags2;
- DWORD m_dwDSBFlags;
- };
- #endif // _DSBUFFER__H