Class SampleProviderSpatial
Namespace: ValveResourceFormat.Renderer.Audio.SampleProviders
Assembly: Renderer.dll
Applies per-ear volumes to a stereo stream based on the listener's orientation. Volumes are interpolated across each buffer to avoid zipper noise.
public abstract class SampleProviderSpatial : SampleProvider2D, IAudioSampleProviderInheritance
object ← AudioSampleProvider ← SampleProvider2D ← SampleProviderSpatial
Derived
Implements
Inherited Members
SampleProvider2D.Provider, SampleProvider2D.Read(float[], int, int), AudioSampleProvider.OnOver, AudioSampleProvider.Volume, AudioSampleProvider.VolumeMultiplier, AudioSampleProvider.Read(float[], int, int), AudioSampleProvider.Over()
Constructors
SampleProviderSpatial(IAudioSampleProvider)
Creates a spatializer around the given source.
protected SampleProviderSpatial(IAudioSampleProvider provider)Parameters
provider IAudioSampleProvider
Properties
LastLeftVolume
Gets or sets the left ear gain used for the previous buffer.
protected float LastLeftVolume { get; set; }Property Value
LastRightVolume
Gets or sets the right ear gain used for the previous buffer.
protected float LastRightVolume { get; set; }Property Value
LeftVolume
Gets the current left ear gain.
public float LeftVolume { get; protected set; }Property Value
RightVolume
Gets the current right ear gain.
public float RightVolume { get; protected set; }Property Value
Methods
GetDirectionMix(Vector3, Vector3)
Returns how much the sound leans towards the right ear (-1 fully left, 1 fully right).
protected abstract float GetDirectionMix(Vector3 listenerPosition, Vector3 rightEarDirection)Parameters
listenerPosition Vector3
rightEarDirection Vector3
Returns
Read(float[], int, int)
Fills buffer with up to count samples starting at offset. Returns the number of samples written. A return value smaller than count signals the end of the sound.
public override int Read(float[] buffer, int offset, int count)Parameters
buffer float[]
offset int
count int
Returns
ResetInterpolation()
Resets the interpolation state so the next update snaps to its target instead of fading in from wherever this provider last left off. Call when reusing this instance for a new (e.g. retriggered) sound.
public virtual void ResetInterpolation()SnapVolumesOnFirstUpdate()
Snaps the interpolation state to the current volumes on the first update.
protected void SnapVolumesOnFirstUpdate()Update(Vector3, Vector3)
Recomputes the per-ear volumes for the given listener. Returns whether the sound is currently audible.
public virtual bool Update(Vector3 listenerPosition, Vector3 rightEarDirection)Parameters
listenerPosition Vector3
rightEarDirection Vector3

