From b29193945d9b0cd6d96c8ade0a64359e46c32cf4 Mon Sep 17 00:00:00 2001 From: Raul Santos Date: Mon, 23 Jan 2023 20:20:54 +0100 Subject: [PATCH] C#: Move `LinearToDb` and `DbToLinear` to Mathf --- .../glue/GodotSharp/GodotSharp/Core/GD.cs | 31 ------------------- .../glue/GodotSharp/GodotSharp/Core/Mathf.cs | 31 +++++++++++++++++++ 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs index e4b79e7ec43..f3f124d5ad5 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/GD.cs @@ -49,17 +49,6 @@ namespace Godot return Variant.CreateTakingOwnershipOfDisposableValue(ret); } - /// - /// Converts from decibels to linear energy (audio). - /// - /// - /// Decibels to convert. - /// Audio volume as linear energy. - public static real_t DbToLinear(real_t db) - { - return (real_t)Math.Exp(db * 0.11512925464970228420089957273422); - } - private static string[] GetPrintParams(object[] parameters) { if (parameters == null) @@ -111,26 +100,6 @@ namespace Godot return InteropUtils.UnmanagedGetManaged(NativeFuncs.godotsharp_instance_from_id(instanceId)); } - /// - /// Converts from linear energy to decibels (audio). - /// This can be used to implement volume sliders that behave as expected (since volume isn't linear). - /// - /// - /// - /// - /// // "slider" refers to a node that inherits Range such as HSlider or VSlider. - /// // Its range must be configured to go from 0 to 1. - /// // Change the bus name if you'd like to change the volume of a specific bus only. - /// AudioServer.SetBusVolumeDb(AudioServer.GetBusIndex("Master"), GD.LinearToDb(slider.value)); - /// - /// - /// The linear energy to convert. - /// Audio as decibels. - public static real_t LinearToDb(real_t linear) - { - return (real_t)(Math.Log(linear) * 8.6858896380650365530225783783321); - } - /// /// Loads a resource from the filesystem located at . /// The resource is loaded on the method call (unless it's referenced already diff --git a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs index b2cb0f5e6bc..137a42a6de7 100644 --- a/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs +++ b/modules/mono/glue/GodotSharp/GodotSharp/Core/Mathf.cs @@ -323,6 +323,17 @@ namespace Godot return d; } + /// + /// Converts from decibels to linear energy (audio). + /// + /// + /// Decibels to convert. + /// Audio volume as linear energy. + public static real_t DbToLinear(real_t db) + { + return (real_t)Math.Exp(db * 0.11512925464970228420089957273422); + } + /// /// Converts an angle expressed in degrees to radians. /// @@ -514,6 +525,26 @@ namespace Godot return from + (distance * weight); } + /// + /// Converts from linear energy to decibels (audio). + /// This can be used to implement volume sliders that behave as expected (since volume isn't linear). + /// + /// + /// + /// + /// // "slider" refers to a node that inherits Range such as HSlider or VSlider. + /// // Its range must be configured to go from 0 to 1. + /// // Change the bus name if you'd like to change the volume of a specific bus only. + /// AudioServer.SetBusVolumeDb(AudioServer.GetBusIndex("Master"), GD.LinearToDb(slider.value)); + /// + /// + /// The linear energy to convert. + /// Audio as decibels. + public static real_t LinearToDb(real_t linear) + { + return (real_t)(Math.Log(linear) * 8.6858896380650365530225783783321); + } + /// /// Natural logarithm. The amount of time needed to reach a certain level of continuous growth. ///