Skip to content

Commit

Permalink
Clarify what happens when setting the audio volume (bevyengine#9480)
Browse files Browse the repository at this point in the history
# 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]>
  • Loading branch information
4 people authored and Ray Redondo committed Jan 9, 2024
1 parent 0505ea1 commit 4dcf42b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/bevy_audio/src/sinks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ pub trait AudioSinkPlayback {
///
/// The value `1.0` is the "normal" volume (unfiltered input). Any value other than `1.0`
/// will multiply each sample by this value.
///
/// # Note on Audio Volume
///
/// An increase of 10 decibels (dB) roughly corresponds to the perceived volume doubling in intensity.
/// As this function scales not the volume but the amplitude, a conversion might be necessary.
/// For example, to halve the perceived volume you need to decrease the volume by 10 dB.
/// This corresponds to 20log(x) = -10dB, solving x = 10^(-10/20) = 0.316.
/// Multiply the current volume by 0.316 to halve the perceived volume.
fn set_volume(&self, volume: f32);

/// Gets the speed of the sound.
Expand Down

0 comments on commit 4dcf42b

Please sign in to comment.