home *** CD-ROM | disk | FTP | other *** search
- #ifndef SFXSOUND_H
- #define SFXSOUND_H
-
-
- #ifndef RELEASE
- #define RELEASE(x) if(x != NULL) { x->Release(); x = NULL; }
- #endif
-
- #include "stdafx.h"
- #include "DSound.h" //Link To DXGuid.lib, DSound.lib
- #include "stdio.h"
- #include "mmsystem.h"
-
- //////////////////////////////////////////////////////////////////////////////////
- // SFXSound Class
- //////////////////////////////////////////////////////////////////////////////////
- class SFXSound
- {
- public:
- SFXSound(void);
- ~SFXSound(void);
-
- BOOL Create(HWND hwnd);
- BOOL GetCaps(void);
-
- LPDIRECTSOUND m_lpDS;
- DSCAPS m_DSCaps;
- };
-
- //////////////////////////////////////////////////////////////////////////////////
- // SFXSoundBuffer Class
- //////////////////////////////////////////////////////////////////////////////////
- class SFXSoundBuffer
- {
- public:
- SFXSoundBuffer(void);
- ~SFXSoundBuffer(void);
-
- BOOL Load(SFXSound* pDS, const char* Filename, int Num);
- BOOL Play(int Pan = 0, DWORD dwFlags = 0);
- BOOL Stop(void);
- void SetVolume(LONG Volume);
-
- private:
- BOOL LoadFromFile(void);
- BOOL CreateSoundBuffer(DWORD dwBufSize, DWORD dwFreq, DWORD dwBitsPerSample,
- DWORD dwBlkAlign, BOOL bStereo);
- BOOL ReadData(FILE* fp, DWORD dwSize, DWORD dwPos);
- LPDIRECTSOUNDBUFFER GetFreeBuffer(void);
-
- private:
- int m_nBuffers;
- int m_Current;
- const char* m_Filename;
- SFXSound* m_pDS;
- LPDIRECTSOUNDBUFFER m_lpDSB[4];
- };
-
- struct Waveheader
- {
- BYTE RIFF[4]; // "RIFF"
- DWORD dwSize; // Size of data to follow
- BYTE WAVE[4]; // "WAVE"
- BYTE fmt_[4]; // "fmt "
- DWORD dw16; // 16
- WORD wOne_0; // 1
- WORD wChnls; // Number of Channels
- DWORD dwSRate; // Sample Rate
- DWORD BytesPerSec; // Sample Rate
- WORD wBlkAlign; // 1
- WORD BitsPerSample; // Sample size
- BYTE DATA[4]; // "DATA"
- DWORD dwDSize; // Number of Samples
- };
-
- #endif