diff options
author | Mary <mary@mary.zone> | 2022-04-06 09:12:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-06 09:12:38 +0200 |
commit | 3f4fb8f73a6635dbdca9dd11738c3a793f53ac65 (patch) | |
tree | adab6a0c08efac674982ded8ca915ff5069462ea /Ryujinx.Audio/Renderer/Dsp | |
parent | 56c56aa34d40327cf045d7198fe0f40492a5dbc3 (diff) |
amadeus: Update to REV11 (#3230)1.1.91
This should implement all ABI changes from REV11 on 14.0.0
As Nintendo changed the channel disposition for "legacy" effects (Delay, Reverb and Reverb 3D) to match the standard channel mapping, I took the liberty to just remap to the old disposition for now.
The proper changes will be handled at a later date with a complete rewriting of those 3 effects to be more readable (see https://github.com/Ryujinx/Ryujinx/pull/3205 for the first iteration of it).
Diffstat (limited to 'Ryujinx.Audio/Renderer/Dsp')
6 files changed, 58 insertions, 9 deletions
diff --git a/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs b/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs index ace0f274..8d416cc3 100644 --- a/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs +++ b/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs @@ -45,7 +45,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command private const int FixedPointPrecision = 14; - public DelayCommand(uint bufferOffset, DelayParameter parameter, Memory<DelayState> state, bool isEnabled, ulong workBuffer, int nodeId) + public DelayCommand(uint bufferOffset, DelayParameter parameter, Memory<DelayState> state, bool isEnabled, ulong workBuffer, int nodeId, bool newEffectChannelMappingSupported) { Enabled = true; NodeId = nodeId; @@ -63,6 +63,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command InputBufferIndices[i] = (ushort)(bufferOffset + Parameter.Input[i]); OutputBufferIndices[i] = (ushort)(bufferOffset + Parameter.Output[i]); } + + // NOTE: We do the opposite as Nintendo here for now to restore previous behaviour + // TODO: Update delay processing and remove this to use RemapLegacyChannelEffectMappingToChannelResourceMapping. + DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, InputBufferIndices); + DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, OutputBufferIndices); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs b/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs index 7da9804e..5cbc1060 100644 --- a/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs +++ b/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs @@ -63,7 +63,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command private Reverb3dParameter _parameter; - public Reverb3dCommand(uint bufferOffset, Reverb3dParameter parameter, Memory<Reverb3dState> state, bool isEnabled, ulong workBuffer, int nodeId) + public Reverb3dCommand(uint bufferOffset, Reverb3dParameter parameter, Memory<Reverb3dState> state, bool isEnabled, ulong workBuffer, int nodeId, bool newEffectChannelMappingSupported) { Enabled = true; IsEffectEnabled = isEnabled; @@ -80,6 +80,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command InputBufferIndices[i] = (ushort)(bufferOffset + Parameter.Input[i]); OutputBufferIndices[i] = (ushort)(bufferOffset + Parameter.Output[i]); } + + // 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); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -194,7 +199,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command if (isSurround) { - *((float*)outputBuffers[4] + sampleIndex) += (outputValues[4] + state.BackLeftDelayLine.Update((values[2] - values[3]) * 0.5f) + channelInput[4] * state.DryGain); + *((float*)outputBuffers[4] + sampleIndex) += (outputValues[4] + state.FrontCenterDelayLine.Update((values[2] - values[3]) * 0.5f) + channelInput[4] * state.DryGain); } } } diff --git a/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs b/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs index 1da9c81b..15c67f17 100644 --- a/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs +++ b/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs @@ -66,7 +66,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command private const int FixedPointPrecision = 14; - public ReverbCommand(uint bufferOffset, ReverbParameter parameter, Memory<ReverbState> state, bool isEnabled, ulong workBuffer, int nodeId, bool isLongSizePreDelaySupported) + public ReverbCommand(uint bufferOffset, ReverbParameter parameter, Memory<ReverbState> state, bool isEnabled, ulong workBuffer, int nodeId, bool isLongSizePreDelaySupported, bool newEffectChannelMappingSupported) { Enabled = true; IsEffectEnabled = isEnabled; @@ -85,6 +85,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command } IsLongSizePreDelaySupported = isLongSizePreDelaySupported; + + // NOTE: We do the opposite as Nintendo here for now to restore previous behaviour + // TODO: Update reverb processing and remove this to use RemapLegacyChannelEffectMappingToChannelResourceMapping. + DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, InputBufferIndices); + DataSourceHelper.RemapChannelResourceMappingToLegacy(newEffectChannelMappingSupported, OutputBufferIndices); } [MethodImpl(MethodImplOptions.AggressiveInlining)] @@ -214,7 +219,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command if (isSurround) { - outputValues[4] += state.BackLeftDelayLine.Update((feedbackOutputValues[2] - feedbackOutputValues[3]) * 0.5f); + outputValues[4] += state.FrontCenterDelayLine.Update((feedbackOutputValues[2] - feedbackOutputValues[3]) * 0.5f); } for (int channelIndex = 0; channelIndex < Parameter.ChannelCount; channelIndex++) diff --git a/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs b/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs index 4732f504..5c413ee1 100644 --- a/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs +++ b/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs @@ -445,5 +445,39 @@ namespace Ryujinx.Audio.Renderer.Dsp ToIntSlow(output, input, sampleCount); } } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void RemapLegacyChannelEffectMappingToChannelResourceMapping(bool isSupported, Span<ushort> bufferIndices) + { + if (!isSupported && bufferIndices.Length == 6) + { + ushort backLeft = bufferIndices[2]; + ushort backRight = bufferIndices[3]; + ushort frontCenter = bufferIndices[4]; + ushort lowFrequency = bufferIndices[5]; + + bufferIndices[2] = frontCenter; + bufferIndices[3] = lowFrequency; + bufferIndices[4] = backLeft; + bufferIndices[5] = backRight; + } + } + + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public static void RemapChannelResourceMappingToLegacy(bool isSupported, Span<ushort> bufferIndices) + { + if (isSupported && bufferIndices.Length == 6) + { + ushort frontCenter = bufferIndices[2]; + ushort lowFrequency = bufferIndices[3]; + ushort backLeft = bufferIndices[4]; + ushort backRight = bufferIndices[5]; + + bufferIndices[2] = backLeft; + bufferIndices[3] = backRight; + bufferIndices[4] = frontCenter; + bufferIndices[5] = lowFrequency; + } + } } } diff --git a/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs b/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs index be0f9734..dc7d6efe 100644 --- a/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs +++ b/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs @@ -34,7 +34,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State public DecayDelay[] DecayDelays1 { get; } public DecayDelay[] DecayDelays2 { get; } public IDelayLine PreDelayLine { get; } - public IDelayLine BackLeftDelayLine { get; } + public IDelayLine FrontCenterDelayLine { get; } public float DryGain { get; private set; } public uint[] EarlyDelayTime { get; private set; } public float PreviousPreDelayValue { get; set; } @@ -69,7 +69,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State } PreDelayLine = new DelayLine3d(sampleRate, 400); - BackLeftDelayLine = new DelayLine3d(sampleRate, 5); + FrontCenterDelayLine = new DelayLine3d(sampleRate, 5); UpdateParameter(ref parameter); } diff --git a/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs b/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs index c75bdce2..fc0c6539 100644 --- a/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs +++ b/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs @@ -97,7 +97,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State public DelayLine[] FdnDelayLines { get; } public DecayDelay[] DecayDelays { get; } public DelayLine PreDelayLine { get; } - public DelayLine BackLeftDelayLine { get; } + public DelayLine FrontCenterDelayLine { get; } public uint[] EarlyDelayTime { get; } public float[] EarlyGain { get; } public uint PreDelayLineDelayTime { get; private set; } @@ -149,7 +149,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State } PreDelayLine = new DelayLine(sampleRate, preDelayTimeMax); - BackLeftDelayLine = new DelayLine(sampleRate, 5.0f); + FrontCenterDelayLine = new DelayLine(sampleRate, 5.0f); UpdateParameter(ref parameter); } |