audio.h
上传用户:May-22
上传日期:2015-07-19
资源大小:7113k
文件大小:2k
源码类别:

DirextX编程

开发平台:

Visual C++

  1. //--------------------------------------------------------------------------------------
  2. // File: audio.h
  3. //
  4. // XNA Developer Connection
  5. // Copyright (c) Microsoft Corporation. All rights reserved.
  6. //--------------------------------------------------------------------------------------
  7. #include <xaudio2.h>
  8. #include <xaudio2fx.h>
  9. #include <x3daudio.h>
  10. //-----------------------------------------------------------------------------
  11. // Global defines
  12. //-----------------------------------------------------------------------------
  13. #define INPUTCHANNELS 1
  14. #define OUTPUTCHANNELS 8
  15. #define NUM_PRESETS 30
  16. // Constants to define our world space
  17. const INT XMIN = -10;
  18. const INT XMAX = 10;
  19. const INT ZMIN = -10;
  20. const INT ZMAX = 10;
  21. //-----------------------------------------------------------------------------
  22. // Struct to hold audio game state
  23. //-----------------------------------------------------------------------------
  24. struct AUDIO_STATE
  25. {
  26.     bool bInitialized;
  27.     // XAudio2
  28.     IXAudio2*               pXAudio2;
  29.     IXAudio2MasteringVoice* pMasteringVoice;
  30.     IXAudio2SourceVoice*    pSourceVoice;
  31.     IXAudio2SubmixVoice*    pSubmixVoice;
  32.     IUnknown*               pReverbEffect;
  33.     BYTE*                   pbSampleData;
  34.     // 3D
  35.     X3DAUDIO_HANDLE         x3DInstance;
  36.     int                     nFrameToApply3DAudio;
  37.     DWORD                   dwChannelMask;
  38.     UINT32                  nChannels;
  39.     X3DAUDIO_DSP_SETTINGS   dspSettings;
  40.     X3DAUDIO_LISTENER       listener;
  41.     X3DAUDIO_EMITTER        emitter;
  42.     X3DAUDIO_CONE           emitterCone;
  43.     D3DXVECTOR3             vListenerPos;
  44.     D3DXVECTOR3             vEmitterPos;
  45.     float                   fListenerAngle;
  46.     FLOAT32 emitterAzimuths[INPUTCHANNELS];
  47.     FLOAT32 matrixCoefficients[INPUTCHANNELS * OUTPUTCHANNELS];
  48. };
  49. //--------------------------------------------------------------------------------------
  50. // Global variables
  51. //--------------------------------------------------------------------------------------
  52. extern AUDIO_STATE g_audioState;
  53. //--------------------------------------------------------------------------------------
  54. // External functions
  55. //--------------------------------------------------------------------------------------
  56. HRESULT InitAudio();
  57. HRESULT PrepareAudio( const LPWSTR wavname );
  58. HRESULT UpdateAudio( float fElapsedTime );
  59. HRESULT SetReverb( int nReverb );
  60. VOID PauseAudio( bool resume );
  61. VOID CleanupAudio();