Villermen's picture

Linear 1D audio balance

I'm trying to get a balance value of -1 to 1 converted to the left/right audio channels. When 0 (default value) both sides should be at 100% gain. When 1 100% for right and 0% for left and the opposite for -1. I'm having a hard time trying to get this to work in OAL seeing as this is actually my first time working with it.

So far I've tried:
After OAL initialization:

AL.DistanceModel(ALDistanceModel.LinearDistanceClamped);

For each new source:

AL.Source(SourceId, ALSourcef.MaxDistance, 1f);
AL.Source(SourceId, ALSourceb.SourceRelative, false);

For setting the balance:

float balance = 0f; //(-1f to 1f)
OpenTK.Vector3 position = new OpenTK.Vector3(balance, 0f, 0f);
AL.Source(SourceId, ALSource3f.Position, ref position);

This will make the audio go 100% on the left channel and 0% on the right for all negative values of balance and 100% right 0% left for all positive values, so I'm kinda stuck.

How should I go about doing this? Any help is appreciated!

Gr.Viller