mirror of
https://github.com/amerkoleci/Vortice.Win32.git
synced 2026-01-14 16:16:04 +08:00
Improve XAudio2 bindings and add X3DAudio support.
This commit is contained in:
@@ -137,12 +137,12 @@ public unsafe partial struct IXAudio2 : IXAudio2.Interface, INativeGuid
|
||||
/// <include file='../XAudio2.xml' path='doc/member[@name="IXAudio2::CreateMasteringVoice"]/*' />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(7)]
|
||||
public HResult CreateMasteringVoice(IXAudio2MasteringVoice** ppMasteringVoice, uint InputChannels, uint InputSampleRate, uint Flags, ushort* szDeviceId, EffectChain* pEffectChain, Media.Audio.AudioStreamCategory* StreamCategory)
|
||||
public HResult CreateMasteringVoice(IXAudio2MasteringVoice** ppMasteringVoice, uint InputChannels, uint InputSampleRate, uint Flags, ushort* szDeviceId, EffectChain* pEffectChain, Media.Audio.AudioStreamCategory StreamCategory)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
return ((delegate* unmanaged<IXAudio2*, IXAudio2MasteringVoice**, uint, uint, uint, ushort*, EffectChain*, Media.Audio.AudioStreamCategory*, int>)(lpVtbl[7]))((IXAudio2*)Unsafe.AsPointer(ref this), ppMasteringVoice, InputChannels, InputSampleRate, Flags, szDeviceId, pEffectChain, StreamCategory);
|
||||
return ((delegate* unmanaged<IXAudio2*, IXAudio2MasteringVoice**, uint, uint, uint, ushort*, EffectChain*, Media.Audio.AudioStreamCategory, int>)(lpVtbl[7]))((IXAudio2*)Unsafe.AsPointer(ref this), ppMasteringVoice, InputChannels, InputSampleRate, Flags, szDeviceId, pEffectChain, StreamCategory);
|
||||
#else
|
||||
return ((delegate* unmanaged[Stdcall]<IXAudio2*, IXAudio2MasteringVoice**, uint, uint, uint, ushort*, EffectChain*, Media.Audio.AudioStreamCategory*, int>)(lpVtbl[7]))((IXAudio2*)Unsafe.AsPointer(ref this), ppMasteringVoice, InputChannels, InputSampleRate, Flags, szDeviceId, pEffectChain, StreamCategory);
|
||||
return ((delegate* unmanaged[Stdcall]<IXAudio2*, IXAudio2MasteringVoice**, uint, uint, uint, ushort*, EffectChain*, Media.Audio.AudioStreamCategory, int>)(lpVtbl[7]))((IXAudio2*)Unsafe.AsPointer(ref this), ppMasteringVoice, InputChannels, InputSampleRate, Flags, szDeviceId, pEffectChain, StreamCategory);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ public unsafe partial struct IXAudio2 : IXAudio2.Interface, INativeGuid
|
||||
/// <include file='../XAudio2.xml' path='doc/member[@name="IXAudio2::SetDebugConfiguration"]/*' />
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[VtblIndex(12)]
|
||||
public void SetDebugConfiguration(DebugConfiguration* pDebugConfiguration, void* pReserved)
|
||||
public void SetDebugConfiguration(DebugConfiguration* pDebugConfiguration, void* pReserved = null)
|
||||
{
|
||||
#if NET6_0_OR_GREATER
|
||||
((delegate* unmanaged<IXAudio2*, DebugConfiguration*, void*, void>)(lpVtbl[12]))((IXAudio2*)Unsafe.AsPointer(ref this), pDebugConfiguration, pReserved);
|
||||
@@ -221,7 +221,7 @@ public unsafe partial struct IXAudio2 : IXAudio2.Interface, INativeGuid
|
||||
HResult CreateSubmixVoice(IXAudio2SubmixVoice** ppSubmixVoice, uint InputChannels, uint InputSampleRate, uint Flags, uint ProcessingStage, VoiceSends* pSendList, EffectChain* pEffectChain);
|
||||
|
||||
[VtblIndex(7)]
|
||||
HResult CreateMasteringVoice(IXAudio2MasteringVoice** ppMasteringVoice, uint InputChannels, uint InputSampleRate, uint Flags, ushort* szDeviceId, EffectChain* pEffectChain, Media.Audio.AudioStreamCategory* StreamCategory);
|
||||
HResult CreateMasteringVoice(IXAudio2MasteringVoice** ppMasteringVoice, uint InputChannels, uint InputSampleRate, uint Flags, ushort* szDeviceId, EffectChain* pEffectChain, Media.Audio.AudioStreamCategory StreamCategory);
|
||||
|
||||
[VtblIndex(8)]
|
||||
HResult StartEngine();
|
||||
@@ -236,7 +236,7 @@ public unsafe partial struct IXAudio2 : IXAudio2.Interface, INativeGuid
|
||||
void GetPerformanceData(PerformanceData* pPerfData);
|
||||
|
||||
[VtblIndex(12)]
|
||||
void SetDebugConfiguration(DebugConfiguration* pDebugConfiguration, void* pReserved);
|
||||
void SetDebugConfiguration(DebugConfiguration* pDebugConfiguration, void* pReserved = null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
23
src/Vortice.Win32.Media.Audio.XAudio2/X3DAudio/Apis.cs
Normal file
23
src/Vortice.Win32.Media.Audio.XAudio2/X3DAudio/Apis.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
namespace Win32.Media.Audio.XAudio2;
|
||||
|
||||
public static unsafe partial class Apis
|
||||
{
|
||||
public static HResult X3DAudioInitialize(uint SpeakerChannelMask, out X3DAudioHandle Instance)
|
||||
{
|
||||
return X3DAudioInitialize(SpeakerChannelMask, X3DAUDIO_SPEED_OF_SOUND, out Instance);
|
||||
}
|
||||
|
||||
public static void X3DAudioCalculate(in X3DAudioHandle Instance, X3DAudioListener* pListener, X3DAudioEmitter* pEmitter, X3DCalculateFlags Flags, X3DAudioDSPSettings* pDSPSettings)
|
||||
{
|
||||
X3DAudioCalculate(Instance, pListener, pEmitter, (uint)Flags, pDSPSettings);
|
||||
}
|
||||
|
||||
[DllImport("xaudio2_9", ExactSpelling = true)]
|
||||
public static extern HResult X3DAudioInitialize(uint SpeakerChannelMask, float SpeedOfSound, out X3DAudioHandle Instance);
|
||||
|
||||
[DllImport("xaudio2_9", ExactSpelling = true)]
|
||||
public static extern void X3DAudioCalculate(in X3DAudioHandle Instance, X3DAudioListener* pListener, X3DAudioEmitter* pEmitter, uint Flags, X3DAudioDSPSettings* pDSPSettings);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
namespace Win32.Media.Audio.XAudio2;
|
||||
|
||||
/// <unmanaged>X3DAUDIO_CONE</unmanaged>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public partial struct X3DAudioCone
|
||||
{
|
||||
[NativeTypeName("FLOAT32")]
|
||||
public float InnerAngle;
|
||||
|
||||
[NativeTypeName("FLOAT32")]
|
||||
public float OuterAngle;
|
||||
|
||||
[NativeTypeName("FLOAT32")]
|
||||
public float InnerVolume;
|
||||
|
||||
[NativeTypeName("FLOAT32")]
|
||||
public float OuterVolume;
|
||||
|
||||
[NativeTypeName("FLOAT32")]
|
||||
public float InnerLPF;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
namespace Win32.Media.Audio.XAudio2;
|
||||
|
||||
/// <unmanaged>X3DAUDIO_DSP_SETTINGS</unmanaged>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public unsafe partial struct X3DAudioDSPSettings
|
||||
{
|
||||
public float* pMatrixCoefficients;
|
||||
|
||||
public float* pDelayTimes;
|
||||
|
||||
public uint SrcChannelCount;
|
||||
|
||||
public uint DstChannelCount;
|
||||
|
||||
public float LPFDirectCoefficient;
|
||||
|
||||
public float LPFReverbCoefficient;
|
||||
|
||||
public float ReverbLevel;
|
||||
|
||||
public float DopplerFactor;
|
||||
|
||||
public float EmitterToListenerAngle;
|
||||
|
||||
public float EmitterToListenerDistance;
|
||||
|
||||
public float EmitterVelocityComponent;
|
||||
|
||||
public float ListenerVelocityComponent;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
namespace Win32.Media.Audio.XAudio2;
|
||||
|
||||
/// <unmanaged>X3DAUDIO_DISTANCE_CURVE</unmanaged>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public unsafe partial struct X3DAudioDistanceCurve
|
||||
{
|
||||
public X3DAudioDistanceCurvePoint* pPoints;
|
||||
|
||||
public uint PointCount;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
namespace Win32.Media.Audio.XAudio2;
|
||||
|
||||
/// <unmanaged>X3DAUDIO_DISTANCE_CURVE_POINT</unmanaged>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public unsafe partial struct X3DAudioDistanceCurvePoint
|
||||
{
|
||||
public float Distance;
|
||||
|
||||
public float DSPSetting;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
namespace Win32.Media.Audio.XAudio2;
|
||||
|
||||
/// <unmanaged>X3DAUDIO_EMITTER</unmanaged>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public unsafe partial struct X3DAudioEmitter
|
||||
{
|
||||
public X3DAudioCone* pCone;
|
||||
|
||||
public Vector3 OrientFront;
|
||||
|
||||
public Vector3 OrientTop;
|
||||
|
||||
public Vector3 Position;
|
||||
|
||||
public Vector3 Velocity;
|
||||
|
||||
public float InnerRadius;
|
||||
|
||||
public float InnerRadiusAngle;
|
||||
|
||||
public uint ChannelCount;
|
||||
|
||||
public float ChannelRadius;
|
||||
|
||||
public float* pChannelAzimuths;
|
||||
|
||||
public X3DAudioDistanceCurve* pVolumeCurve;
|
||||
|
||||
public X3DAudioDistanceCurve* pLFECurve;
|
||||
|
||||
public X3DAudioDistanceCurve* pLPFDirectCurve;
|
||||
|
||||
public X3DAudioDistanceCurve* pLPFReverbCurve;
|
||||
|
||||
public X3DAudioDistanceCurve* pReverbCurve;
|
||||
|
||||
public float CurveDistanceScaler;
|
||||
|
||||
public float DopplerScaler;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
using static Win32.Media.Audio.XAudio2.Apis;
|
||||
|
||||
namespace Win32.Media.Audio.XAudio2;
|
||||
|
||||
[StructLayout(LayoutKind.Explicit, Size = (int)X3DAUDIO_HANDLE_BYTESIZE)]
|
||||
public readonly struct X3DAudioHandle
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
namespace Win32.Media.Audio.XAudio2;
|
||||
|
||||
/// <unmanaged>X3DAUDIO_LISTENER</unmanaged>
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 1)]
|
||||
public struct X3DAudioListener
|
||||
{
|
||||
public Vector3 OrientFront;
|
||||
|
||||
public Vector3 OrientTop;
|
||||
|
||||
public Vector3 Position;
|
||||
|
||||
public Vector3 Velocity;
|
||||
|
||||
public unsafe X3DAudioCone* pCone;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright © Amer Koleci and Contributors.
|
||||
// Licensed under the MIT License (MIT). See LICENSE in the repository root for more information.
|
||||
|
||||
using static Win32.Media.Audio.XAudio2.Apis;
|
||||
|
||||
namespace Win32.Media.Audio.XAudio2;
|
||||
|
||||
[Flags]
|
||||
public enum X3DCalculateFlags : uint
|
||||
{
|
||||
None = 0,
|
||||
/// <unmanaged>X3DAUDIO_CALCULATE_MATRIX</unmanaged>
|
||||
Matrix = X3DAUDIO_CALCULATE_MATRIX,
|
||||
/// <unmanaged>X3DAUDIO_CALCULATE_DELAY</unmanaged>
|
||||
Delay = X3DAUDIO_CALCULATE_DELAY,
|
||||
/// <unmanaged>X3DAUDIO_CALCULATE_LPF_DIRECT</unmanaged>
|
||||
LpfDirect = X3DAUDIO_CALCULATE_LPF_DIRECT,
|
||||
/// <unmanaged>X3DAUDIO_CALCULATE_LPF_REVERB</unmanaged>
|
||||
LpfReverb = X3DAUDIO_CALCULATE_LPF_REVERB,
|
||||
/// <unmanaged>X3DAUDIO_CALCULATE_REVERB</unmanaged>
|
||||
Reverb = X3DAUDIO_CALCULATE_REVERB,
|
||||
/// <unmanaged>X3DAUDIO_CALCULATE_DOPPLER</unmanaged>
|
||||
Doppler = X3DAUDIO_CALCULATE_DOPPLER,
|
||||
/// <unmanaged>X3DAUDIO_CALCULATE_EMITTER_ANGLE</unmanaged>
|
||||
EmitterAngle = X3DAUDIO_CALCULATE_EMITTER_ANGLE,
|
||||
/// <unmanaged>X3DAUDIO_CALCULATE_ZEROCENTER</unmanaged>
|
||||
ZeroCenter = X3DAUDIO_CALCULATE_ZEROCENTER,
|
||||
/// <unmanaged>X3DAUDIO_CALCULATE_REDIRECT_TO_LFE</unmanaged>
|
||||
RedirectToLfe = X3DAUDIO_CALCULATE_REDIRECT_TO_LFE,
|
||||
}
|
||||
|
||||
|
||||
@@ -418,7 +418,6 @@ See Remarks for more information on volume levels.</param>
|
||||
<para>Changes global debug logging options for XAudio2.</para>
|
||||
<para>Microsoft Docs: <see href="https://docs.microsoft.com/windows/win32/api//xaudio2/nf-xaudio2-ixaudio2-setdebugconfiguration" /></para>
|
||||
<param name="pDebugConfiguration">Pointer to a <a href="https://docs.microsoft.com/windows/desktop/api/xaudio2/ns-xaudio2-xaudio2_debug_configuration">XAUDIO2_DEBUG_CONFIGURATION</a> structure that contains the new debug configuration.</param>
|
||||
<param name="X2DEFAULT">This parameter is reserved and must be NULL.</param>
|
||||
</summary>
|
||||
</member>
|
||||
<member name="IXAudio2::CreateSourceVoice">
|
||||
|
||||
Reference in New Issue
Block a user