public static class SpatializerTurns a listener and a source into per-speaker gains and a pitch ratio.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Panning and not HRTF. A head-related transfer function is a pair of convolutions per voice with a filter set that has to be shipped, and it is only correct on headphones — over speakers it is worse than panning. This is amplitude panning, which is what OpenAL's software mixer, WebAudio's equalpower mode and every console mixer do by default. An HRTF panner is a later addition behind the same call, and the interesting part of the work — distance, cones, doppler, the listener basis — does not change when it arrives.
Constant power, not constant amplitude. A sound panned to the centre is at 0.707 in both speakers rather than 0.5, because two speakers at 0.707 carry the same power as one at 1. Linear panning makes anything crossing the centre audibly dip.
Pure function, no state, no allocation, called once per voice per block from the audio thread — which is also what makes every one of these behaviours a unit test over numbers.
Methods (3)
public static SpatialResult Evaluate(in AudioListener listener, in SpatialSettings source, int outputChannels, Span<float> gains)Works out how a source should sound from where the listener is.
public static SpatialResult Evaluate(in AudioListenerSet listeners, in SpatialSettings source, int outputChannels, Span<float> gains, Span<float> scratch)Places a sound for several listeners at once.
public static float Pan(in AudioListener listener, Vector3 direction)Where a direction sits from left to right, as seen by a listener.
Used by (4)
- MultipleListenerTestsVixen.Audio.Tests
- SpatializerTestsVixen.Audio.Tests
- SurroundTestsVixen.Audio.Tests
- VoiceVixen.Audio