开发者

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;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜