2
0

DSoundManager.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #ifndef __DSOUNDMANAGER_H__
  2. #define __DSOUNDMANAGER_H__
  3. #include <dsound.h>
  4. #include "BFSound.h"
  5. namespace Beefy
  6. {
  7. class DSoundInstance;
  8. class DSoundManager : public BFSoundManager
  9. {
  10. friend class DSoundInstance;
  11. friend class DSoundMusicInterface;
  12. protected:
  13. LPDIRECTSOUNDBUFFER mSourceSounds[MAX_SOURCE_SOUNDS];
  14. String mSourceFileNames[MAX_SOURCE_SOUNDS];
  15. LPDIRECTSOUNDBUFFER mPrimaryBuffer;
  16. int32 mSourceDataSizes[MAX_SOURCE_SOUNDS];
  17. float mBaseVolumes[MAX_SOURCE_SOUNDS];
  18. int mBasePans[MAX_SOURCE_SOUNDS];
  19. DSoundInstance* mPlayingSounds[MAX_CHANNELS];
  20. float mMasterVolume;
  21. DWORD mLastReleaseTick;
  22. protected:
  23. int FindFreeChannel();
  24. int VolumeToDB(float theVolume);
  25. bool LoadWAVSound(unsigned int theSfxID, const StringImpl& theFilename);
  26. void ReleaseFreeChannels();
  27. public:
  28. LPDIRECTSOUND mDirectSound;
  29. DSoundManager(HWND theHWnd);
  30. virtual ~DSoundManager();
  31. virtual bool Initialized() override;
  32. virtual bool LoadSound(unsigned int theSfxID, const StringImpl& theFilename) override;
  33. virtual int LoadSound(const StringImpl& theFilename) override;
  34. virtual void ReleaseSound(unsigned int theSfxID) override;
  35. virtual void SetVolume(float theVolume) override;
  36. virtual bool SetBaseVolume(unsigned int theSfxID, float theBaseVolume) override;
  37. virtual bool SetBasePan(unsigned int theSfxID, int theBasePan) override;
  38. virtual BFSoundInstance* GetSoundInstance(unsigned int theSfxID);
  39. virtual void ReleaseSounds() override;
  40. virtual void ReleaseChannels() override;
  41. virtual float GetMasterVolume() override;
  42. virtual void SetMasterVolume(float theVolume) override;
  43. virtual void Flush() override;
  44. virtual void SetCooperativeWindow(HWND theHWnd, bool isWindowed);
  45. virtual void StopAllSounds() override;
  46. virtual int GetFreeSoundId() override;
  47. virtual int GetNumSounds() override;
  48. };
  49. }
  50. #endif //__DSOUNDMANAGER_H__