2

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

  • you can always do the brute force approach and calculate the RMS value (for each audio sample square the raw audio PCM level along its curve and add for each sample then divide that sum by number of samples then take square root ) to obtain a measure of the ~~volume~~ for a stretch of audio across each of a linear increase of that normalized range 0 to 1 for both XAudio2 and OpenAL and see if the curves are linear or not ... short of this dunno – Scott Stensland Aug 02 '19 at 13:02
  • 1
    Thank you for the suggestion. Will try something practical, like this. – Perneky László Aug 13 '19 at 12:52

1 Answers1

2

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

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81