From d04ba51bb0456ee8f778fe86fc224665b0fb20c8 Mon Sep 17 00:00:00 2001 From: Mary Date: Fri, 8 Apr 2022 10:52:18 +0200 Subject: amadeus: Improve and fix delay effect processing (#3205) * amadeus: Improve and fix delay effect processing This rework the delay effect processing by representing calculation with the appropriate matrix and by unrolling some loop in the code. This allows better optimization by the JIT while making it more readeable. Also fix a bug in the Surround code path found while looking back at my notes. * Remove useless GetHashCode * Address gdkchan's comments --- Ryujinx.Audio/Renderer/Utils/Math/Matrix2x2.cs | 71 ++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Ryujinx.Audio/Renderer/Utils/Math/Matrix2x2.cs (limited to 'Ryujinx.Audio/Renderer/Utils/Math/Matrix2x2.cs') diff --git a/Ryujinx.Audio/Renderer/Utils/Math/Matrix2x2.cs b/Ryujinx.Audio/Renderer/Utils/Math/Matrix2x2.cs new file mode 100644 index 00000000..f25b1537 --- /dev/null +++ b/Ryujinx.Audio/Renderer/Utils/Math/Matrix2x2.cs @@ -0,0 +1,71 @@ +namespace Ryujinx.Audio.Renderer.Utils.Math +{ + record struct Matrix2x2 + { + public float M11; + public float M12; + public float M21; + public float M22; + + public Matrix2x2(float m11, float m12, + float m21, float m22) + { + M11 = m11; + M12 = m12; + + M21 = m21; + M22 = m22; + } + + public static Matrix2x2 operator +(Matrix2x2 value1, Matrix2x2 value2) + { + Matrix2x2 m; + + m.M11 = value1.M11 + value2.M11; + m.M12 = value1.M12 + value2.M12; + m.M21 = value1.M21 + value2.M21; + m.M22 = value1.M22 + value2.M22; + + return m; + } + + public static Matrix2x2 operator -(Matrix2x2 value1, float value2) + { + Matrix2x2 m; + + m.M11 = value1.M11 - value2; + m.M12 = value1.M12 - value2; + m.M21 = value1.M21 - value2; + m.M22 = value1.M22 - value2; + + return m; + } + + public static Matrix2x2 operator *(Matrix2x2 value1, float value2) + { + Matrix2x2 m; + + m.M11 = value1.M11 * value2; + m.M12 = value1.M12 * value2; + m.M21 = value1.M21 * value2; + m.M22 = value1.M22 * value2; + + return m; + } + + public static Matrix2x2 operator *(Matrix2x2 value1, Matrix2x2 value2) + { + Matrix2x2 m; + + // First row + m.M11 = value1.M11 * value2.M11 + value1.M12 * value2.M21; + m.M12 = value1.M11 * value2.M12 + value1.M12 * value2.M22; + + // Second row + m.M21 = value1.M21 * value2.M11 + value1.M22 * value2.M21; + m.M22 = value1.M21 * value2.M12 + value1.M22 * value2.M22; + + return m; + } + } +} -- cgit v1.2.3