#ifndef __XAUDIO2_C_API_ESSENTIALS_H__
#define __XAUDIO2_C_API_ESSENTIALS_H__

#include <windows.h>
#include <ole2.h>

// audiosessiontypes.h
typedef enum _AUDIO_STREAM_CATEGORY {
  AudioCategory_Other = 0,
  AudioCategory_ForegroundOnlyMedia,
  AudioCategory_BackgroundCapableMedia,
  AudioCategory_Communications,
  AudioCategory_Alerts,
  AudioCategory_SoundEffects,
  AudioCategory_GameEffects,
  AudioCategory_GameMedia,
  AudioCategory_GameChat,
  AudioCategory_Speech,
  AudioCategory_Movie,
  AudioCategory_Media
} AUDIO_STREAM_CATEGORY;

// mmreg.h
#ifndef _WAVEFORMATEXTENSIBLE_
#define _WAVEFORMATEXTENSIBLE_
  typedef struct {
    WAVEFORMATEX Format;
    union {
      WORD wValidBitsPerSample;
      WORD wSamplesPerBlock;
      WORD wReserved;
    } Samples;
    DWORD dwChannelMask;

    GUID SubFormat;
  } WAVEFORMATEXTENSIBLE,*PWAVEFORMATEXTENSIBLE;
#endif


#ifndef __IXAudio2EngineCallback_FWD_DEFINED__
#define __IXAudio2EngineCallback_FWD_DEFINED__
typedef interface IXAudio2EngineCallback IXAudio2EngineCallback;
#endif

#ifndef __IXAudio2Voice_FWD_DEFINED__
#define __IXAudio2Voice_FWD_DEFINED__
typedef interface IXAudio2Voice IXAudio2Voice;
#endif

#ifndef __IXAudio2SourceVoice_FWD_DEFINED__
#define __IXAudio2SourceVoice_FWD_DEFINED__
typedef interface IXAudio2SourceVoice IXAudio2SourceVoice;
#endif

#ifndef __IXAudio2SubmixVoice_FWD_DEFINED__
#define __IXAudio2SubmixVoice_FWD_DEFINED__
typedef interface IXAudio2SubmixVoice IXAudio2SubmixVoice;
#endif

#ifndef __IXAudio2MasteringVoice_FWD_DEFINED__
#define __IXAudio2MasteringVoice_FWD_DEFINED__
typedef interface IXAudio2MasteringVoice IXAudio2MasteringVoice;
#endif

#ifndef __IXAudio2VoiceCallback_FWD_DEFINED__
#define __IXAudio2VoiceCallback_FWD_DEFINED__
typedef interface IXAudio2VoiceCallback IXAudio2VoiceCallback;
#endif

#ifndef __IXAudio2_FWD_DEFINED__
#define __IXAudio2_FWD_DEFINED__
typedef interface IXAudio2 IXAudio2;
#endif

#ifndef __IXAudio2Voice_FWD_DEFINED__
#define __IXAudio2Voice_FWD_DEFINED__
typedef interface IXAudio2Voice IXAudio2Voice;
#endif

typedef enum XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER {
    Processor1 = 0x1,
    Processor2 = 0x2,
    Processor3 = 0x4,
    Processor4 = 0x8,
    Processor5 = 0x10,
    Processor6 = 0x20,
    Processor7 = 0x40,
    Processor8 = 0x80,
    Processor9 = 0x100,
    Processor10 = 0x200,
    Processor11 = 0x400,
    Processor12 = 0x800,
    Processor13 = 0x1000,
    Processor14 = 0x2000,
    Processor15 = 0x4000,
    Processor16 = 0x8000,
    Processor17 = 0x10000,
    Processor18 = 0x20000,
    Processor19 = 0x40000,
    Processor20 = 0x80000,
    Processor21 = 0x100000,
    Processor22 = 0x200000,
    Processor23 = 0x400000,
    Processor24 = 0x800000,
    Processor25 = 0x1000000,
    Processor26 = 0x2000000,
    Processor27 = 0x4000000,
    Processor28 = 0x8000000,
    Processor29 = 0x10000000,
    Processor30 = 0x20000000,
    Processor31 = 0x40000000,
    Processor32 = 0x80000000,
    XAUDIO2_ANY_PROCESSOR = 0xffffffff,
    XAUDIO2_DEFAULT_PROCESSOR = XAUDIO2_ANY_PROCESSOR
} XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER;
typedef enum XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER XAUDIO2_PROCESSOR;
typedef struct XAUDIO2_PERFORMANCE_DATA {
    UINT64 AudioCyclesSinceLastQuery;
    UINT64 TotalCyclesSinceLastQuery;
    UINT32 MinimumCyclesPerQuantum;
    UINT32 MaximumCyclesPerQuantum;
    UINT32 MemoryUsageInBytes;
    UINT32 CurrentLatencyInSamples;
    UINT32 GlitchesSinceEngineStarted;
    UINT32 ActiveSourceVoiceCount;
    UINT32 TotalSourceVoiceCount;
    UINT32 ActiveSubmixVoiceCount;
    UINT32 ActiveResamplerCount;
    UINT32 ActiveMatrixMixCount;
    UINT32 ActiveXmaSourceVoices;
    UINT32 ActiveXmaStreams;
} XAUDIO2_PERFORMANCE_DATA;
typedef struct XAUDIO22_PERFORMANCE_DATA {
    UINT64 AudioCyclesSinceLastQuery;
    UINT64 TotalCyclesSinceLastQuery;
    UINT32 MinimumCyclesPerQuantum;
    UINT32 MaximumCyclesPerQuantum;
    UINT32 MemoryUsageInBytes;
    UINT32 CurrentLatencyInSamples;
    UINT32 GlitchesSinceEngineStarted;
    UINT32 ActiveSourceVoiceCount;
    UINT32 TotalSourceVoiceCount;
    UINT32 ActiveSubmixVoiceCount;
    UINT32 TotalSubmixVoiceCount;
    UINT32 ActiveXmaSourceVoices;
    UINT32 ActiveXmaStreams;
} XAUDIO22_PERFORMANCE_DATA;
typedef struct XAUDIO20_PERFORMANCE_DATA {
    UINT64 AudioCyclesSinceLastQuery;
    UINT64 TotalCyclesSinceLastQuery;
    UINT32 MinimumCyclesPerQuantum;
    UINT32 MaximumCyclesPerQuantum;
    UINT32 MemoryUsageInBytes;
    UINT32 CurrentLatencyInSamples;
    UINT32 GlitchesSinceLastQuery;
    UINT32 ActiveSourceVoiceCount;
    UINT32 TotalSourceVoiceCount;
    UINT32 ActiveSubmixVoiceCount;
    UINT32 TotalSubmixVoiceCount;
    UINT32 ActiveXmaSourceVoices;
    UINT32 ActiveXmaStreams;
} XAUDIO20_PERFORMANCE_DATA;
typedef enum XAUDIO2_DEVICE_ROLE {
    NotDefaultDevice = 0x0,
    DefaultConsoleDevice = 0x1,
    DefaultMultimediaDevice = 0x2,
    DefaultCommunicationsDevice = 0x4,
    DefaultGameDevice = 0x8,
    GlobalDefaultDevice = 0xf,
    InvalidDeviceRole = ~GlobalDefaultDevice
} XAUDIO2_DEVICE_ROLE;
typedef struct XAUDIO2_DEVICE_DETAILS {
    WCHAR DeviceID[256];
    WCHAR DisplayName[256];
    XAUDIO2_DEVICE_ROLE Role;
    WAVEFORMATEXTENSIBLE OutputFormat;
} XAUDIO2_DEVICE_DETAILS;
typedef struct XAUDIO27_VOICE_DETAILS {
    UINT32 CreationFlags;
    UINT32 InputChannels;
    UINT32 InputSampleRate;
} XAUDIO27_VOICE_DETAILS;
typedef struct XAUDIO2_VOICE_DETAILS {
    UINT32 CreationFlags;
    UINT32 ActiveFlags;
    UINT32 InputChannels;
    UINT32 InputSampleRate;
} XAUDIO2_VOICE_DETAILS;
typedef struct XAUDIO2_SEND_DESCRIPTOR {
    UINT32 Flags;
    IXAudio2Voice *pOutputVoice;
} XAUDIO2_SEND_DESCRIPTOR;
typedef struct XAUDIO23_VOICE_SENDS {
    UINT32 OutputCount;
    IXAudio2Voice **pOutputVoices;
} XAUDIO23_VOICE_SENDS;
typedef struct XAUDIO2_VOICE_SENDS {
    UINT32 SendCount;
    XAUDIO2_SEND_DESCRIPTOR *pSends;
} XAUDIO2_VOICE_SENDS;
typedef struct XAUDIO2_EFFECT_DESCRIPTOR {
    IUnknown *pEffect;
    WINBOOL InitialState;
    UINT32 OutputChannels;
} XAUDIO2_EFFECT_DESCRIPTOR;
typedef struct XAUDIO2_EFFECT_CHAIN {
    UINT32 EffectCount;
    XAUDIO2_EFFECT_DESCRIPTOR *pEffectDescriptors;
} XAUDIO2_EFFECT_CHAIN;
#define XAUDIO2_MAX_BUFFER_BYTES (0x80000000)

#define XAUDIO2_MAX_QUEUED_BUFFERS (64)

#define XAUDIO2_MAX_BUFFERS_SYSTEM (2)

#define XAUDIO2_MAX_AUDIO_CHANNELS (64)

#define XAUDIO2_MIN_SAMPLE_RATE (1000)

#define XAUDIO2_MAX_SAMPLE_RATE (200000)

#define XAUDIO2_MAX_VOLUME_LEVEL (16777216.0000000)

#define XAUDIO2_MIN_FREQ_RATIO (1 / 1024.00000000000)

#define XAUDIO2_MAX_FREQ_RATIO (1024.00000000000)

#define XAUDIO2_DEFAULT_FREQ_RATIO (2.00000000000000)

#define XAUDIO2_MAX_FILTER_ONEOVERQ (1.50000000000000)

#define XAUDIO2_MAX_FILTER_FREQUENCY (1.00000000000000)

#define XAUDIO2_MAX_LOOP_COUNT (254)

#define XAUDIO20_MAX_LOOP_COUNT (0x100000)

#define XAUDIO2_COMMIT_NOW (0)

#define XAUDIO2_COMMIT_ALL (0)

#define XAUDIO2_INVALID_OPSET (0xffffffff)

#define XAUDIO2_NO_LOOP_REGION (0)

#define XAUDIO2_LOOP_INFINITE (255)

#define XAUDIO20_LOOP_INFINITE ((UINT)-1)

#define XAUDIO2_DEFAULT_CHANNELS (0)

#define XAUDIO2_DEFAULT_SAMPLERATE (0)


typedef struct IXAudio2EngineCallbackVtbl {
    BEGIN_INTERFACE

    /*** IXAudio2EngineCallback methods ***/
    void (STDMETHODCALLTYPE *OnProcessingPassStart)(
        IXAudio2EngineCallback *This);

    void (STDMETHODCALLTYPE *OnProcessingPassEnd)(
        IXAudio2EngineCallback *This);

    void (STDMETHODCALLTYPE *OnCriticalError)(
        IXAudio2EngineCallback *This,
        HRESULT Error);

    END_INTERFACE
} IXAudio2EngineCallbackVtbl;

interface IXAudio2EngineCallback {
    CONST_VTBL IXAudio2EngineCallbackVtbl* lpVtbl;
};


typedef enum XAUDIO2_FILTER_TYPE {
    LowPassFilter = 0,
    BandPassFilter = 1,
    HighPassFilter = 2,
    NotchFilter = 3
} XAUDIO2_FILTER_TYPE;
typedef struct XAUDIO2_FILTER_PARAMETERS {
    XAUDIO2_FILTER_TYPE Type;
    float Frequency;
    float OneOverQ;
} XAUDIO2_FILTER_PARAMETERS;


typedef struct IXAudio2VoiceVtbl {
    BEGIN_INTERFACE

    /*** IXAudio2Voice methods ***/
    void (STDMETHODCALLTYPE *GetVoiceDetails)(
        IXAudio2Voice *This,
        XAUDIO2_VOICE_DETAILS *pVoiceDetails);

    HRESULT (STDMETHODCALLTYPE *SetOutputVoices)(
        IXAudio2Voice *This,
        const XAUDIO2_VOICE_SENDS *pSendList);

    HRESULT (STDMETHODCALLTYPE *SetEffectChain)(
        IXAudio2Voice *This,
        const XAUDIO2_EFFECT_CHAIN *pEffectChain);

    HRESULT (STDMETHODCALLTYPE *EnableEffect)(
        IXAudio2Voice *This,
        UINT32 EffectIndex,
        UINT32 OperationSet);

    HRESULT (STDMETHODCALLTYPE *DisableEffect)(
        IXAudio2Voice *This,
        UINT32 EffectIndex,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetEffectState)(
        IXAudio2Voice *This,
        UINT32 EffectIndex,
        WINBOOL *pEnabled);

    HRESULT (STDMETHODCALLTYPE *SetEffectParameters)(
        IXAudio2Voice *This,
        UINT32 EffectIndex,
        const void *pParameters,
        UINT32 ParametersByteSize,
        UINT32 OperationSet);

    HRESULT (STDMETHODCALLTYPE *GetEffectParameters)(
        IXAudio2Voice *This,
        UINT32 EffectIndex,
        void *pParameters,
        UINT32 ParametersByteSize);

    HRESULT (STDMETHODCALLTYPE *SetFilterParameters)(
        IXAudio2Voice *This,
        const XAUDIO2_FILTER_PARAMETERS *pParameters,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetFilterParameters)(
        IXAudio2Voice *This,
        XAUDIO2_FILTER_PARAMETERS *pParameters);

    HRESULT (STDMETHODCALLTYPE *SetOutputFilterParameters)(
        IXAudio2Voice *This,
        IXAudio2Voice *pDestinationVoice,
        const XAUDIO2_FILTER_PARAMETERS *pParameters,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetOutputFilterParameters)(
        IXAudio2Voice *This,
        IXAudio2Voice *pDestinationVoice,
        XAUDIO2_FILTER_PARAMETERS *pParameters);

    HRESULT (STDMETHODCALLTYPE *SetVolume)(
        IXAudio2Voice *This,
        float Volume,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetVolume)(
        IXAudio2Voice *This,
        float *pVolume);

    HRESULT (STDMETHODCALLTYPE *SetChannelVolumes)(
        IXAudio2Voice *This,
        UINT32 Channels,
        const float *pVolumes,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetChannelVolumes)(
        IXAudio2Voice *This,
        UINT32 Channels,
        float *pVolumes);

    HRESULT (STDMETHODCALLTYPE *SetOutputMatrix)(
        IXAudio2Voice *This,
        IXAudio2Voice *pDestinationVoice,
        UINT32 SourceChannels,
        UINT32 DestinationChannels,
        const float *pLevelMatrix,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetOutputMatrix)(
        IXAudio2Voice *This,
        IXAudio2Voice *pDestinationVoice,
        UINT32 SourceChannels,
        UINT32 DestinationChannels,
        float *pLevelMatrix);

    void (STDMETHODCALLTYPE *DestroyVoice)(
        IXAudio2Voice *This);

    END_INTERFACE
} IXAudio2VoiceVtbl;

interface IXAudio2Voice {
    CONST_VTBL IXAudio2VoiceVtbl* lpVtbl;
};


typedef struct XAUDIO2_BUFFER {
    UINT32 Flags;
    UINT32 AudioBytes;
    const BYTE *pAudioData;
    UINT32 PlayBegin;
    UINT32 PlayLength;
    UINT32 LoopBegin;
    UINT32 LoopLength;
    UINT32 LoopCount;
    void *pContext;
} XAUDIO2_BUFFER;
typedef struct XAUDIO2_BUFFER_WMA {
    const UINT32 *pDecodedPacketCumulativeBytes;
    UINT32 PacketCount;
} XAUDIO2_BUFFER_WMA;
typedef struct XAUDIO2_VOICE_STATE {
    void *pCurrentBufferContext;
    UINT32 BuffersQueued;
    UINT64 SamplesPlayed;
} XAUDIO2_VOICE_STATE;


typedef struct IXAudio2SourceVoiceVtbl {
    BEGIN_INTERFACE

    /*** IXAudio2Voice methods ***/
    void (STDMETHODCALLTYPE *GetVoiceDetails)(
        IXAudio2SourceVoice *This,
        XAUDIO2_VOICE_DETAILS *pVoiceDetails);

    HRESULT (STDMETHODCALLTYPE *SetOutputVoices)(
        IXAudio2SourceVoice *This,
        const XAUDIO2_VOICE_SENDS *pSendList);

    HRESULT (STDMETHODCALLTYPE *SetEffectChain)(
        IXAudio2SourceVoice *This,
        const XAUDIO2_EFFECT_CHAIN *pEffectChain);

    HRESULT (STDMETHODCALLTYPE *EnableEffect)(
        IXAudio2SourceVoice *This,
        UINT32 EffectIndex,
        UINT32 OperationSet);

    HRESULT (STDMETHODCALLTYPE *DisableEffect)(
        IXAudio2SourceVoice *This,
        UINT32 EffectIndex,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetEffectState)(
        IXAudio2SourceVoice *This,
        UINT32 EffectIndex,
        WINBOOL *pEnabled);

    HRESULT (STDMETHODCALLTYPE *SetEffectParameters)(
        IXAudio2SourceVoice *This,
        UINT32 EffectIndex,
        const void *pParameters,
        UINT32 ParametersByteSize,
        UINT32 OperationSet);

    HRESULT (STDMETHODCALLTYPE *GetEffectParameters)(
        IXAudio2SourceVoice *This,
        UINT32 EffectIndex,
        void *pParameters,
        UINT32 ParametersByteSize);

    HRESULT (STDMETHODCALLTYPE *SetFilterParameters)(
        IXAudio2SourceVoice *This,
        const XAUDIO2_FILTER_PARAMETERS *pParameters,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetFilterParameters)(
        IXAudio2SourceVoice *This,
        XAUDIO2_FILTER_PARAMETERS *pParameters);

    HRESULT (STDMETHODCALLTYPE *SetOutputFilterParameters)(
        IXAudio2SourceVoice *This,
        IXAudio2Voice *pDestinationVoice,
        const XAUDIO2_FILTER_PARAMETERS *pParameters,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetOutputFilterParameters)(
        IXAudio2SourceVoice *This,
        IXAudio2Voice *pDestinationVoice,
        XAUDIO2_FILTER_PARAMETERS *pParameters);

    HRESULT (STDMETHODCALLTYPE *SetVolume)(
        IXAudio2SourceVoice *This,
        float Volume,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetVolume)(
        IXAudio2SourceVoice *This,
        float *pVolume);

    HRESULT (STDMETHODCALLTYPE *SetChannelVolumes)(
        IXAudio2SourceVoice *This,
        UINT32 Channels,
        const float *pVolumes,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetChannelVolumes)(
        IXAudio2SourceVoice *This,
        UINT32 Channels,
        float *pVolumes);

    HRESULT (STDMETHODCALLTYPE *SetOutputMatrix)(
        IXAudio2SourceVoice *This,
        IXAudio2Voice *pDestinationVoice,
        UINT32 SourceChannels,
        UINT32 DestinationChannels,
        const float *pLevelMatrix,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetOutputMatrix)(
        IXAudio2SourceVoice *This,
        IXAudio2Voice *pDestinationVoice,
        UINT32 SourceChannels,
        UINT32 DestinationChannels,
        float *pLevelMatrix);

    void (STDMETHODCALLTYPE *DestroyVoice)(
        IXAudio2SourceVoice *This);

    /*** IXAudio2SourceVoice methods ***/
    HRESULT (STDMETHODCALLTYPE *Start)(
        IXAudio2SourceVoice *This,
        UINT32 Flags,
        UINT32 OperationSet);

    HRESULT (STDMETHODCALLTYPE *Stop)(
        IXAudio2SourceVoice *This,
        UINT32 Flags,
        UINT32 OperationSet);

    HRESULT (STDMETHODCALLTYPE *SubmitSourceBuffer)(
        IXAudio2SourceVoice *This,
        const XAUDIO2_BUFFER *pBuffer,
        const XAUDIO2_BUFFER_WMA *pBufferWMA);

    HRESULT (STDMETHODCALLTYPE *FlushSourceBuffers)(
        IXAudio2SourceVoice *This);

    HRESULT (STDMETHODCALLTYPE *Discontinuity)(
        IXAudio2SourceVoice *This);

    HRESULT (STDMETHODCALLTYPE *ExitLoop)(
        IXAudio2SourceVoice *This,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetState)(
        IXAudio2SourceVoice *This,
        XAUDIO2_VOICE_STATE *pVoiceState,
        UINT32 Flags);

    HRESULT (STDMETHODCALLTYPE *SetFrequencyRatio)(
        IXAudio2SourceVoice *This,
        float Ratio,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetFrequencyRatio)(
        IXAudio2SourceVoice *This,
        float *pRatio);

    HRESULT (STDMETHODCALLTYPE *SetSourceSampleRate)(
        IXAudio2SourceVoice *This,
        UINT32 NewSourceSampleRate);

    END_INTERFACE
} IXAudio2SourceVoiceVtbl;

interface IXAudio2SourceVoice {
    CONST_VTBL IXAudio2SourceVoiceVtbl* lpVtbl;
};


typedef struct IXAudio2SubmixVoiceVtbl {
    BEGIN_INTERFACE

    /*** IXAudio2Voice methods ***/
    void (STDMETHODCALLTYPE *GetVoiceDetails)(
        IXAudio2SubmixVoice *This,
        XAUDIO2_VOICE_DETAILS *pVoiceDetails);

    HRESULT (STDMETHODCALLTYPE *SetOutputVoices)(
        IXAudio2SubmixVoice *This,
        const XAUDIO2_VOICE_SENDS *pSendList);

    HRESULT (STDMETHODCALLTYPE *SetEffectChain)(
        IXAudio2SubmixVoice *This,
        const XAUDIO2_EFFECT_CHAIN *pEffectChain);

    HRESULT (STDMETHODCALLTYPE *EnableEffect)(
        IXAudio2SubmixVoice *This,
        UINT32 EffectIndex,
        UINT32 OperationSet);

    HRESULT (STDMETHODCALLTYPE *DisableEffect)(
        IXAudio2SubmixVoice *This,
        UINT32 EffectIndex,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetEffectState)(
        IXAudio2SubmixVoice *This,
        UINT32 EffectIndex,
        WINBOOL *pEnabled);

    HRESULT (STDMETHODCALLTYPE *SetEffectParameters)(
        IXAudio2SubmixVoice *This,
        UINT32 EffectIndex,
        const void *pParameters,
        UINT32 ParametersByteSize,
        UINT32 OperationSet);

    HRESULT (STDMETHODCALLTYPE *GetEffectParameters)(
        IXAudio2SubmixVoice *This,
        UINT32 EffectIndex,
        void *pParameters,
        UINT32 ParametersByteSize);

    HRESULT (STDMETHODCALLTYPE *SetFilterParameters)(
        IXAudio2SubmixVoice *This,
        const XAUDIO2_FILTER_PARAMETERS *pParameters,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetFilterParameters)(
        IXAudio2SubmixVoice *This,
        XAUDIO2_FILTER_PARAMETERS *pParameters);

    HRESULT (STDMETHODCALLTYPE *SetOutputFilterParameters)(
        IXAudio2SubmixVoice *This,
        IXAudio2Voice *pDestinationVoice,
        const XAUDIO2_FILTER_PARAMETERS *pParameters,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetOutputFilterParameters)(
        IXAudio2SubmixVoice *This,
        IXAudio2Voice *pDestinationVoice,
        XAUDIO2_FILTER_PARAMETERS *pParameters);

    HRESULT (STDMETHODCALLTYPE *SetVolume)(
        IXAudio2SubmixVoice *This,
        float Volume,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetVolume)(
        IXAudio2SubmixVoice *This,
        float *pVolume);

    HRESULT (STDMETHODCALLTYPE *SetChannelVolumes)(
        IXAudio2SubmixVoice *This,
        UINT32 Channels,
        const float *pVolumes,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetChannelVolumes)(
        IXAudio2SubmixVoice *This,
        UINT32 Channels,
        float *pVolumes);

    HRESULT (STDMETHODCALLTYPE *SetOutputMatrix)(
        IXAudio2SubmixVoice *This,
        IXAudio2Voice *pDestinationVoice,
        UINT32 SourceChannels,
        UINT32 DestinationChannels,
        const float *pLevelMatrix,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetOutputMatrix)(
        IXAudio2SubmixVoice *This,
        IXAudio2Voice *pDestinationVoice,
        UINT32 SourceChannels,
        UINT32 DestinationChannels,
        float *pLevelMatrix);

    void (STDMETHODCALLTYPE *DestroyVoice)(
        IXAudio2SubmixVoice *This);

    END_INTERFACE
} IXAudio2SubmixVoiceVtbl;

interface IXAudio2SubmixVoice {
    CONST_VTBL IXAudio2SubmixVoiceVtbl* lpVtbl;
};


typedef struct IXAudio2MasteringVoiceVtbl {
    BEGIN_INTERFACE

    /*** IXAudio2Voice methods ***/
    void (STDMETHODCALLTYPE *GetVoiceDetails)(
        IXAudio2MasteringVoice *This,
        XAUDIO2_VOICE_DETAILS *pVoiceDetails);

    HRESULT (STDMETHODCALLTYPE *SetOutputVoices)(
        IXAudio2MasteringVoice *This,
        const XAUDIO2_VOICE_SENDS *pSendList);

    HRESULT (STDMETHODCALLTYPE *SetEffectChain)(
        IXAudio2MasteringVoice *This,
        const XAUDIO2_EFFECT_CHAIN *pEffectChain);

    HRESULT (STDMETHODCALLTYPE *EnableEffect)(
        IXAudio2MasteringVoice *This,
        UINT32 EffectIndex,
        UINT32 OperationSet);

    HRESULT (STDMETHODCALLTYPE *DisableEffect)(
        IXAudio2MasteringVoice *This,
        UINT32 EffectIndex,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetEffectState)(
        IXAudio2MasteringVoice *This,
        UINT32 EffectIndex,
        WINBOOL *pEnabled);

    HRESULT (STDMETHODCALLTYPE *SetEffectParameters)(
        IXAudio2MasteringVoice *This,
        UINT32 EffectIndex,
        const void *pParameters,
        UINT32 ParametersByteSize,
        UINT32 OperationSet);

    HRESULT (STDMETHODCALLTYPE *GetEffectParameters)(
        IXAudio2MasteringVoice *This,
        UINT32 EffectIndex,
        void *pParameters,
        UINT32 ParametersByteSize);

    HRESULT (STDMETHODCALLTYPE *SetFilterParameters)(
        IXAudio2MasteringVoice *This,
        const XAUDIO2_FILTER_PARAMETERS *pParameters,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetFilterParameters)(
        IXAudio2MasteringVoice *This,
        XAUDIO2_FILTER_PARAMETERS *pParameters);

    HRESULT (STDMETHODCALLTYPE *SetOutputFilterParameters)(
        IXAudio2MasteringVoice *This,
        IXAudio2Voice *pDestinationVoice,
        const XAUDIO2_FILTER_PARAMETERS *pParameters,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetOutputFilterParameters)(
        IXAudio2MasteringVoice *This,
        IXAudio2Voice *pDestinationVoice,
        XAUDIO2_FILTER_PARAMETERS *pParameters);

    HRESULT (STDMETHODCALLTYPE *SetVolume)(
        IXAudio2MasteringVoice *This,
        float Volume,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetVolume)(
        IXAudio2MasteringVoice *This,
        float *pVolume);

    HRESULT (STDMETHODCALLTYPE *SetChannelVolumes)(
        IXAudio2MasteringVoice *This,
        UINT32 Channels,
        const float *pVolumes,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetChannelVolumes)(
        IXAudio2MasteringVoice *This,
        UINT32 Channels,
        float *pVolumes);

    HRESULT (STDMETHODCALLTYPE *SetOutputMatrix)(
        IXAudio2MasteringVoice *This,
        IXAudio2Voice *pDestinationVoice,
        UINT32 SourceChannels,
        UINT32 DestinationChannels,
        const float *pLevelMatrix,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetOutputMatrix)(
        IXAudio2MasteringVoice *This,
        IXAudio2Voice *pDestinationVoice,
        UINT32 SourceChannels,
        UINT32 DestinationChannels,
        float *pLevelMatrix);

    void (STDMETHODCALLTYPE *DestroyVoice)(
        IXAudio2MasteringVoice *This);

    /*** IXAudio2MasteringVoice methods ***/
    void (STDMETHODCALLTYPE *GetChannelMask)(
        IXAudio2MasteringVoice *This,
        DWORD *pChannelMask);

    END_INTERFACE
} IXAudio2MasteringVoiceVtbl;

interface IXAudio2MasteringVoice {
    CONST_VTBL IXAudio2MasteringVoiceVtbl* lpVtbl;
};


typedef struct IXAudio2VoiceCallbackVtbl {
    BEGIN_INTERFACE

    /*** IXAudio2VoiceCallback methods ***/
    void (STDMETHODCALLTYPE *OnVoiceProcessingPassStart)(
        IXAudio2VoiceCallback *This,
        UINT32 BytesRequired);

    void (STDMETHODCALLTYPE *OnVoiceProcessingPassEnd)(
        IXAudio2VoiceCallback *This);

    void (STDMETHODCALLTYPE *OnStreamEnd)(
        IXAudio2VoiceCallback *This);

    void (STDMETHODCALLTYPE *OnBufferStart)(
        IXAudio2VoiceCallback *This,
        void *pBufferContext);

    void (STDMETHODCALLTYPE *OnBufferEnd)(
        IXAudio2VoiceCallback *This,
        void *pBufferContext);

    void (STDMETHODCALLTYPE *OnLoopEnd)(
        IXAudio2VoiceCallback *This,
        void *pBufferContext);

    void (STDMETHODCALLTYPE *OnVoiceError)(
        IXAudio2VoiceCallback *This,
        void *pBuffercontext,
        HRESULT Error);

    END_INTERFACE
} IXAudio2VoiceCallbackVtbl;

interface IXAudio2VoiceCallback {
    /*CONST_VTBL*/ IXAudio2VoiceCallbackVtbl* lpVtbl;
};


typedef struct XAUDIO2_DEBUG_CONFIGURATION {
    UINT32 TraceMask;
    UINT32 BreakMask;
    WINBOOL LogThreadID;
    WINBOOL LogFileline;
    WINBOOL LogFunctionName;
    WINBOOL LogTiming;
} XAUDIO2_DEBUG_CONFIGURATION;

//DEFINE_GUID(IID_IXAudio2, 0x2b02e3cf, 0x2e0b, 0x4ec3, 0xbe,0x45, 0x1b,0x2a,0x3f,0xe7,0x21,0x0d);
typedef struct IXAudio2Vtbl {
    BEGIN_INTERFACE

    /*** IUnknown methods ***/
    HRESULT (STDMETHODCALLTYPE *QueryInterface)(
        IXAudio2 *This,
        REFIID riid,
        void **ppvObject);

    ULONG (STDMETHODCALLTYPE *AddRef)(
        IXAudio2 *This);

    ULONG (STDMETHODCALLTYPE *Release)(
        IXAudio2 *This);

    /*** IXAudio2 methods ***/
    HRESULT (STDMETHODCALLTYPE *RegisterForCallbacks)(
        IXAudio2 *This,
        IXAudio2EngineCallback *pCallback);

    void (STDMETHODCALLTYPE *UnregisterForCallbacks)(
        IXAudio2 *This,
        IXAudio2EngineCallback *pCallback);

    HRESULT (STDMETHODCALLTYPE *CreateSourceVoice)(
        IXAudio2 *This,
        IXAudio2SourceVoice **ppSourceVoice,
        const WAVEFORMATEX *pSourceFormat,
        UINT32 Flags,
        float MaxFrequencyRatio,
        IXAudio2VoiceCallback *pCallback,
        const XAUDIO2_VOICE_SENDS *pSendList,
        const XAUDIO2_EFFECT_CHAIN *pEffectChain);

    HRESULT (STDMETHODCALLTYPE *CreateSubmixVoice)(
        IXAudio2 *This,
        IXAudio2SubmixVoice **ppSubmixVoice,
        UINT32 InputChannels,
        UINT32 InputSampleRate,
        UINT32 Flags,
        UINT32 ProcessingStage,
        const XAUDIO2_VOICE_SENDS *pSendList,
        const XAUDIO2_EFFECT_CHAIN *pEffectChain);

    HRESULT (STDMETHODCALLTYPE *CreateMasteringVoice)(
        IXAudio2 *This,
        IXAudio2MasteringVoice **ppMasteringVoice,
        UINT32 InputChannels,
        UINT32 InputSampleRate,
        UINT32 Flags,
        LPCWSTR DeviceId,
        const XAUDIO2_EFFECT_CHAIN *pEffectChain,
        AUDIO_STREAM_CATEGORY StreamCategory);

    HRESULT (STDMETHODCALLTYPE *StartEngine)(
        IXAudio2 *This);

    void (STDMETHODCALLTYPE *StopEngine)(
        IXAudio2 *This);

    HRESULT (STDMETHODCALLTYPE *CommitChanges)(
        IXAudio2 *This,
        UINT32 OperationSet);

    void (STDMETHODCALLTYPE *GetPerformanceData)(
        IXAudio2 *This,
        XAUDIO2_PERFORMANCE_DATA *pPerfData);

    void (STDMETHODCALLTYPE *SetDebugConfiguration)(
        IXAudio2 *This,
        const XAUDIO2_DEBUG_CONFIGURATION *pDebugConfiguration,
        void *pReserved);

    END_INTERFACE
} IXAudio2Vtbl;

interface IXAudio2 {
    CONST_VTBL IXAudio2Vtbl* lpVtbl;
};

HRESULT WINAPI XAudio2Create(IXAudio2** pxaudio2, UINT32 flags, XAUDIO2_PROCESSOR processor);

#endif
