DirectSound.h
上传用户:wymy58
上传日期:2007-01-07
资源大小:2086k
文件大小:3k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. // Copyright (C) 1998-1999 DXGuide.  All Rights Reserved.
  2. // File: DirectSound.h
  3. #ifndef _DIRECTSOUND__H
  4. #define _DIRECTSOUND__H
  5. #if _MSC_VER >= 1000
  6. #pragma once
  7. #endif // _MSC_VER >= 1000
  8. // turn off warnings for /W4
  9. #pragma warning(disable: 4201)
  10. #include <mmsystem.h>
  11. #pragma warning(default: 4201)
  12. #pragma warning(disable: 4201)
  13. #include <dsound.h>
  14. #pragma warning(default: 4201)
  15. class CDSDriverInfoObject;
  16. class CDSBuffer;
  17. class CWaveFile;
  18. class CDirectSound
  19. {
  20. friend class CDSBuffer;
  21. friend class CDSStreamBuffer;
  22. friend class CDS3DListener;
  23. friend class CDirectMusic;
  24. friend class CDirectXApp;
  25. public:
  26. // Flags for DSInit
  27. enum DSInitFlag
  28. {
  29. DSIF_3D = 0x00000001L,
  30. DSIF_DSSCL_NORMAL = 0x00010000L,
  31. DSIF_DSSCL_PRIORITY = 0x00020000L,
  32. DSIF_DSSCL_EXCLUSIVE = 0x00040000L,
  33. DSIF_DSSCL_WRITEPRIMARY = 0x00080000L,
  34. };
  35. enum WAVEFORMATCODE
  36. {
  37. _WAVEFORMATCODE_UNKNOWN = 0,
  38. _8000_8BIT_MONO = 8108,
  39. _8000_8BIT_STEREO = 8208,
  40. _8000_16BIT_MONO = 8116,
  41. _8000_16BIT_STEREO = 8216,
  42. _11025_8BIT_MONO = 11108,
  43. _11025_8BIT_STEREO = 11208,
  44. _11025_16BIT_MONO = 11116,
  45. _11025_16BIT_STEREO = 11216,
  46. _22050_8BIT_MONO = 22108,
  47. _22050_8BIT_STEREO = 22208,
  48. _22050_16BIT_MONO = 22116,
  49. _22050_16BIT_STEREO = 22216,
  50. _44100_8BIT_MONO = 44108,
  51. _44100_8BIT_STEREO = 44208,
  52. _44100_16BIT_MONO = 44116,
  53. _44100_16BIT_STEREO = 44216,
  54. };
  55. protected:
  56. CDirectSound(void);
  57. ~CDirectSound();
  58. protected:
  59. bool Create(HWND  hWnd, DWORD  dwDSInitFlags);
  60. protected:
  61. HRESULT CreateSoundBuffer(
  62. LPCDSBUFFERDESC  lpcDSBufferDesc,
  63. LPLPDIRECTSOUNDBUFFER  lplpDirectSoundBuffer);
  64. public:
  65. HRESULT GetCaps(DSCAPS*  pDSCaps);
  66. HRESULT Compact(void);
  67. bool SetFormat(CDirectSound::WAVEFORMATCODE  waveFormatCode);
  68. bool SetFormat(CDSBuffer*  pDSB);
  69. CDS3DListener* GetDS3DListener(void);
  70. public:
  71. bool SelectDSDriver(int  nPos);
  72. bool SelectDSDriver(const LPGUID  lpGuid);
  73. int GetDSDriverNumber(void) const;
  74. protected:
  75. bool LoadDSDriverInfoArray(void);
  76. CDSDriverInfoObject* GetSelectedDSDriverInfoObject(void) const;
  77. void AddDSDriverInfo(GUID FAR* const  lpGuid, LPCSTR  lpDriverDescription,
  78. LPCSTR  lpDriverName, DSCAPS*  pDSCaps);
  79. static BOOL CALLBACK DSEnumCallback(
  80. LPGUID  lpGuid, LPCSTR  lpstrDescription,
  81. LPCSTR  lpstrModule, LPVOID  lpContext);
  82. protected:
  83. int m_nSelectedDSDriverInfoPos;
  84. protected:
  85. LPDIRECTSOUND m_lpDS;
  86. CDSBuffer* m_pPrimaryDSB;
  87. DWORD m_dwDSInitFlags;
  88. };
  89. #include "DirectSound.inl"
  90. #endif // _DIRECTSOUND__H