diff options
author | Peter Nelson <peter1138@openttd.org> | 2021-04-04 15:58:06 +0100 |
---|---|---|
committer | Charles Pigott <charlespigott@googlemail.com> | 2021-04-06 19:31:14 +0100 |
commit | 42fbdda9ab12a06a5fbe4817cb93c227b828e042 (patch) | |
tree | de44b300fd98685eb0f5480ba22a5bc4c6b58f96 | |
parent | f0a24e98f55def996b0913690736f4c708fc4c55 (diff) | |
download | openttd-42fbdda9ab12a06a5fbe4817cb93c227b828e042.tar.xz |
Change: Apply power-of-3 scaling to master effect volume to improve perceived loudness change.
-rw-r--r-- | src/mixer.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mixer.cpp b/src/mixer.cpp index 0a41bb7c7..0c9d9b151 100644 --- a/src/mixer.cpp +++ b/src/mixer.cpp @@ -155,7 +155,13 @@ void MxMixSamples(void *buffer, uint samples) /* Fetch music if a sampled stream is available */ if (_music_stream) _music_stream((int16*)buffer, samples); - uint8 effect_vol = _settings_client.music.effect_vol; + /* Apply simple x^3 scaling to master effect volume. This increases the + * perceived difference in loudness to better match expectations. effect_vol + * is expected to be in the range 0-127 hence the division by 127 * 127 to + * get back into range. */ + uint8 effect_vol = (_settings_client.music.effect_vol * + _settings_client.music.effect_vol * + _settings_client.music.effect_vol) / (127 * 127); /* Mix each channel */ for (mc = _channels; mc != endof(_channels); mc++) { |