diff options
author | gdkchan <gab.dark.100@gmail.com> | 2023-09-29 07:48:49 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-29 10:48:49 +0000 |
commit | 41b104d0fbf1e8cf280ab594f1316d815afdd1d6 (patch) | |
tree | 0cbcd43f4543b20a2b0f3064799140c32c3488c1 /src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs | |
parent | bc44b85b0bdcaf8140a04130e4a895677a01111f (diff) |
Fix audio renderer compressor effect (#5742)1.1.1036
* Delete DecibelToLinearExtended and fix Log10 function
* Fix CopyBuffer and ClearBuffer
* Change effect states from class to struct + formatting
* Formatting
* Make UpdateLowPassFilter readonly
* More compressor fixes
Diffstat (limited to 'src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs')
-rw-r--r-- | src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs index b231dbb6..415e1c19 100644 --- a/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs +++ b/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs @@ -52,7 +52,7 @@ namespace Ryujinx.Audio.Renderer.Dsp { // NOTE: Nintendo uses an approximation of log10, we don't. // As such, we support the same ranges as Nintendo to avoid unexpected behaviours. - return MathF.Pow(10, MathF.Max(x, 1.0e-10f)); + return MathF.Log10(MathF.Max(x, 1.0e-10f)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -62,7 +62,8 @@ namespace Ryujinx.Audio.Renderer.Dsp foreach (float input in inputs) { - res += (input * input); + float normInput = input * (1f / 32768f); + res += normInput * normInput; } res /= inputs.Length; @@ -81,19 +82,6 @@ namespace Ryujinx.Audio.Renderer.Dsp return MathF.Pow(10.0f, db / 20.0f); } - /// <summary> - /// Map decibel to linear in [0, 2] range. - /// </summary> - /// <param name="db">The decibel value to convert</param> - /// <returns>Converted linear value in [0, 2] range</returns> - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float DecibelToLinearExtended(float db) - { - float tmp = MathF.Log2(DecibelToLinear(db)); - - return MathF.Truncate(tmp) + MathF.Pow(2.0f, tmp - MathF.Truncate(tmp)); - } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public static float DegreesToRadians(float degrees) { |