Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make effect volume slider non-linear #8950

Merged
merged 2 commits into from Apr 6, 2021

Conversation

PeterN
Copy link
Member

@PeterN PeterN commented Apr 5, 2021

Motivation / Problem

The effect volume slider has barely any effect on perceived volume until down into the low values.

Description

This is because perceived audio loudness is non-linear, but our code treats it as such,

This is approximately documented here: https://www.dr-lex.be/info-stuff/volumecontrols.html

This change introduces x^3 scaling rather than the suggested x^4 or x^5 scaling, as this "feels" fine and whereas the latter curves seem excessive. This is just a game, not professional audio mixing software, after all. It also feels similar to how the music volume slider already works, at least for the soft-synth on Windows.

And additional change to increase the permitted sample range values to avoid clipping is included, but the volume slider change doesn't have any bearing on that.

Limitations

Existing volume adjustment will probably be too quiet now, however the level can easily be adjusted up.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

Clamping each sample value to half the available range could cause
unnecessary premature clipping with lots of sounds playing. This change
does not affect the actual volume level.
@nielsmh nielsmh added the backport requested This PR should be backport to current release (RC / stable) label Apr 5, 2021
Copy link
Member

@LordAro LordAro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

¯\_(ツ)_/¯

@LordAro LordAro merged commit 920bf70 into OpenTTD:master Apr 6, 2021
@PeterN PeterN deleted the non-linear-volume branch April 6, 2021 18:42
@LordAro LordAro added backported This PR is backported to a current release (RC / stable) and removed backport requested This PR should be backport to current release (RC / stable) labels Apr 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backported This PR is backported to a current release (RC / stable)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants