Audio.h
上传用户:hkb425
上传日期:2007-06-16
资源大小:34191k
文件大小:2k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. // Audio.h: interface for the CAudio class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_AUDIO_H__C59411DC_4F55_40AF_945A_7157AAE6F15B__INCLUDED_)
  5. #define AFX_AUDIO_H__C59411DC_4F55_40AF_945A_7157AAE6F15B__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include <dmusicc.h>
  10. #include <dmusici.h>
  11. #include "audiodef.h"
  12. #include "structdef.h"
  13. class CAudioSegment  
  14. {
  15. public:
  16. LPDIRECTMUSICSEGMENT8  dmSegment;
  17. LPDIRECTCSound3DBUFFER ds3DBuffer;
  18. bool                   is3DSound;
  19. VERTEX                *vPosition;
  20. void Set3DPos(VERTEX *pos);
  21. void Set3DDistances(float minDistance, float maxDistance);
  22. void Shutdown(void);
  23. CAudioSegment() : dmSegment(NULL),  ds3DBuffer(NULL), 
  24.               is3DSound(false) , vPosition(NULL)
  25. { }
  26. ~CAudioSegment() 
  27. { }
  28. };
  29. class CAudio  
  30. {
  31. public:
  32.     CAudio();
  33. virtual ~CAudio();
  34. static void DeleteSound(unsigned int NumOfSound);
  35. static bool CreateSound(unsigned int NumOfSound, char* filename, bool is3DSound);
  36. static void Play(unsigned int NumOfSound,DWORD numRepeats, bool bPrimary ,bool bCheckOlyOne=true);
  37.     static bool CheckSoundPlaying(unsigned int NumOfSound);
  38.     static int  GetSoundState(unsigned int NumOfSound);
  39. static void Stop(unsigned int NumOfSound);
  40. static void StopAll();
  41. static void SetVolume(int fVolume);
  42. static bool SetAudioActive(bool bActiveAudio);
  43. static bool IsAudioActive();
  44. static bool IsAudioEnable();
  45. static void SetSoundPos(unsigned int NumOfSound,VERTEX *pos);
  46. static void SetListenerPos(VERTEX *pos,float roty);
  47. static void SetSoundRolloff(float rolloff);
  48. static VERTEX GetTransformSoundPos(VERTEX *vSoundPos);
  49. //private:
  50. static bool InitAudio();
  51.     static void ReleaseAudio(void);
  52. static LPDIRECTMUSICLOADER8      dmLoader; // the loader
  53. static LPDIRECTMUSICPERFORMANCE8 dmPerformance; // the performance
  54. static LPDIRECTMUSICAUDIOPATH    dm3DAudioPath; // the audiopath
  55.     //////////////////////////////////
  56. static CAudioSegment  *pSound;
  57. static char           *pSoundState;
  58. static VERTEX          vListenerPos;
  59. static float           froty;
  60. static bool            bActive;
  61. static bool            bEnable;
  62. static int             m_numUser;
  63. };
  64. #endif // !defined(AFX_AUDIO_H__C59411DC_4F55_40AF_945A_7157AAE6F15B__INCLUDED_)