c++audioopenalxaudio2

XAudio2 vs. OpenAL volume


I'm writing a piece of audio wrapper code in C++, to have an abstract API over XAudio2 and OpenAL (and some more later on). Everything works just fine, I have the system up and running, providing almost the same audio.

I only seems to have problem with setting source volumes. Both XAudio2 and OpenAL has a method to set the volume level for a source voice.

IXAudio2Voice::SetVolume( volume ) and alSourcef( source, AL_GAIN, volume );

According to the documentations both functions take the volume argument should be in the [0;1] range to set the level.

However, it seems that the curve they use internally doesn't match. It feels like OpenAL for example more quieter than XAudio2 when setting the valume to 0.5

Like one of them would interpret the volume linearly and the other is like logarithmic. Both the documentations say nothing about it, just stating that the range is [0;1] and say nothing how it is interpreted.

It is really hard to debug as it is hard to measure. Does somebody did something like this, or have experience using these functions?

Thank you.

Laci


Solution

  • You should look at the XAudio2 helper XAudio2DecibelsToAmplitudeRatio which computes float volume values from dB