From ab5d77c0c4925955180dc51e9f289187ce6f2901 Mon Sep 17 00:00:00 2001 From: Mary <mary@mary.zone> Date: Wed, 16 Feb 2022 21:38:45 +0100 Subject: amadeus: Fix limiter correctness (#3126) This fixes missing audio on Nintendo Switch Sports Online Play Test. --- Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs') diff --git a/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs b/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs index 3ff758ba..e5c85b94 100644 --- a/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs +++ b/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs @@ -111,9 +111,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command { for (int sampleIndex = 0; sampleIndex < context.SampleCount; sampleIndex++) { - float inputSample = *((float*)inputBuffers[channelIndex] + sampleIndex); + float rawInputSample = *((float*)inputBuffers[channelIndex] + sampleIndex); - float sampleInputMax = Math.Abs(inputSample * Parameter.InputGain); + float inputSample = (rawInputSample / short.MaxValue) * Parameter.InputGain; + + float sampleInputMax = Math.Abs(inputSample); float inputCoefficient = Parameter.ReleaseCoefficient; @@ -142,7 +144,9 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command ref float delayedSample = ref state.DelayedSampleBuffer[channelIndex * Parameter.DelayBufferSampleCountMax + state.DelayedSampleBufferPosition[channelIndex]]; - *((float*)outputBuffers[channelIndex] + sampleIndex) = delayedSample * state.CompressionGain[channelIndex] * Parameter.OutputGain; + float outputSample = delayedSample * state.CompressionGain[channelIndex] * Parameter.OutputGain; + + *((float*)outputBuffers[channelIndex] + sampleIndex) = outputSample * short.MaxValue; delayedSample = inputSample; -- cgit v1.2.3-70-g09d2