How can I adjust the volume of a sound in the OpenAL sound library?
You can change the global volume by setting the gain of the listener.
void Listener::setVolume(float v)
{
Assert::isTrue(0 <= v && v <= 1);
alListenerf(AL_GAIN, v);
}
float Listener::getVolume()
{
ALfloat v;
alGetListenerf(AL_GAIN, &v);
return v;
}
float newVolume = 0.4f;
alSourcef(currentSourceID, AL_GAIN, newVolume);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With