FineAudio/AudioListener.cs

98 lines
1.7 KiB
C#
Raw Normal View History

2022-02-23 05:14:32 +00:00
using System;
2021-02-27 00:17:26 +00:00
using MoonWorks.Math;
namespace MoonWorks.Audio
{
2022-02-23 05:14:32 +00:00
public class AudioListener : AudioResource
{
internal FAudio.F3DAUDIO_LISTENER listenerData;
2021-02-27 00:17:26 +00:00
public Vector3 Forward
{
get
{
return new Vector3(
listenerData.OrientFront.x,
listenerData.OrientFront.y,
-listenerData.OrientFront.z
);
}
set
{
listenerData.OrientFront.x = value.X;
listenerData.OrientFront.y = value.Y;
listenerData.OrientFront.z = -value.Z;
}
}
public Vector3 Position
{
get
{
return new Vector3(
listenerData.Position.x,
listenerData.Position.y,
-listenerData.Position.z
);
}
set
{
listenerData.Position.x = value.X;
listenerData.Position.y = value.Y;
listenerData.Position.z = -value.Z;
}
}
public Vector3 Up
{
get
{
return new Vector3(
listenerData.OrientTop.x,
listenerData.OrientTop.y,
-listenerData.OrientTop.z
);
}
set
{
listenerData.OrientTop.x = value.X;
listenerData.OrientTop.y = value.Y;
listenerData.OrientTop.z = -value.Z;
}
}
public Vector3 Velocity
{
get
{
return new Vector3(
listenerData.Velocity.x,
listenerData.Velocity.y,
-listenerData.Velocity.z
);
}
set
{
listenerData.Velocity.x = value.X;
listenerData.Velocity.y = value.Y;
listenerData.Velocity.z = -value.Z;
}
}
2022-02-23 05:14:32 +00:00
public AudioListener(AudioDevice device) : base(device)
{
listenerData = new FAudio.F3DAUDIO_LISTENER();
Forward = Vector3.Forward;
Position = Vector3.Zero;
Up = Vector3.Up;
Velocity = Vector3.Zero;
2021-02-27 00:17:26 +00:00
2022-02-23 05:14:32 +00:00
/* Unexposed variables, defaults based on XNA behavior */
2021-02-27 00:17:26 +00:00
listenerData.pCone = IntPtr.Zero;
2022-02-23 05:14:32 +00:00
}
2021-02-27 00:17:26 +00:00
2022-02-23 05:14:32 +00:00
protected override void Destroy() { }
}
2021-02-27 00:17:26 +00:00
}