I'm trying to figure out how to get openAL to pan in 2D (by manipulating the 3D positioning). Ideally I want to achieve panning such that the Left or Right channel can be fully engaged with the other channel completely silent. It seems that Open AL handles 3d distances and falloffs nicely, but I'm struggling to emulate this kind of 2D panning.
I'm using
alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED)
float sourcePosition[3] = {0.99f,0.f,0.f};
alSourcefv(sourceID, AL_POSITION, sourcePosition);
alSourcei(sourceID, AL_SOURCE_RELATIVE, AL_FALSE);
alSourcef(sourceID, AL_MAX_DISTANCE, 1.f);
alSourcef(sourceID, AL_REFERENCE_DISTANCE, 0.5f);
However there is a substantial amount of audio in the right channel. I don't really want gain to drop off based on distance, just proportion the channels.
Is it possible to emulate 2d panning with open AL?
You'll want to set AL_SOURCE_RELATIVE to AL_TRUE, rather than false.
So says the OpenAL 1.1 Specification (page 34)!
So, changing
to
should achieve the desired result.