From 40d47b7aa235b464974480d09875eef0377bb261 Mon Sep 17 00:00:00 2001
From: Mary <mary@mary.zone>
Date: Thu, 11 May 2023 20:14:02 +0200
Subject: amadeus: Fix wrong channel mapping check and an old typo (#4888)

* amadeus: Fix wrong channel mapping check

This was always going to happens, as a result quadratic would break and
move index after the channel count point, effectively breaking
input/output indices.

* amadeus: Fix reverb 3d early delay wrong output index
---
 src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs')

diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs
index eeb64567..74b53b24 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs
@@ -66,8 +66,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
 
             // NOTE: We do the opposite as Nintendo here for now to restore previous behaviour
             // TODO: Update reverb 3d processing and remove this to use RemapLegacyChannelEffectMappingToChannelResourceMapping.
-            DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, InputBufferIndices);
-            DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, OutputBufferIndices);
+            DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, InputBufferIndices, Parameter.ChannelCount);
+            DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, OutputBufferIndices, Parameter.ChannelCount);
         }
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -116,7 +116,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
                 for (int i = 0; i < targetEarlyDelayLineIndicesTable.Length; i++)
                 {
                     int earlyDelayIndex = targetEarlyDelayLineIndicesTable[i];
-                    int outputIndex = outputEarlyIndicesTable[i];
+                    int outputIndex = outputEarlyIndicesTable[earlyDelayIndex];
 
                     float tempTapOut = state.PreDelayLine.TapUnsafe(state.EarlyDelayTime[earlyDelayIndex], delayLineSampleIndexOffset);
 
-- 
cgit v1.2.3-70-g09d2