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/Dsp/State/DelayState.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Ryujinx.Audio/Renderer/Dsp/State') diff --git a/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs b/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs index 7b694fb0..21ffbebd 100644 --- a/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs +++ b/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs @@ -17,6 +17,7 @@ using Ryujinx.Audio.Renderer.Dsp.Effect; using Ryujinx.Audio.Renderer.Parameter.Effect; +using System.Runtime.CompilerServices; namespace Ryujinx.Audio.Renderer.Dsp.State { @@ -43,7 +44,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.State { DelayLines[i] = new DelayLine(sampleRate, parameter.DelayTimeMax); DelayLines[i].SetDelay(parameter.DelayTime); - LowPassZ[0] = 0; } UpdateParameter(ref parameter); @@ -69,5 +69,16 @@ namespace Ryujinx.Audio.Renderer.Dsp.State LowPassFeedbackGain = 0.95f * FixedPointHelper.ToFloat(parameter.LowPassAmount, FixedPointPrecision); LowPassBaseGain = 1.0f - LowPassFeedbackGain; } + + public void UpdateLowPassFilter(ref float tempRawRef, uint channelCount) + { + for (int i = 0; i < channelCount; i++) + { + float lowPassResult = LowPassFeedbackGain * LowPassZ[i] + Unsafe.Add(ref tempRawRef, i) * LowPassBaseGain; + + LowPassZ[i] = lowPassResult; + DelayLines[i].Update(lowPassResult); + } + } } } -- cgit v1.2.3