From 2e3900f6a9453e6c1fb260e7636ff3e4a984b482 Mon Sep 17 00:00:00 2001 From: lelo <15314665+hate@users.noreply.github.com> Date: Mon, 28 Aug 2023 14:21:12 -0400 Subject: [PATCH] Clarify what happens when setting the audio volume (#9480) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective - Fixes [#8835](https://github.com/bevyengine/bevy/issues/8835) ## Solution - Added a note to the `set_volume` docstring which explains how volume is interpreted. --------- Co-authored-by: Alice Cecile Co-authored-by: GitGhillie Co-authored-by: François --- crates/bevy_audio/src/sinks.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crates/bevy_audio/src/sinks.rs b/crates/bevy_audio/src/sinks.rs index f81b817d698f2..e0730cbebd60f 100644 --- a/crates/bevy_audio/src/sinks.rs +++ b/crates/bevy_audio/src/sinks.rs @@ -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.