diff options
| author | Mary <mary@mary.zone> | 2022-04-08 10:52:18 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-04-08 10:52:18 +0200 |
| commit | d04ba51bb0456ee8f778fe86fc224665b0fb20c8 (patch) | |
| tree | 7dd94a8c321cb64df7016065eeb30a345d3aa4b7 /Ryujinx.Audio/Renderer/Dsp/State | |
| parent | 55ee26136363338d1cfffabd4cca07c9ca9b7847 (diff) | |
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
Diffstat (limited to 'Ryujinx.Audio/Renderer/Dsp/State')
| -rw-r--r-- | Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs | 13 |
1 files changed, 12 insertions, 1 deletions
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); + } + } } } |
