Skip to content

Enable stereo spatialization when using OpenAL Soft#2034

Open
Digivorix wants to merge 1 commit intoopenfl:8.4.0-devfrom
Digivorix:8.4.0-dev
Open

Enable stereo spatialization when using OpenAL Soft#2034
Digivorix wants to merge 1 commit intoopenfl:8.4.0-devfrom
Digivorix:8.4.0-dev

Conversation

@Digivorix
Copy link

By default, OpenAL Soft will only allow spatialization on mono sounds. This means that the position property of Lime AudioSource instances has no effect if the audio is stereo. This change makes use of the AL_SOFT_source_spatialize extension to enable the spatialization of stereo audio sources along with mono ones when using OpenAL Soft.

According to the extension documentation, the stereo audio will be down-mixed to mono, but only if the audio has a non-0 distance from the listener, so stereo audio that is left at the default position should not be affected by this change.

When a spatialized source plays a non-mono buffer and has a non-0 distance from the listener, the channels are down-mixed to mono and panned as appropriate (that is, all channels occupy the same spot in 3D space). An exception is the LFE channel of buffer formats that include one. The LFE input is sent separately to LFE output as normal, rather than being down-mixed and panned. It is still influenced by distance and cone attenuation however.

I feel like most people will be using stereo audio sources, so enabling spatialization of these samples where possible makes sense.

Credit to @ACrazyTown for helping me out with this on the Haxe Discord and directing me to their PR (#2001) as an example of how to work with OpenAL extensions.

Relies on the AL_SOFT_source_spatialize extension.
@skial skial mentioned this pull request Mar 4, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant