----------------------------------------
-- File : XAudio2.ads --
-- Translator:Dongfeng.Gu,2018/10/30 --
-- Mail: 515639@qq.com --
-- Progress:100% --
----------------------------------------
with win32; use win32;
with win32.rpcdce;
with win32.Objbase; use win32.Objbase;
with Interfaces.C;
with audiodefs; use audiodefs;
package XAudio2 is
subtype UINT32 is UINT;
type LPUINT32 is access all UINT32;
type LPIUNKNOWN is access all IUnknown;
type UINT64 is mod 2**64;
type LPCFLOAT is access constant FLOAT;
CLSID_XAudio2:constant win32.rpcdce.GUID:=(16#4c9b6dde#, 16#6809#, 16#46e6#, (16#a2#, 16#78#, 16#9b#, 16#6a#, 16#97#, 16#58#, 16#86#, 16#70#));
CLSID_XAudio2_Debug:constant rpcdce.GUID:=(16#715bdd1a#, 16#aa82#, 16#436b#,(16#b0#, 16#fa#, 16#6a#, 16#ce#, 16#a3#, 16#9b#, 16#d0#, 16#a1#));
IID_IXAudio2:constant rpcdce.GUID:=(16#8bcf1f58#, 16#9fe7#, 16#4583#, (16#8a#, 16#c6#, 16#e2#, 16#ad#, 16#c4#, 16#65#, 16#c8#, 16#bb#));
type IXAudio2;
type LPIXAudio2 is access all IXAudio2;
type LPLPIXAudio2 is access all LPIXAudio2;
subtype LPXAudio2 is LPIXAudio2;
subtype LPLPXAudio2 is LPLPIXAudio2;
type IXAudio2Voice;
type LPIXAudio2Voice is access all IXAudio2Voice;
type LPLPIXAudio2Voice is access all LPIXAudio2Voice;
subtype LPXAudio2Voice is LPIXAudio2Voice;
subtype LPLPXAudio2Voice is LPLPIXAudio2Voice;
type IXAudio2SourceVoice;
type LPIXAudio2SourceVoice is access all IXAudio2SourceVoice;
type LPLPIXAudio2SourceVoice is access all LPIXAudio2SourceVoice;
subtype LPXAudio2SourceVoice is LPIXAudio2SourceVoice;
subtype LPLPXAudio2SourceVoice is LPLPIXAudio2SourceVoice;
type IXAudio2SubmixVoice;
type LPIXAudio2SubmixVoice is access all IXAudio2SubmixVoice;
type LPLPIXAudio2SubmixVoice is access all LPIXAudio2SubmixVoice;
subtype LPXAudio2SubmixVoice is LPIXAudio2SubmixVoice;
subtype LPLPXAudio2SubmixVoice is LPLPIXAudio2SubmixVoice;
type IXAudio2MasteringVoice;
type LPIXAudio2MasteringVoice is access all IXAudio2MasteringVoice;
type LPLPIXAudio2MasteringVoice is access all LPIXAudio2MasteringVoice;
subtype LPXAudio2MasteringVoice is LPIXAudio2MasteringVoice;
subtype LPLPXAudio2MasteringVoice is LPLPIXAudio2MasteringVoice;
type IXAudio2EngineCallback;
type LPIXAudio2EngineCallback is access all IXAudio2EngineCallback;
type LPLPIXAudio2EngineCallback is access all LPIXAudio2EngineCallback;
subtype LPXAudio2EngineCallback is LPIXAudio2EngineCallback;
subtype LPLPXAudio2EngineCallback is LPLPIXAudio2EngineCallback;
type IXAudio2VoiceCallback;
type LPIXAudio2VoiceCallback is access all IXAudio2VoiceCallback;
type LPLPIXAudio2VoiceCallback is access all LPIXAudio2VoiceCallback;
subtype LPXAudio2VoiceCallback is LPIXAudio2VoiceCallback;
subtype LPLPXAudio2VoiceCallback is LPLPIXAudio2VoiceCallback;
XAUDIO2_MAX_BUFFER_BYTES : constant := 16#80000000#; -- Maximum bytes allowed in a source buffer;
XAUDIO2_MAX_QUEUED_BUFFERS : constant := 64; -- Maximum buffers allowed in a voice queue;
XAUDIO2_MAX_BUFFERS_SYSTEM : constant := 2; -- Maximum buffers allowed for system threads (Xbox 360 only);
XAUDIO2_MAX_AUDIO_CHANNELS : constant := 64; -- Maximum channels in an audio stream;
XAUDIO2_MIN_SAMPLE_RATE : constant := 1000; -- Minimum audio sample rate supported;
XAUDIO2_MAX_SAMPLE_RATE : constant := 200000; -- Maximum audio sample rate supported;
XAUDIO2_MAX_VOLUME_LEVEL : constant := 16777216.0; -- Maximum acceptable volume level (2^24);
XAUDIO2_MIN_FREQ_RATIO : constant := (1.0/1024.0); -- Minimum SetFrequencyRatio argument;
XAUDIO2_MAX_FREQ_RATIO : constant := 1024.0; -- Maximum MaxFrequencyRatio argument;
XAUDIO2_DEFAULT_FREQ_RATIO : constant := 2.0; -- Default MaxFrequencyRatio argument;
XAUDIO2_MAX_FILTER_ONEOVERQ : constant := 1.5; -- Maximum XAUDIO2_FILTER_PARAMETERS.OneOverQ;
XAUDIO2_MAX_FILTER_FREQUENCY : constant := 1.0; -- Maximum XAUDIO2_FILTER_PARAMETERS.Frequency;
XAUDIO2_MAX_LOOP_COUNT : constant := 254; -- Maximum non-infinite XAUDIO2_BUFFER.LoopCount;
XAUDIO2_MAX_INSTANCES : constant := 8; -- Maximum simultaneous XAudio2 objects on Xbox 360;
XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MONO : constant := 600000;
XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MULTICHANNEL : constant := 300000;
XAUDIO2_COMMIT_NOW : constant := 0; -- Used as an OperationSet argument;
XAUDIO2_COMMIT_ALL : constant := 0; -- Used in IXAudio2::CommitChanges;
XAUDIO2_INVALID_OPSET : constant := 16#ffff_ffff#; -- Not allowed for OperationSet arguments;
XAUDIO2_NO_LOOP_REGION : constant := 0; -- Used in XAUDIO2_BUFFER.LoopCount;
XAUDIO2_LOOP_INFINITE : constant := 255; -- Used in XAUDIO2_BUFFER.LoopCount;
XAUDIO2_DEFAULT_CHANNELS : constant := 0; -- Used in CreateMasteringVoice;
XAUDIO2_DEFAULT_SAMPLERATE : constant := 0; -- Used in CreateMasteringVoice;
XAUDIO2_DEBUG_ENGINE : constant := 16#0001#; -- Used in XAudio2Create on Windows only;
XAUDIO2_VOICE_NOPITCH : constant := 16#0002#; -- Used in IXAudio2::CreateSourceVoice;
XAUDIO2_VOICE_NOSRC : constant := 16#0004#; -- Used in IXAudio2::CreateSourceVoice;
XAUDIO2_VOICE_USEFILTER : constant := 16#0008#; -- Used in IXAudio2::CreateSource/SubmixVoice;
XAUDIO2_VOICE_MUSIC : constant := 16#0010#; -- Used in IXAudio2::CreateSourceVoice;
XAUDIO2_PLAY_TAILS : constant := 16#0020#; -- Used in IXAudio2SourceVoice::Stop;
XAUDIO2_END_OF_STREAM : constant := 16#0040#; -- Used in XAUDIO2_BUFFER.Flags;
XAUDIO2_SEND_USEFILTER : constant := 16#0080#; -- Used in XAUDIO2_SEND_DESCRIPTOR.Flags;
XAUDIO2_DEFAULT_FILTER_TYPE : constant := 0;
XAUDIO2_DEFAULT_FILTER_FREQUENCY : constant := XAUDIO2_MAX_FILTER_FREQUENCY;
XAUDIO2_DEFAULT_FILTER_ONEOVERQ : constant := 1.0;
XBOX_XAUDIO2_QUANTUM_NUMERATOR : constant := 2; -- On Xbox 360, XAudio2 processes audio;
XBOX_XAUDIO2_QUANTUM_DENOMINATOR : constant := 375; -- in 5.333ms chunks (= 2/375 seconds);
XAUDIO2_QUANTUM_NUMERATOR : constant := 1; -- On Windows, XAudio2 processes audio;
XAUDIO2_QUANTUM_DENOMINATOR : constant := 100; -- in 10ms chunks (= 1/100 seconds);
XAUDIO2_QUANTUM_MS : constant := (1000.0 * XAUDIO2_QUANTUM_NUMERATOR / XAUDIO2_QUANTUM_DENOMINATOR);
FACILITY_XAUDIO2 : constant := 16#896#;
XAUDIO2_E_INVALID_CALL : constant := 16#88960001#; -- An API call or one of its arguments was illegal;
XAUDIO2_E_XMA_DECODER_ERROR : constant := 16#88960002#; -- The XMA hardware suffered an unrecoverable error;
XAUDIO2_E_XAPO_CREATION_FAILED : constant := 16#88960003#; -- XAudio2 failed to initialize an XAPO effect;
XAUDIO2_E_DEVICE_INVALIDATED : constant := 16#88960004#; -- An audio device became unusable (unplugged, etc);
-- #define FWD_DECLARE(x) interface x
-- #define FWD_DECLARE(x) typedef interface x x
type XAUDIO2_XBOX_HWTHREAD_SPECIFIER is (XboxThread0,
XboxThread1,
XboxThread2,
XboxThread3,
XboxThread4,
XboxThread5
-- XAUDIO2_ANY_PROCESSOR,
--XAUDIO2_DEFAULT_PROCESSOR
);
for XAUDIO2_XBOX_HWTHREAD_SPECIFIER use (XboxThread0=>16#01#,
XboxThread1=>16#02#,
XboxThread2=>16#04#,
XboxThread3=>16#08#,
XboxThread4=>16#10#,
XboxThread5=>16#20#
);
XBOX_XAUDIO2_ANY_PROCESSOR:constant XAUDIO2_XBOX_HWTHREAD_SPECIFIER:=XboxThread4;
XBOX_XAUDIO2_DEFAULT_PROCESSOR:constant XAUDIO2_XBOX_HWTHREAD_SPECIFIER:=XBOX_XAUDIO2_ANY_PROCESSOR;
subtype XBOX_XAUDIO2_PROCESSOR is XAUDIO2_XBOX_HWTHREAD_SPECIFIER;
type XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER is (Processor1,
Processor2,
Processor3,
Processor4,
Processor5,
Processor6,
Processor7,
Processor8,
Processor9,
Processor10,
Processor11,
Processor12,
Processor13,
Processor14,
Processor15,
Processor16,
Processor17,
Processor18,
Processor19,
Processor20,
Processor21,
Processor22,
Processor23,
Processor24,
Processor25,
Processor26,
Processor27,
Processor28,
Processor29,
Processor30,
Processor31,
Processor32,
XAUDIO2_ANY_PROCESSOR
--XAUDIO2_DEFAULT_PROCESSOR
) with size=>32;
for XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER use (Processor1=>16#00000001#,
Processor2=>16#00000002#,
Processor3=>16#00000004#,
Processor4=>16#00000008#,
Processor5=>16#00000010#,
Processor6=>16#00000020#,
Processor7=>16#00000040#,
Processor8=>16#00000080#,
Processor9=>16#00000100#,
Processor10=>16#00000200#,
Processor11=>16#00000400#,
Processor12=>16#00000800#,
Processor13=>16#00001000#,
Processor14=>16#00002000#,
Processor15=>16#00004000#,
Processor16=>16#00008000#,
Processor17=>16#00010000#,
Processor18=>16#00020000#,
Processor19=>16#00040000#,
Processor20=>16#00080000#,
Processor21=>16#00100000#,
Processor22=>16#00200000#,
Processor23=>16#00400000#,
Processor24=>16#00800000#,
Processor25=>16#01000000#,
Processor26=>16#02000000#,
Processor27=>16#04000000#,
Processor28=>16#08000000#,
Processor29=>16#10000000#,
Processor30=>16#20000000#,
Processor31=>16#40000000#,
Processor32=>16#80000000#,
XAUDIO2_ANY_PROCESSOR=>16#ffffffff#
--XAUDIO2_DEFAULT_PROCESSOR=>XAUDIO2_ANY_PROCESSOR
);
XAUDIO2_DEFAULT_PROCESSOR:CONSTANT XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER:=XAUDIO2_ANY_PROCESSOR;
subtype XAUDIO2_PROCESSOR is XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER;
type XAUDIO2_DEVICE_ROLE is (NotDefaultDevice,
DefaultConsoleDevice,
DefaultMultimediaDevice,
DefaultCommunicationsDevice,
DefaultGameDevice,
GlobalDefaultDevice
--InvalidDeviceRole
);
for XAUDIO2_DEVICE_ROLE use (NotDefaultDevice=>16#0#,
DefaultConsoleDevice=>16#1#,
DefaultMultimediaDevice=>16#2#,
DefaultCommunicationsDevice=>16#4#,
DefaultGameDevice=>16#8#,
GlobalDefaultDevice=>16#f#
--InvalidDeviceRole=>GlobalDefaultDevice
);
InvalidDeviceRole:CONSTANT XAUDIO2_DEVICE_ROLE:=GlobalDefaultDevice;
type XAUDIO2_DEVICE_DETAILS is record
DeviceID: WCHAR_Array(0..256-1);
DisplayName: WCHAR_Array(0..256-1);
Role: XAUDIO2_DEVICE_ROLE;
OutputFormat: WAVEFORMATEXTENSIBLE;
end record;
type LPXAUDIO2_DEVICE_DETAILS is access all XAUDIO2_DEVICE_DETAILS;
type XAUDIO2_VOICE_DETAILS is record
CreationFlags: UINT32;
InputChannels: UINT32;
InputSampleRate: UINT32;
end record;
type LPXAUDIO2_VOICE_DETAILS is access all XAUDIO2_VOICE_DETAILS;
type XAUDIO2_SEND_DESCRIPTOR is record
Flags: UINT32;
pOutputVoice:LPIXAudio2Voice;
end record;
type LPXAUDIO2_SEND_DESCRIPTOR is access all XAUDIO2_SEND_DESCRIPTOR;
type XAUDIO2_VOICE_SENDS is record
SendCount: UINT32;
pSends:LPXAUDIO2_SEND_DESCRIPTOR;
end record;
type LPXAUDIO2_VOICE_SENDS is access all XAUDIO2_VOICE_SENDS;
type LPCXAUDIO2_VOICE_SENDS is access constant XAUDIO2_VOICE_SENDS;
type XAUDIO2_EFFECT_DESCRIPTOR is record
pEffect:LPIUnknown;
InitialState: BOOL;
OutputChannels: UINT32;
end record;
type LPXAUDIO2_EFFECT_DESCRIPTOR is access all XAUDIO2_EFFECT_DESCRIPTOR;
type XAUDIO2_EFFECT_CHAIN is record
EffectCount: UINT32;
pEffectDescriptors:LPXAUDIO2_EFFECT_DESCRIPTOR;
end record;
type LPXAUDIO2_EFFECT_CHAIN is access all XAUDIO2_EFFECT_CHAIN;
type LPCXAUDIO2_EFFECT_CHAIN is access constant XAUDIO2_EFFECT_CHAIN;
type XAUDIO2_FILTER_TYPE is (LowPassFilter,
BandPassFilter,
HighPassFilter,
NotchFilter);
type XAUDIO2_FILTER_PARAMETERS is record
Typ: XAUDIO2_FILTER_TYPE;
Frequency: float;
OneOverQ: float;
end record;
type LPXAUDIO2_FILTER_PARAMETERS is access all XAUDIO2_FILTER_PARAMETERS;
type LPCXAUDIO2_FILTER_PARAMETERS is access constant XAUDIO2_FILTER_PARAMETERS;
type XAUDIO2_BUFFER is record
Flags: UINT32;
AudioBytes: UINT32;
pAudioData:LPBYTE;
PlayBegin: UINT32;
PlayLength: UINT32;
LoopBegin: UINT32;
LoopLength: UINT32;
LoopCount: UINT32;
pContext:LPvoid;
end record;
type LPXAUDIO2_BUFFER is access all XAUDIO2_BUFFER;
type LPCXAUDIO2_BUFFER is access constant XAUDIO2_BUFFER;
type XAUDIO2_BUFFER_WMA is record
pDecodedPacketCumulativeBytes:access UINT32;
PacketCount: UINT32;
end record;
type LPXAUDIO2_BUFFER_WMA is access all XAUDIO2_BUFFER_WMA;
type LPCXAUDIO2_BUFFER_WMA is access constant XAUDIO2_BUFFER_WMA;
type XAUDIO2_VOICE_STATE is record
pCurrentBufferContext:LPvoid;
BuffersQueued: UINT32;
SamplesPlayed: UINT64;
end record;
type LPXAUDIO2_VOICE_STATE is access all XAUDIO2_VOICE_STATE;
type XAUDIO2_PERFORMANCE_DATA is record
AudioCyclesSinceLastQuery: UINT64;
TotalCyclesSinceLastQuery: UINT64;
MinimumCyclesPerQuantum: UINT32;
MaximumCyclesPerQuantum: UINT32;
MemoryUsageInBytes: UINT32;
CurrentLatencyInSamples: UINT32;
GlitchesSinceEngineStarted: UINT32;
ActiveSourceVoiceCount: UINT32;
TotalSourceVoiceCount: UINT32;
ActiveSubmixVoiceCount: UINT32;
ActiveResamplerCount: UINT32;
ActiveMatrixMixCount: UINT32;
ActiveXmaSourceVoices: UINT32;
ActiveXmaStreams: UINT32;
end record;
type LPXAUDIO2_PERFORMANCE_DATA is access all XAUDIO2_PERFORMANCE_DATA;
type XAUDIO2_DEBUG_CONFIGURATION is record
TraceMask: UINT32;
BreakMask: UINT32;
LogThreadID: BOOL;
LogFileline: BOOL;
LogFunctionName: BOOL;
LogTiming: BOOL;
end record;
type LPXAUDIO2_DEBUG_CONFIGURATION is access all XAUDIO2_DEBUG_CONFIGURATION;
type LPCXAUDIO2_DEBUG_CONFIGURATION is access constant XAUDIO2_DEBUG_CONFIGURATION;
XAUDIO2_LOG_ERRORS : constant := 16#0001#; -- For handled errors with serious effects.;
XAUDIO2_LOG_WARNINGS : constant := 16#0002#; -- For handled errors that may be recoverable.;
XAUDIO2_LOG_INFO : constant := 16#0004#; -- Informational chit-chat (e.g. state changes).;
XAUDIO2_LOG_DETAIL : constant := 16#0008#; -- More detailed chit-chat.;
XAUDIO2_LOG_API_CALLS : constant := 16#0010#; -- Public API function entries and exits.;
XAUDIO2_LOG_FUNC_CALLS : constant := 16#0020#; -- Internal function entries and exits.;
XAUDIO2_LOG_TIMING : constant := 16#0040#; -- Delays detected and other timing data.;
XAUDIO2_LOG_LOCKS : constant := 16#0080#; -- Usage of critical sections and mutexes.;
XAUDIO2_LOG_MEMORY : constant := 16#0100#; -- Memory heap usage information.;
XAUDIO2_LOG_STREAMING : constant := 16#1000#; -- Audio streaming information.;
type IXAudio2 is record
QueryInterface:access function(THIS:LPIXAudio2;riid:REFIID;ppvInterface:LPLPvoid) return HRESULT with Convention=>Stdcall;
AddRef:access function(THIS:LPIXAudio2) return ULONG with Convention=>Stdcall;
Release:access function(THIS:LPIXAudio2) return ULONG with Convention=>Stdcall;
GetDeviceCount:access function(THIS:LPIXAudio2;pCount:LPUINT32) return HRESULT with Convention=>Stdcall;
GetDeviceDetails:access function(THIS:LPIXAudio2;Index:UINT32;pDeviceDetails:LPXAUDIO2_DEVICE_DETAILS) return HRESULT with Convention=>Stdcall;
Initialize:access function(THIS:LPIXAudio2;Flags:UINT32;XAudio2Processor:XAUDIO2_PROCESSOR) return HRESULT with Convention=>Stdcall;
RegisterForCallbacks:access function(pCallback:LPIXAudio2EngineCallback) return HRESULT with Convention=>Stdcall;
UnregisterForCallbacks:access procedure(pCallback:LPIXAudio2EngineCallback) with Convention=>Stdcall;
CreateSourceVoice:access function(THIS:LPIXAudio2;ppSourceVoice:LPLPIXAudio2SourceVoice;pSourceFormat:LPCWAVEFORMATEX;Flags:UINT32;MaxFrequencyRatio:float;pCallback:LPIXAudio2VoiceCallback;pSendList:LPCXAUDIO2_VOICE_SENDS;pEffectChain:LPCXAUDIO2_EFFECT_CHAIN) return HRESULT with Convention=>Stdcall;
CreateSubmixVoice:access function(THIS:LPIXAudio2;ppSubmixVoice:LPLPIXAudio2SubmixVoice;InputChannels:UINT32;InputSampleRate:UINT32;Flags:UINT32;ProcessingStage:UINT32;pSendList:LPCXAUDIO2_VOICE_SENDS;pEffectChain:LPCXAUDIO2_EFFECT_CHAIN) return HRESULT with Convention=>Stdcall;
CreateMasteringVoice:access function(THIS:LPIXAudio2;ppMasteringVoice:LPLPIXAudio2MasteringVoice;InputChannels:UINT32;InputSampleRate:UINT32;Flags:UINT32;DeviceIndex:UINT32;pEffectChain:LPCXAUDIO2_EFFECT_CHAIN) return HRESULT with Convention=>Stdcall;
StartEngine:access function(THIS:LPIXAudio2) return HRESULT with Convention=>Stdcall;
StopEngine:access function(THIS:LPIXAudio2) return void with Convention=>Stdcall;
CommitChanges:access function(THIS:LPIXAudio2;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetPerformanceData:access procedure(THIS:LPIXAudio2;pPerfData:LPXAUDIO2_PERFORMANCE_DATA) with Convention=>Stdcall;
SetDebugConfiguration:access procedure(THIS:LPIXAudio2;pDebugConfiguration:LPCXAUDIO2_DEBUG_CONFIGURATION;pReserved:LPvoid) with Convention=>Stdcall;
end record;
type IXAudio2Voice is record
GetVoiceDetails:access procedure(THIS:LPIXAudio2Voice;pVoiceDetails:LPXAUDIO2_VOICE_DETAILS) with Convention=>Stdcall;
SetOutputVoices:access function(THIS:LPIXAudio2Voice;pSendList:LPCXAUDIO2_VOICE_SENDS) return HRESULT with Convention=>Stdcall;
SetEffectChain:access function(THIS:LPIXAudio2Voice;pEffectChain:LPCXAUDIO2_EFFECT_CHAIN) return HRESULT with Convention=>Stdcall;
EnableEffect:access function(THIS:LPIXAudio2Voice;EffectIndex:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
DisableEffect:access function(THIS:LPIXAudio2Voice;EffectIndex:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetEffectState:access procedure(THIS:LPIXAudio2Voice;EffectIndex:UINT32;pEnabled:LPBOOL) with Convention=>Stdcall;
SetEffectParameters:access function(THIS:LPIXAudio2Voice;EffectIndex:UINT32;pParameters:LPCvoid;ParametersByteSize:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetEffectParameters:access function(THIS:LPIXAudio2Voice;EffectIndex:UINT32;pParameters:LPvoid;ParametersByteSize:UINT32) return HRESULT with Convention=>Stdcall;
SetFilterParameters:access function(THIS:LPIXAudio2Voice;pParameters:LPCXAUDIO2_FILTER_PARAMETERS;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetFilterParameters:access procedure(THIS:LPIXAudio2Voice;pParameters:LPXAUDIO2_FILTER_PARAMETERS) with Convention=>Stdcall;
SetOutputFilterParameters:access function(THIS:LPIXAudio2Voice;pDestinationVoice:LPIXAudio2Voice;pParameters:LPCXAUDIO2_FILTER_PARAMETERS;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetOutputFilterParameters:access procedure(THIS:LPIXAudio2Voice;pDestinationVoice:LPIXAudio2Voice;pParameters:LPXAUDIO2_FILTER_PARAMETERS) with Convention=>Stdcall;
SetVolume:access function(THIS:LPIXAudio2Voice;Volume:float;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetVolume:access procedure(THIS:LPIXAudio2Voice;pVolume:LPfloat) with Convention=>Stdcall;
SetChannelVolumes:access function(THIS:LPIXAudio2Voice;Channels:UINT32;pVolumes:LPCfloat;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetChannelVolumes:access procedure(THIS:LPIXAudio2Voice;Channels:UINT32;pVolumes:LPfloat) with Convention=>Stdcall;
SetOutputMatrix:access function(THIS:LPIXAudio2Voice;pDestinationVoice:LPIXAudio2Voice;SourceChannels:UINT32;DestinationChannels:UINT32;pLevelMatrix:LPCfloat;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetOutputMatrix:access procedure(THIS:LPIXAudio2Voice;pDestinationVoice:LPIXAudio2Voice;SourceChannels:UINT32;DestinationChannels:UINT32;pLevelMatrix:LPfloat) with Convention=>Stdcall;
DestroyVoice:access procedure(THIS:LPIXAudio2Voice) with Convention=>Stdcall;
end record;
type IXAudio2SourceVoice is record
GetVoiceDetails:access procedure(THIS:LPIXAudio2SourceVoice;pVoiceDetails:LPXAUDIO2_VOICE_DETAILS) with Convention=>Stdcall;
SetOutputVoices:access function(THIS:LPIXAudio2SourceVoice;pSendList:LPCXAUDIO2_VOICE_SENDS) return HRESULT with Convention=>Stdcall;
SetEffectChain:access function(THIS:LPIXAudio2SourceVoice;pEffectChain:LPCXAUDIO2_EFFECT_CHAIN) return HRESULT with Convention=>Stdcall;
EnableEffect:access function(THIS:LPIXAudio2SourceVoice;EffectIndex:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
DisableEffect:access function(THIS:LPIXAudio2SourceVoice;EffectIndex:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetEffectState:access procedure(THIS:LPIXAudio2SourceVoice;EffectIndex:UINT32;pEnabled:LPBOOL) with Convention=>Stdcall;
SetEffectParameters:access function(THIS:LPIXAudio2SourceVoice;EffectIndex:UINT32;pParameters:LPCvoid;ParametersByteSize:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetEffectParameters:access function(THIS:LPIXAudio2SourceVoice;EffectIndex:UINT32;pParameters:LPvoid;ParametersByteSize:UINT32) return HRESULT with Convention=>Stdcall;
SetFilterParameters:access function(THIS:LPIXAudio2SourceVoice;pParameters:LPCXAUDIO2_FILTER_PARAMETERS;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetFilterParameters:access procedure(THIS:LPIXAudio2SourceVoice;pParameters:LPXAUDIO2_FILTER_PARAMETERS) with Convention=>Stdcall;
SetOutputFilterParameters:access function(THIS:LPIXAudio2SourceVoice;pDestinationVoice:LPIXAudio2Voice;pParameters:LPCXAUDIO2_FILTER_PARAMETERS;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetOutputFilterParameters:access procedure(THIS:LPIXAudio2SourceVoice;pDestinationVoice:LPIXAudio2Voice;pParameters:LPXAUDIO2_FILTER_PARAMETERS) with Convention=>Stdcall;
SetVolume:access function(THIS:LPIXAudio2SourceVoice;Volume:float;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetVolume:access procedure(THIS:LPIXAudio2SourceVoice;pVolume:LPfloat) with Convention=>Stdcall;
SetChannelVolumes:access function(THIS:LPIXAudio2SourceVoice;Channels:UINT32;pVolumes:LPCfloat;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetChannelVolumes:access function(THIS:LPIXAudio2SourceVoice;Channels:UINT32;pVolumes:LPfloat) return HRESULT with Convention=>Stdcall;
SetOutputMatrix:access function(THIS:LPIXAudio2SourceVoice;pDestinationVoice:LPIXAudio2Voice;SourceChannels:UINT32;DestinationChannels:UINT32;pLevelMatrix:LPCfloat;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetOutputMatrix:access procedure(THIS:LPIXAudio2SourceVoice;pDestinationVoice:LPIXAudio2Voice;SourceChannels:UINT32;DestinationChannels:UINT32;pLevelMatrix:LPfloat) with Convention=>Stdcall;
DestroyVoice:access procedure(THIS:LPIXAudio2SourceVoice) with Convention=>Stdcall;
Start:access function(THIS:LPIXAudio2SourceVoice;Flags:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
Stop:access function(THIS:LPIXAudio2SourceVoice;Flags:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
SubmitSourceBuffer:access function(THIS:LPIXAudio2SourceVoice;pBuffer:LPCXAUDIO2_BUFFER;pBufferWMA:LPCXAUDIO2_BUFFER_WMA) return HRESULT with Convention=>Stdcall;
FlushSourceBuffers:access function(THIS:LPIXAudio2SourceVoice) return HRESULT with Convention=>Stdcall;
Discontinuity:access function(THIS:LPIXAudio2SourceVoice) return HRESULT with Convention=>Stdcall;
ExitLoop:access function(THIS:LPIXAudio2SourceVoice;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetState:access procedure(THIS:LPIXAudio2SourceVoice;pVoiceState:LPXAUDIO2_VOICE_STATE) with Convention=>Stdcall;
SetFrequencyRatio:access function(THIS:LPIXAudio2SourceVoice;Ratio:float;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetFrequencyRatio:access procedure(THIS:LPIXAudio2SourceVoice;pRatio:LPfloat) with Convention=>Stdcall;
SetSourceSampleRate:access function(THIS:LPIXAudio2SourceVoice;NewSourceSampleRate:UINT32) return HRESULT with Convention=>Stdcall;
end record;
type IXAudio2SubmixVoice is record
GetVoiceDetails:access procedure(THIS:LPIXAudio2SubmixVoice;pVoiceDetails:LPXAUDIO2_VOICE_DETAILS) with Convention=>Stdcall;
SetOutputVoices:access function(THIS:LPIXAudio2SubmixVoice;pSendList:LPCXAUDIO2_VOICE_SENDS) return HRESULT with Convention=>Stdcall;
SetEffectChain:access function(THIS:LPIXAudio2SubmixVoice;pEffectChain:LPCXAUDIO2_EFFECT_CHAIN) return HRESULT with Convention=>Stdcall;
EnableEffect:access function(THIS:LPIXAudio2SubmixVoice;EffectIndex:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
DisableEffect:access function(THIS:LPIXAudio2SubmixVoice;EffectIndex:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetEffectState:access procedure(THIS:LPIXAudio2SubmixVoice;EffectIndex:UINT32;pEnabled:LPBOOL) with Convention=>Stdcall;
SetEffectParameters:access function(THIS:LPIXAudio2SubmixVoice;EffectIndex:UINT32;pParameters:LPCvoid;ParametersByteSize:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetEffectParameters:access function(THIS:LPIXAudio2SubmixVoice;EffectIndex:UINT32;pParameters:LPvoid;ParametersByteSize:UINT32) return HRESULT with Convention=>Stdcall;
SetFilterParameters:access function(THIS:LPIXAudio2SubmixVoice;pParameters:LPCXAUDIO2_FILTER_PARAMETERS;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetFilterParameters:access procedure(THIS:LPIXAudio2SubmixVoice;pParameters:LPXAUDIO2_FILTER_PARAMETERS) with Convention=>Stdcall;
SetOutputFilterParameters:access function(THIS:LPIXAudio2SubmixVoice;pDestinationVoice:LPIXAudio2Voice;pParameters:LPCXAUDIO2_FILTER_PARAMETERS;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetOutputFilterParameters:access procedure(THIS:LPIXAudio2SubmixVoice;pDestinationVoice:LPIXAudio2Voice;pParameters:LPXAUDIO2_FILTER_PARAMETERS) with Convention=>Stdcall;
SetVolume:access function(THIS:LPIXAudio2SubmixVoice;Volume:float;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetVolume:access procedure(THIS:LPIXAudio2SubmixVoice;pVolume:LPfloat) with Convention=>Stdcall;
SetChannelVolumes:access function(THIS:LPIXAudio2SubmixVoice;Channels:UINT32;pVolumes:LPCfloat;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetChannelVolumes:access procedure(THIS:LPIXAudio2SubmixVoice;Channels:UINT32;pVolumes:LPfloat) with Convention=>Stdcall;
SetOutputMatrix:access function(THIS:LPIXAudio2SubmixVoice;pDestinationVoice:LPIXAudio2Voice;SourceChannels:UINT32;DestinationChannels:UINT32;pLevelMatrix:LPCfloat;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetOutputMatrix:access procedure(THIS:LPIXAudio2SubmixVoice;pDestinationVoice:LPIXAudio2Voice;SourceChannels:UINT32;DestinationChannels:UINT32;pLevelMatrix:LPfloat) with Convention=>Stdcall;
DestroyVoice:access procedure(THIS:LPIXAudio2SubmixVoice) with Convention=>Stdcall;
end record;
type IXAudio2MasteringVoice is record
GetVoiceDetails:access procedure(THIS:LPIXAudio2MasteringVoice;pVoiceDetails:LPXAUDIO2_VOICE_DETAILS) with Convention=>Stdcall;
SetOutputVoices:access function(THIS:LPIXAudio2MasteringVoice;pSendList:LPCXAUDIO2_VOICE_SENDS) return HRESULT with Convention=>Stdcall;
SetEffectChain:access function(THIS:LPIXAudio2MasteringVoice;pEffectChain:LPCXAUDIO2_EFFECT_CHAIN) return HRESULT with Convention=>Stdcall;
EnableEffect:access function(THIS:LPIXAudio2MasteringVoice;EffectIndex:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
DisableEffect:access function(THIS:LPIXAudio2MasteringVoice;EffectIndex:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetEffectState:access procedure(THIS:LPIXAudio2MasteringVoice;EffectIndex:UINT32;pEnabled:LPBOOL) with Convention=>Stdcall;
SetEffectParameters:access function(THIS:LPIXAudio2MasteringVoice;EffectIndex:UINT32;pParameters:LPCvoid;ParametersByteSize:UINT32;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetEffectParameters:access function(THIS:LPIXAudio2MasteringVoice;EffectIndex:UINT32;pParameters:LPvoid;ParametersByteSize:UINT32) return HRESULT with Convention=>Stdcall;
SetFilterParameters:access function(THIS:LPIXAudio2MasteringVoice;pParameters:LPCXAUDIO2_FILTER_PARAMETERS;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetFilterParameters:access procedure(THIS:LPIXAudio2MasteringVoice;pParameters:LPXAUDIO2_FILTER_PARAMETERS) with Convention=>Stdcall;
SetOutputFilterParameters:access function(THIS:LPIXAudio2MasteringVoice;pDestinationVoice:LPIXAudio2Voice;pParameters:LPCXAUDIO2_FILTER_PARAMETERS;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetOutputFilterParameters:access procedure(THIS:LPIXAudio2MasteringVoice;pDestinationVoice:LPIXAudio2Voice;pParameters:LPXAUDIO2_FILTER_PARAMETERS) with Convention=>Stdcall;
SetVolume:access function(THIS:LPIXAudio2MasteringVoice;Volume:float;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetVolume:access procedure(THIS:LPIXAudio2MasteringVoice;pVolume:LPfloat) with Convention=>Stdcall;
SetChannelVolumes:access function(THIS:LPIXAudio2MasteringVoice;Channels:UINT32;pVolumes:LPCfloat;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetChannelVolumes:access procedure(THIS:LPIXAudio2MasteringVoice;Channels:UINT32;pVolumes:LPfloat) with Convention=>Stdcall;
SetOutputMatrix:access function(THIS:LPIXAudio2MasteringVoice;pDestinationVoice:LPIXAudio2Voice;SourceChannels:UINT32;DestinationChannels:UINT32;pLevelMatrix:LPCfloat;OperationSet:UINT32) return HRESULT with Convention=>Stdcall;
GetOutputMatrix:access procedure(THIS:LPIXAudio2MasteringVoice;pDestinationVoice:LPIXAudio2Voice;SourceChannels:UINT32;DestinationChannels:UINT32;pLevelMatrix:LPfloat) with Convention=>Stdcall;
DestroyVoice:access procedure(THIS:LPIXAudio2MasteringVoice) with Convention=>Stdcall;
end record;
type IXAudio2EngineCallback is record
OnProcessingPassStart:access procedure(THIS:LPIXAudio2EngineCallback) with Convention=>Stdcall;
OnProcessingPassEnd:access procedure(THIS:LPIXAudio2EngineCallback) with Convention=>Stdcall;
OnCriticalError:access procedure(THIS:LPIXAudio2EngineCallback;Error:HRESULT) with Convention=>Stdcall;
end record;
type IXAudio2VoiceCallback is record
OnVoiceProcessingPassStart:access procedure(THIS:LPIXAudio2VoiceCallback;BytesRequired:UINT32) with Convention=>Stdcall;
OnVoiceProcessingPassEnd:access procedure(THIS:LPIXAudio2VoiceCallback) with Convention=>Stdcall;
OnStreamEnd:access procedure(THIS:LPIXAudio2VoiceCallback) with Convention=>Stdcall;
OnBufferStart:access procedure(THIS:LPIXAudio2VoiceCallback;pBufferContext:LPvoid) with Convention=>Stdcall;
OnBufferEnd:access procedure(THIS:LPIXAudio2VoiceCallback;pBufferContext:LPvoid) with Convention=>Stdcall;
OnLoopEnd:access procedure(THIS:LPIXAudio2VoiceCallback;pBufferContext:LPvoid) with Convention=>Stdcall;
OnVoiceError:access procedure(THIS:LPIXAudio2VoiceCallback;pBufferContext:LPvoid;Error:HRESULT) with Convention=>Stdcall;
end record;
--
-- 帮助函数
--
function powf(a,b:float) return float with Import,external_name=>"powf";
function log10f(a:float) return float with Import,external_name=>"log10f";
function sinf(a:float) return float with Import,external_name=>"sinf";
function asinf(a:float) return float with Import,external_name=>"asinf";
function XAudio2DecibelsToAmplitudeRatio(Decibels:float) return float is (powf(10.0, Decibels/20.0)) with Inline_Always;
function XAudio2AmplitudeRatioToDecibels(Volume:float) return float is (if Volume=0.0 then -3.402823466e+38 else 20.0*log10f(Volume)) with Inline_Always;
function XAudio2SemitonesToFrequencyRatio(Semitones:float) return float is (powf(2.0, Semitones / 12.0)) with Inline_Always;
function XAudio2FrequencyRatioToSemitones(FrequencyRatio:float) return float is (39.86313713864835 * log10f(FrequencyRatio)) with Inline_Always;
M_PI:constant:=3.14159265358979323846;
use type interfaces.C.unsigned;
function XAudio2CutoffFrequencyToRadians(CutoffFrequency:float; SampleRate:UINT32) return float is (if uint(CutoffFrequency * 6.0)>SampleRate then XAUDIO2_MAX_FILTER_FREQUENCY else 2.0 * sinf(float(M_PI) * CutoffFrequency / Float(SampleRate))) with Inline_Always;
function XAudio2RadiansToCutoffFrequency(Radians:float; SampleRate:float) return float is (SampleRate * asinf(Radians / 2.0) / float(M_PI)) with Inline_Always;
function XAudio2Create(ppXAudio2:LPLPIXAudio2;Flags:UINT32:=0;XAudio2Processor:XAUDIO2_PROCESSOR:=XAUDIO2_DEFAULT_PROCESSOR) return HRESULT with Inline;
end XAudio2;
----------------------------------------
-- File : XAudio2.adb --
-- Translator:Dongfeng.Gu,2018/10/30 --
-- Mail: 515639@qq.com --
-- Progress:100% --
----------------------------------------
with Ada.Unchecked_Conversion;
with win32.Winerror;
package body XAudio2 is
function AsPVOID is new Ada.Unchecked_Conversion(LPIXAudio2,LPVOID);
function XAudio2Create(ppXAudio2:LPLPIXAudio2;Flags:UINT32:=0;XAudio2Processor:XAUDIO2_PROCESSOR:=XAUDIO2_DEFAULT_PROCESSOR) return HRESULT is
pXAudio2:LPIXAudio2;pragma Warnings(off,pXAudio2);
hr:HRESULT:=CoCreateInstance((if (Flags and XAUDIO2_DEBUG_ENGINE)/=0 then CLSID_XAudio2_Debug'Unrestricted_Access else CLSID_XAudio2'Unrestricted_Access),NULL, 1, IID_IXAudio2'Unrestricted_Access, AsPVOID(pXAudio2)'Unrestricted_Access);
rl:ulong;
begin
if Winerror.SUCCEEDED(hr) then
hr := pXAudio2.Initialize(pXAudio2, Flags, XAudio2Processor);
if Winerror.SUCCEEDED(hr) then
ppXAudio2.all:=pXAudio2;
else
rl:=pXAudio2.Release(pXAudio2);
end if;
end if;
return hr;
end XAudio2Create;
end XAudio2;