From 40311310d1a6d2fde2ee9f04bfa1f21ced7cbee2 Mon Sep 17 00:00:00 2001 From: Mary-nyan Date: Tue, 6 Dec 2022 15:04:25 +0100 Subject: amadeus: Add missing compressor effect from REV11 (#4010) * amadeus: Add missing compressor effect from REV11 This was in my reversing notes but seems I completely forgot to implement it Also took the opportunity to simplify the Limiter effect a bit. * Remove some outdated comment * Address gdkchan's comments --- .../Renderer/Server/Effect/CompressorEffect.cs | 67 ++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Ryujinx.Audio/Renderer/Server/Effect/CompressorEffect.cs (limited to 'Ryujinx.Audio/Renderer/Server/Effect/CompressorEffect.cs') diff --git a/Ryujinx.Audio/Renderer/Server/Effect/CompressorEffect.cs b/Ryujinx.Audio/Renderer/Server/Effect/CompressorEffect.cs new file mode 100644 index 00000000..f4e5ae82 --- /dev/null +++ b/Ryujinx.Audio/Renderer/Server/Effect/CompressorEffect.cs @@ -0,0 +1,67 @@ +using Ryujinx.Audio.Renderer.Common; +using Ryujinx.Audio.Renderer.Dsp.State; +using Ryujinx.Audio.Renderer.Parameter.Effect; +using Ryujinx.Audio.Renderer.Parameter; +using Ryujinx.Audio.Renderer.Server.MemoryPool; +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; + +namespace Ryujinx.Audio.Renderer.Server.Effect +{ + /// + /// Server state for a compressor effect. + /// + public class CompressorEffect : BaseEffect + { + /// + /// The compressor parameter. + /// + public CompressorParameter Parameter; + + /// + /// The compressor state. + /// + public Memory State { get; } + + /// + /// Create a new . + /// + public CompressorEffect() + { + State = new CompressorState[1]; + } + + public override EffectType TargetEffectType => EffectType.Compressor; + + public override ulong GetWorkBuffer(int index) + { + return GetSingleBuffer(); + } + + public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion1 parameter, PoolMapper mapper) + { + // Nintendo doesn't do anything here but we still require updateErrorInfo to be initialised. + updateErrorInfo = new BehaviourParameter.ErrorInfo(); + } + + public override void Update(out BehaviourParameter.ErrorInfo updateErrorInfo, ref EffectInParameterVersion2 parameter, PoolMapper mapper) + { + Debug.Assert(IsTypeValid(ref parameter)); + + UpdateParameterBase(ref parameter); + + Parameter = MemoryMarshal.Cast(parameter.SpecificData)[0]; + IsEnabled = parameter.IsEnabled; + + updateErrorInfo = new BehaviourParameter.ErrorInfo(); + } + + public override void UpdateForCommandGeneration() + { + UpdateUsageStateForCommandGeneration(); + + Parameter.Status = UsageState.Enabled; + } + } +} -- cgit v1.2.3