Apply global volume after applying volume scale

This commit is contained in:
刘皓 2024-08-06 14:40:41 -04:00
parent aaf5d3c8bf
commit d04b383667
No known key found for this signature in database
GPG key ID: 7901753DB465B711
3 changed files with 4 additions and 5 deletions

View file

@ -181,11 +181,11 @@ namespace Source
break;
case VolumeScale::Db35:
if (value > FLT_EPSILON) {
value = std::powf(10., -(35. / 20.) * (1. - value));
value = std::powf(10.0f, -(35.0f / 20.0f) * (1.0f - value));
}
break;
}
alSourcef(id.al, AL_GAIN, value);
alSourcef(id.al, AL_GAIN, value * 0.8f);
}
inline void setPitch(Source::ID id, float value)
@ -269,6 +269,5 @@ inline ALenum chooseALFormat(int sampleSize, int channelCount)
#define AUDIO_SLEEP 10
#define STREAM_BUF_SIZE 32768
#define GLOBAL_VOLUME 0.8f
#endif // ALUTIL_H

View file

@ -260,7 +260,7 @@ float AudioStream::playingOffset()
void AudioStream::updateVolume()
{
float vol = GLOBAL_VOLUME;
float vol = 1.0f;
for (size_t i = 0; i < VolumeTypeCount; ++i)
vol *= volumes[i];

View file

@ -172,7 +172,7 @@ void SoundEmitter::play(const std::string &filename,
if (switchBuffer)
AL::Source::attachBuffer(src, buffer->alBuffer);
AL::Source::setVolume(src, _volume * GLOBAL_VOLUME, AL::Source::Linear);
AL::Source::setVolume(src, _volume, AL::Source::Linear);
AL::Source::setPitch(src, _pitch);
AL::Source::play(src);