How to adjust the volume of a sound in OpenAL?
How can I adjust the volume of a sound in开发者_运维技巧 the OpenAL sound library?
float newVolume = 0.4f;
alSourcef(currentSourceID, AL_GAIN, newVolume);
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;
}
精彩评论