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

Clarify what happens when setting the audio volume #9480

Merged
merged 4 commits into from
Aug 28, 2023

Conversation

hate
Copy link
Contributor

@hate hate commented Aug 18, 2023

Objective

Solution

  • Added a note to the set_volume docstring which explains how volume is interpreted.

Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

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

I think that the suggestion will give nicer formatting, but otherwise this LGTM.

@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-Audio Sounds playback and modification labels Aug 18, 2023
@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

@mockersf
Copy link
Member

I think I don't agree with the comment. The video is audio at 1.0, then 0.01, then 1.0. for me it's much less than half the volume.

audio-controls.mp4

@alice-i-cecile
Copy link
Member

That would be a quarter, based on the comment, but that's still perceived as much less than that to me.

@GitGhillie
Copy link
Contributor

GitGhillie commented Aug 19, 2023

Sound is doubled with every 3dB, so to get half the sound you would need -3dB, or a power of 10^-3/10 ~= 0.5. If we take the square root of 0.5 you get 0.708 which is what you would need to set the volume to in order to halve the sound from the original 1.0 setting. Multiply the volume by 0.708 to halve the sound again etc. See table below:

image

To make things more complicated:
"an increase of 10 dB roughly corresponds to the perceived volume doubling in intensity"

This means you would have to set the volume to 0.316 to perceive it half as loud as 1.0.
And 0.316 * 0.316 to perceive it 4 times less loud compared to 1.0.

These numbers seem to check out when I try it on the example, as well as the change in dB levels when I check with OBS.
See also my comments on the issue: #8835, I'm not surprised 0.01 is very quiet.

Copy link
Member

@harudagondi harudagondi left a comment

Choose a reason for hiding this comment

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

I agree with the documentation, but I am wondering if we should have it accept something like

enum Volume {
    Logarithmic(f32),
    Linear(u8), // 255 is the 100%, 128 is 50% of the volume, etc.
}

instead of just f32.

crates/bevy_audio/src/sinks.rs Outdated Show resolved Hide resolved
@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Aug 28, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Aug 28, 2023
Merged via the queue into bevyengine:main with commit 2e3900f Aug 28, 2023
21 checks passed
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

- Fixes [bevyengine#8835](bevyengine#8835)

## Solution

- Added a note to the `set_volume` docstring which explains how volume
is interpreted.

---------

Co-authored-by: Alice Cecile <[email protected]>
Co-authored-by: GitGhillie <[email protected]>
Co-authored-by: François <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Audio Sounds playback and modification C-Docs An addition or correction to our documentation S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Audio PlaybackSettings volume setting doesn't correspond to human perception of volume well
5 participants