public sealed class HrtfPannerPlaces a sound around a head, including behind it and above it.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Amplitude panning has a left and a right and nothing else. A sound directly behind you produces the same two numbers as one directly in front, and one overhead produces the same as one at ear level. Those are not subtle differences to a listener — they are the difference between knowing where something is and guessing.
This is a structural model and not a measured filter set, and the distinction matters. A real HRTF is a pair of impulse responses measured around somebody's actual head, and it is several megabytes of content that has to be shipped and licensed. What is here instead is the three physical mechanisms behind those measurements, each written down as a filter: the path length difference to the two ears, the shadow the head casts, and what the outer ear does to sound arriving from different directions. It is not as convincing as a good measured set. It is convincing enough to tell front from back, which is the thing panning cannot do at all, and it costs no content.
Headphones only. Over speakers each ear hears both channels, so the cues arrive crossed and the result is worse than plain panning — which is why this is never the default and why anything switching it on should be reading a headphone setting.
The three mechanisms, in the order the ear weighs them:
Time. Sound reaches the near ear before the far one, by up to about two thirds of a millisecond. Below roughly 1.5 kHz this is the dominant cue and the brain reads the phase difference directly. The delay follows Woodworth's spherical-head formula rather than a straight-line difference, because sound bends around a head rather than passing through it.
Level, and only at high frequencies. A head is an obstacle roughly the size of a wavelength at 2 kHz: below that sound diffracts around it almost undiminished, above it the far ear is in shadow. So the shadow is a one-pole filter whose shape depends on angle, not a gain — a plain level difference would be wrong at exactly the frequencies where the ear is most sensitive to it being wrong.
Shape. The pinna reflects sound into the canal with a delay that depends on where it came from, which puts a notch in the spectrum whose frequency moves with elevation and which is largely absent from behind. That notch is how a listener knows a sound is above them, and its absence is how they know it is behind.
Fields and properties (2)
public const float HeadRadiusThe radius of the head this is modelled on, in metres.
public const float SpeedOfSoundHow fast sound travels, in metres a second.
Methods (3)
public HrtfPanner(int rate)A panner for one voice at one sample rate.
public void Process(float sample, float azimuth, float elevation, out float left, out float right)Turns one mono sample into a left and a right one.
public void Reset()Forgets the delay line and every filter.
Used by (3)
- AudioMixerVixen.Audio
- HrtfTestsVixen.Audio.Tests
- VoiceVixen.Audio