aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Audio/Renderer/Dsp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Audio/Renderer/Dsp')
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/AdpcmHelper.cs10
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/AudioProcessor.cs21
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/BiquadFilterHelper.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/AdpcmDataSourceCommandVersion1.cs8
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/AuxiliaryBufferCommand.cs4
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/BiquadFilterCommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/CaptureBufferCommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/ClearMixBufferCommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/CommandList.cs5
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/CommandType.cs4
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/CompressorCommand.cs5
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/CopyMixBufferCommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/DataSourceVersion2Command.cs26
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs26
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/DepopForMixBuffersCommand.cs16
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/DepopPrepareCommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/DownMixSurroundToStereoCommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/GroupedBiquadFilterCommand.cs12
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/ICommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion1.cs9
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs9
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/MixCommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampCommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampGroupedCommand.cs4
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/PcmFloatDataSourceCommandVersion1.cs8
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/PcmInt16DataSourceCommandVersion1.cs8
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/PerformanceCommand.cs4
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs34
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs79
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeRampCommand.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs12
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Effect/DecayDelay.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLine.cs6
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLineReverb3d.cs6
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Effect/ExponentialMovingAverage.cs6
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/FixedPointHelper.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs6
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/PcmHelper.cs5
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/ResamplerHelper.cs45
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/State/AdpcmLoopContext.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/State/AuxiliaryBufferHeader.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/State/BiquadFilterState.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs2
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/State/LimiterState.cs8
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs24
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs32
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/UpsamplerHelper.cs40
50 files changed, 264 insertions, 258 deletions
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/AdpcmHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/AdpcmHelper.cs
index 2680dcb1..5cb4509f 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/AdpcmHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/AdpcmHelper.cs
@@ -12,7 +12,9 @@ namespace Ryujinx.Audio.Renderer.Dsp
private const int SamplesPerFrame = 14;
private const int NibblesPerFrame = SamplesPerFrame + 2;
private const int BytesPerFrame = 8;
+#pragma warning disable IDE0051 // Remove unused private member
private const int BitsPerFrame = BytesPerFrame * 8;
+#pragma warning restore IDE0051
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static uint GetAdpcmDataSize(int sampleCount)
@@ -64,10 +66,14 @@ namespace Ryujinx.Audio.Renderer.Dsp
private static short Saturate(int value)
{
if (value > short.MaxValue)
+ {
value = short.MaxValue;
+ }
if (value < short.MinValue)
+ {
value = short.MinValue;
+ }
return (short)value;
}
@@ -109,7 +115,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
ReadOnlySpan<byte> targetInput;
- targetInput = input.Slice(nibbles / 2);
+ targetInput = input[(nibbles / 2)..];
while (remaining > 0)
{
@@ -213,4 +219,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
return decodedCount;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/AudioProcessor.cs b/src/Ryujinx.Audio/Renderer/Dsp/AudioProcessor.cs
index 899c2ef9..9c885b2c 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/AudioProcessor.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/AudioProcessor.cs
@@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
Start,
Stop,
RenderStart,
- RenderEnd
+ RenderEnd,
}
private class RendererSession
@@ -36,7 +36,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
private long _lastTime;
private long _playbackEnds;
- private ManualResetEvent _event;
+ private readonly ManualResetEvent _event;
private ManualResetEvent _pauseEvent;
@@ -45,6 +45,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
_event = new ManualResetEvent(false);
}
+#pragma warning disable IDE0051 // Remove unused private member
private static uint GetHardwareChannelCount(IHardwareDeviceDriver deviceDriver)
{
// Get the real device driver (In case the compat layer is on top of it).
@@ -54,12 +55,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
return 6;
}
- else
- {
- // NOTE: We default to stereo as this will get downmixed to mono by the compat layer if it's not compatible.
- return 2;
- }
+
+ // NOTE: We default to stereo as this will get downmixed to mono by the compat layer if it's not compatible.
+ return 2;
}
+#pragma warning restore IDE0051
public void Start(IHardwareDeviceDriver deviceDriver, float volume)
{
@@ -110,7 +110,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
CommandList = commands,
RenderingLimit = renderingLimit,
- AppletResourceId = appletResourceId
+ AppletResourceId = appletResourceId,
};
}
@@ -171,7 +171,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
_workerThread = new Thread(Work)
{
- Name = "AudioProcessor.Worker"
+ Name = "AudioProcessor.Worker",
};
_workerThread.Start();
@@ -260,6 +260,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
public void Dispose()
{
+ GC.SuppressFinalize(this);
Dispose(true);
}
@@ -271,4 +272,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/BiquadFilterHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/BiquadFilterHelper.cs
index 98460ff1..1a51a1fb 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/BiquadFilterHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/BiquadFilterHelper.cs
@@ -80,4 +80,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/AdpcmDataSourceCommandVersion1.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/AdpcmDataSourceCommandVersion1.cs
index 1fe6069f..51a12b4e 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/AdpcmDataSourceCommandVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/AdpcmDataSourceCommandVersion1.cs
@@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
+using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
+using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@@ -29,7 +31,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public DecodingBehaviour DecodingBehaviour { get; }
- public AdpcmDataSourceCommandVersion1(ref Server.Voice.VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, int nodeId)
+ public AdpcmDataSourceCommandVersion1(ref VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, int nodeId)
{
Enabled = true;
NodeId = nodeId;
@@ -57,7 +59,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
- DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
+ DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat.Adpcm,
@@ -72,4 +74,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/AuxiliaryBufferCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/AuxiliaryBufferCommand.cs
index 5c3c0324..7ed32800 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/AuxiliaryBufferCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/AuxiliaryBufferCommand.cs
@@ -155,7 +155,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (readResult != context.SampleCount)
{
- outputBuffer.Slice((int)readResult, (int)context.SampleCount - (int)readResult).Fill(0);
+ outputBuffer[(int)readResult..(int)context.SampleCount].Clear();
}
}
else
@@ -170,4 +170,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/BiquadFilterCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/BiquadFilterCommand.cs
index b994c1cb..f56dd70e 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/BiquadFilterCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/BiquadFilterCommand.cs
@@ -48,4 +48,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
BiquadFilterHelper.ProcessBiquadFilter(ref _parameter, ref state, outputBuffer, inputBuffer, context.SampleCount);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/CaptureBufferCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/CaptureBufferCommand.cs
index da1cb254..01bff1e7 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/CaptureBufferCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/CaptureBufferCommand.cs
@@ -133,4 +133,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/ClearMixBufferCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/ClearMixBufferCommand.cs
index 9e653e80..f0f85b0b 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/ClearMixBufferCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/ClearMixBufferCommand.cs
@@ -21,4 +21,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
context.ClearBuffers();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandList.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandList.cs
index 2cbed9c2..19a9576f 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandList.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandList.cs
@@ -71,7 +71,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
return (IntPtr)((float*)_buffersMemoryHandle.Pointer + index * _sampleCount);
}
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(index), index, null);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -149,7 +149,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public void Dispose()
{
+ GC.SuppressFinalize(this);
_buffersMemoryHandle.Dispose();
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandType.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandType.cs
index 9ce181b1..098a04a0 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandType.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/CommandType.cs
@@ -32,6 +32,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
LimiterVersion2,
GroupedBiquadFilter,
CaptureBuffer,
- Compressor
+ Compressor,
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/CompressorCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/CompressorCommand.cs
index 34231e61..01291852 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/CompressorCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/CompressorCommand.cs
@@ -1,6 +1,7 @@
using Ryujinx.Audio.Renderer.Dsp.Effect;
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter.Effect;
+using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
@@ -51,11 +52,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
- if (_parameter.Status == Server.Effect.UsageState.Invalid)
+ if (_parameter.Status == UsageState.Invalid)
{
state = new CompressorState(ref _parameter);
}
- else if (_parameter.Status == Server.Effect.UsageState.New)
+ else if (_parameter.Status == UsageState.New)
{
state.UpdateParameter(ref _parameter);
}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/CopyMixBufferCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/CopyMixBufferCommand.cs
index 7237fddf..3f6aa839 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/CopyMixBufferCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/CopyMixBufferCommand.cs
@@ -27,4 +27,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
context.CopyBuffer(OutputBufferIndex, InputBufferIndex);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/DataSourceVersion2Command.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/DataSourceVersion2Command.cs
index c1503b6a..e82d403b 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/DataSourceVersion2Command.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/DataSourceVersion2Command.cs
@@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
+using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
+using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@@ -37,7 +39,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public SampleRateConversionQuality SrcQuality { get; }
- public DataSourceVersion2Command(ref Server.Voice.VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
+ public DataSourceVersion2Command(ref VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
Enabled = true;
NodeId = nodeId;
@@ -72,24 +74,20 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
private static CommandType GetCommandTypeBySampleFormat(SampleFormat sampleFormat)
{
- switch (sampleFormat)
+ return sampleFormat switch
{
- case SampleFormat.Adpcm:
- return CommandType.AdpcmDataSourceVersion2;
- case SampleFormat.PcmInt16:
- return CommandType.PcmInt16DataSourceVersion2;
- case SampleFormat.PcmFloat:
- return CommandType.PcmFloatDataSourceVersion2;
- default:
- throw new NotImplementedException($"{sampleFormat}");
- }
+ SampleFormat.Adpcm => CommandType.AdpcmDataSourceVersion2,
+ SampleFormat.PcmInt16 => CommandType.PcmInt16DataSourceVersion2,
+ SampleFormat.PcmFloat => CommandType.PcmFloatDataSourceVersion2,
+ _ => throw new NotImplementedException($"{sampleFormat}"),
+ };
}
public void Process(CommandList context)
{
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
- DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
+ DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat,
@@ -99,10 +97,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ExtraParameterSize = ExtraParameterSize,
ChannelIndex = (int)ChannelIndex,
ChannelCount = (int)ChannelCount,
- SrcQuality = SrcQuality
+ SrcQuality = SrcQuality,
};
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs
index e7e17938..003806cf 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/DelayCommand.cs
@@ -87,18 +87,18 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
- Matrix2x2 delayFeedback = new Matrix2x2(delayFeedbackBaseGain, delayFeedbackCrossGain,
+ Matrix2x2 delayFeedback = new(delayFeedbackBaseGain, delayFeedbackCrossGain,
delayFeedbackCrossGain, delayFeedbackBaseGain);
for (int i = 0; i < sampleCount; i++)
{
- Vector2 channelInput = new Vector2
+ Vector2 channelInput = new()
{
X = *((float*)inputBuffers[0] + i) * 64,
Y = *((float*)inputBuffers[1] + i) * 64,
};
- Vector2 delayLineValues = new Vector2()
+ Vector2 delayLineValues = new()
{
X = state.DelayLines[0].Read(),
Y = state.DelayLines[1].Read(),
@@ -124,7 +124,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
- Matrix4x4 delayFeedback = new Matrix4x4(delayFeedbackBaseGain, delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f,
+ Matrix4x4 delayFeedback = new(delayFeedbackBaseGain, delayFeedbackCrossGain, delayFeedbackCrossGain, 0.0f,
delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain,
delayFeedbackCrossGain, 0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain,
0.0f, delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain);
@@ -132,20 +132,20 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
for (int i = 0; i < sampleCount; i++)
{
- Vector4 channelInput = new Vector4
+ Vector4 channelInput = new()
{
X = *((float*)inputBuffers[0] + i) * 64,
Y = *((float*)inputBuffers[1] + i) * 64,
Z = *((float*)inputBuffers[2] + i) * 64,
- W = *((float*)inputBuffers[3] + i) * 64
+ W = *((float*)inputBuffers[3] + i) * 64,
};
- Vector4 delayLineValues = new Vector4()
+ Vector4 delayLineValues = new()
{
X = state.DelayLines[0].Read(),
Y = state.DelayLines[1].Read(),
Z = state.DelayLines[2].Read(),
- W = state.DelayLines[3].Read()
+ W = state.DelayLines[3].Read(),
};
Vector4 temp = MatrixHelper.Transform(ref delayLineValues, ref delayFeedback) + channelInput * inGain;
@@ -171,7 +171,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
float dryGain = FixedPointHelper.ToFloat(Parameter.DryGain, FixedPointPrecision);
float outGain = FixedPointHelper.ToFloat(Parameter.OutGain, FixedPointPrecision);
- Matrix6x6 delayFeedback = new Matrix6x6(delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain, 0.0f, delayFeedbackCrossGain, 0.0f,
+ Matrix6x6 delayFeedback = new(delayFeedbackBaseGain, 0.0f, delayFeedbackCrossGain, 0.0f, delayFeedbackCrossGain, 0.0f,
0.0f, delayFeedbackBaseGain, delayFeedbackCrossGain, 0.0f, 0.0f, delayFeedbackCrossGain,
delayFeedbackCrossGain, delayFeedbackCrossGain, delayFeedbackBaseGain, 0.0f, 0.0f, 0.0f,
0.0f, 0.0f, 0.0f, feedbackGain, 0.0f, 0.0f,
@@ -180,24 +180,24 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
for (int i = 0; i < sampleCount; i++)
{
- Vector6 channelInput = new Vector6
+ Vector6 channelInput = new()
{
X = *((float*)inputBuffers[0] + i) * 64,
Y = *((float*)inputBuffers[1] + i) * 64,
Z = *((float*)inputBuffers[2] + i) * 64,
W = *((float*)inputBuffers[3] + i) * 64,
V = *((float*)inputBuffers[4] + i) * 64,
- U = *((float*)inputBuffers[5] + i) * 64
+ U = *((float*)inputBuffers[5] + i) * 64,
};
- Vector6 delayLineValues = new Vector6
+ Vector6 delayLineValues = new()
{
X = state.DelayLines[0].Read(),
Y = state.DelayLines[1].Read(),
Z = state.DelayLines[2].Read(),
W = state.DelayLines[3].Read(),
V = state.DelayLines[4].Read(),
- U = state.DelayLines[5].Read()
+ U = state.DelayLines[5].Read(),
};
Vector6 temp = MatrixHelper.Transform(ref delayLineValues, ref delayFeedback) + channelInput * inGain;
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopForMixBuffersCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopForMixBuffersCommand.cs
index 1dba56e6..ff38f38c 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopForMixBuffersCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopForMixBuffersCommand.cs
@@ -55,17 +55,15 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
return -depopValue;
}
- else
- {
- for (int i = 0; i < sampleCount; i++)
- {
- depopValue = FloatingPointHelper.MultiplyRoundDown(Decay, depopValue);
- buffer[i] += depopValue;
- }
+ for (int i = 0; i < sampleCount; i++)
+ {
+ depopValue = FloatingPointHelper.MultiplyRoundDown(Decay, depopValue);
- return depopValue;
+ buffer[i] += depopValue;
}
+
+ return depopValue;
}
public void Process(CommandList context)
@@ -89,4 +87,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopPrepareCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopPrepareCommand.cs
index d02f7c12..c64bbdc5 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopPrepareCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/DepopPrepareCommand.cs
@@ -54,4 +54,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/DownMixSurroundToStereoCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/DownMixSurroundToStereoCommand.cs
index 79cefcc5..8997b0db 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/DownMixSurroundToStereoCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/DownMixSurroundToStereoCommand.cs
@@ -65,4 +65,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
context.ClearBuffer(OutputBufferIndices[5]);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/GroupedBiquadFilterCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/GroupedBiquadFilterCommand.cs
index b190cc10..7af851bd 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/GroupedBiquadFilterCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/GroupedBiquadFilterCommand.cs
@@ -14,11 +14,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public uint EstimatedProcessingTime { get; set; }
- private BiquadFilterParameter[] _parameters;
- private Memory<BiquadFilterState> _biquadFilterStates;
- private int _inputBufferIndex;
- private int _outputBufferIndex;
- private bool[] _isInitialized;
+ private readonly BiquadFilterParameter[] _parameters;
+ private readonly Memory<BiquadFilterState> _biquadFilterStates;
+ private readonly int _inputBufferIndex;
+ private readonly int _outputBufferIndex;
+ private readonly bool[] _isInitialized;
public GroupedBiquadFilterCommand(int baseIndex, ReadOnlySpan<BiquadFilterParameter> filters, Memory<BiquadFilterState> biquadFilterStateMemory, int inputBufferOffset, int outputBufferOffset, ReadOnlySpan<bool> isInitialized, int nodeId)
{
@@ -59,4 +59,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/ICommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/ICommand.cs
index d281e6e9..34a62c58 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/ICommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/ICommand.cs
@@ -17,4 +17,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
return false;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion1.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion1.cs
index a464ad70..3ba0b588 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion1.cs
@@ -1,5 +1,6 @@
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter.Effect;
+using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
@@ -50,13 +51,13 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
- if (Parameter.Status == Server.Effect.UsageState.Invalid)
+ if (Parameter.Status == UsageState.Invalid)
{
state = new LimiterState(ref _parameter, WorkBuffer);
}
- else if (Parameter.Status == Server.Effect.UsageState.New)
+ else if (Parameter.Status == UsageState.New)
{
- state.UpdateParameter(ref _parameter);
+ LimiterState.UpdateParameter(ref _parameter);
}
}
@@ -141,4 +142,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs
index 950de97b..68209867 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/LimiterCommandVersion2.cs
@@ -1,6 +1,7 @@
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter;
using Ryujinx.Audio.Renderer.Parameter.Effect;
+using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
@@ -54,13 +55,13 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
- if (Parameter.Status == Server.Effect.UsageState.Invalid)
+ if (Parameter.Status == UsageState.Invalid)
{
state = new LimiterState(ref _parameter, WorkBuffer);
}
- else if (Parameter.Status == Server.Effect.UsageState.New)
+ else if (Parameter.Status == UsageState.New)
{
- state.UpdateParameter(ref _parameter);
+ LimiterState.UpdateParameter(ref _parameter);
}
}
@@ -160,4 +161,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixCommand.cs
index 2616bda5..c701f80e 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixCommand.cs
@@ -134,4 +134,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessMix(outputBuffer, inputBuffer);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampCommand.cs
index 76a1aba2..f77a233e 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampCommand.cs
@@ -65,4 +65,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
State.Span[0].LastSamples[LastSampleIndex] = ProcessMixRamp(outputBuffer, inputBuffer, (int)context.SampleCount);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampGroupedCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampGroupedCommand.cs
index e348e358..3c7dd63b 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampGroupedCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/MixRampGroupedCommand.cs
@@ -48,7 +48,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
- private float ProcessMixRampGrouped(Span<float> outputBuffer, ReadOnlySpan<float> inputBuffer, float volume0, float volume1, int sampleCount)
+ private static float ProcessMixRampGrouped(Span<float> outputBuffer, ReadOnlySpan<float> inputBuffer, float volume0, float volume1, int sampleCount)
{
float ramp = (volume1 - volume0) / sampleCount;
float volume = volume0;
@@ -88,4 +88,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmFloatDataSourceCommandVersion1.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmFloatDataSourceCommandVersion1.cs
index 7cec7d2a..585edc05 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmFloatDataSourceCommandVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmFloatDataSourceCommandVersion1.cs
@@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
+using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
+using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@@ -28,7 +30,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public Memory<VoiceUpdateState> State { get; }
public DecodingBehaviour DecodingBehaviour { get; }
- public PcmFloatDataSourceCommandVersion1(ref Server.Voice.VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
+ public PcmFloatDataSourceCommandVersion1(ref VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
Enabled = true;
NodeId = nodeId;
@@ -56,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
- DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
+ DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat.PcmFloat,
@@ -71,4 +73,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmInt16DataSourceCommandVersion1.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmInt16DataSourceCommandVersion1.cs
index dfe9814f..6f01219f 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmInt16DataSourceCommandVersion1.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/PcmInt16DataSourceCommandVersion1.cs
@@ -1,7 +1,9 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
+using Ryujinx.Audio.Renderer.Server.Voice;
using System;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
+using WaveBuffer = Ryujinx.Audio.Renderer.Common.WaveBuffer;
namespace Ryujinx.Audio.Renderer.Dsp.Command
{
@@ -28,7 +30,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public Memory<VoiceUpdateState> State { get; }
public DecodingBehaviour DecodingBehaviour { get; }
- public PcmInt16DataSourceCommandVersion1(ref Server.Voice.VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
+ public PcmInt16DataSourceCommandVersion1(ref VoiceState serverState, Memory<VoiceUpdateState> state, ushort outputBufferIndex, ushort channelIndex, int nodeId)
{
Enabled = true;
NodeId = nodeId;
@@ -56,7 +58,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Span<float> outputBuffer = context.GetBuffer(OutputBufferIndex);
- DataSourceHelper.WaveBufferInformation info = new DataSourceHelper.WaveBufferInformation
+ DataSourceHelper.WaveBufferInformation info = new()
{
SourceSampleRate = SampleRate,
SampleFormat = SampleFormat.PcmInt16,
@@ -71,4 +73,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
DataSourceHelper.ProcessWaveBuffers(context.MemoryManager, outputBuffer, ref info, WaveBuffers, ref State.Span[0], context.SampleRate, (int)context.SampleCount);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/PerformanceCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/PerformanceCommand.cs
index d3e3f805..d3d2ee30 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/PerformanceCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/PerformanceCommand.cs
@@ -8,7 +8,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
Invalid,
Start,
- End
+ End,
}
public bool Enabled { get; set; }
@@ -44,4 +44,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs
index d1177e60..8cdd4843 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/Reverb3dCommand.cs
@@ -9,21 +9,21 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
public class Reverb3dCommand : ICommand
{
- private static readonly int[] OutputEarlyIndicesTableMono = new int[20] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableMono = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
- private static readonly int[] TargetOutputFeedbackIndicesTableMono = new int[1] { 0 };
+ private static readonly int[] _outputEarlyIndicesTableMono = new int[20] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableMono = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableMono = new int[1] { 0 };
- private static readonly int[] OutputEarlyIndicesTableStereo = new int[20] { 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableStereo = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
- private static readonly int[] TargetOutputFeedbackIndicesTableStereo = new int[2] { 0, 1 };
+ private static readonly int[] _outputEarlyIndicesTableStereo = new int[20] { 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 1 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableStereo = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableStereo = new int[2] { 0, 1 };
- private static readonly int[] OutputEarlyIndicesTableQuadraphonic = new int[20] { 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableQuadraphonic = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
- private static readonly int[] TargetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
+ private static readonly int[] _outputEarlyIndicesTableQuadraphonic = new int[20] { 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0, 3, 3, 3 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableQuadraphonic = new int[20] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
- private static readonly int[] OutputEarlyIndicesTableSurround = new int[40] { 4, 5, 0, 5, 0, 5, 1, 5, 1, 5, 1, 5, 1, 5, 2, 5, 2, 5, 2, 5, 1, 5, 1, 5, 1, 5, 0, 5, 0, 5, 0, 5, 0, 5, 3, 5, 3, 5, 3, 5 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableSurround = new int[40] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19 };
- private static readonly int[] TargetOutputFeedbackIndicesTableSurround = new int[6] { 0, 1, 2, 3, -1, 3 };
+ private static readonly int[] _outputEarlyIndicesTableSurround = new int[40] { 4, 5, 0, 5, 0, 5, 1, 5, 1, 5, 1, 5, 1, 5, 2, 5, 2, 5, 2, 5, 1, 5, 1, 5, 1, 5, 0, 5, 0, 5, 0, 5, 0, 5, 3, 5, 3, 5, 3, 5 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableSurround = new int[40] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableSurround = new int[6] { 0, 1, 2, 3, -1, 3 };
public bool Enabled { get; set; }
@@ -73,25 +73,25 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ProcessReverb3dMono(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
{
- ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableMono, TargetEarlyDelayLineIndicesTableMono, TargetOutputFeedbackIndicesTableMono);
+ ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableMono, _targetEarlyDelayLineIndicesTableMono, _targetOutputFeedbackIndicesTableMono);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ProcessReverb3dStereo(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
{
- ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableStereo, TargetEarlyDelayLineIndicesTableStereo, TargetOutputFeedbackIndicesTableStereo);
+ ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableStereo, _targetEarlyDelayLineIndicesTableStereo, _targetOutputFeedbackIndicesTableStereo);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ProcessReverb3dQuadraphonic(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
{
- ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableQuadraphonic, TargetEarlyDelayLineIndicesTableQuadraphonic, TargetOutputFeedbackIndicesTableQuadraphonic);
+ ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableQuadraphonic, _targetEarlyDelayLineIndicesTableQuadraphonic, _targetOutputFeedbackIndicesTableQuadraphonic);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ProcessReverb3dSurround(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount)
{
- ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, OutputEarlyIndicesTableSurround, TargetEarlyDelayLineIndicesTableSurround, TargetOutputFeedbackIndicesTableSurround);
+ ProcessReverb3dGeneric(ref state, outputBuffers, inputBuffers, sampleCount, _outputEarlyIndicesTableSurround, _targetEarlyDelayLineIndicesTableSurround, _targetOutputFeedbackIndicesTableSurround);
}
private unsafe void ProcessReverb3dGeneric(ref Reverb3dState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount, ReadOnlySpan<int> outputEarlyIndicesTable, ReadOnlySpan<int> targetEarlyDelayLineIndicesTable, ReadOnlySpan<int> targetOutputFeedbackIndicesTable)
@@ -109,7 +109,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
{
- outputValues.Fill(0);
+ outputValues.Clear();
float tapOut = state.PreDelayLine.TapUnsafe(state.ReflectionDelayTime, DelayLineSampleIndexOffset);
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs
index cd08b838..f494b302 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/ReverbCommand.cs
@@ -1,5 +1,6 @@
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter.Effect;
+using Ryujinx.Audio.Renderer.Server.Effect;
using System;
using System.Diagnostics;
using System.Runtime.CompilerServices;
@@ -8,25 +9,25 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
{
public class ReverbCommand : ICommand
{
- private static readonly int[] OutputEarlyIndicesTableMono = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableMono = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- private static readonly int[] OutputIndicesTableMono = new int[4] { 0, 0, 0, 0 };
- private static readonly int[] TargetOutputFeedbackIndicesTableMono = new int[4] { 0, 1, 2, 3 };
-
- private static readonly int[] OutputEarlyIndicesTableStereo = new int[10] { 0, 0, 1, 1, 0, 1, 0, 0, 1, 1 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableStereo = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- private static readonly int[] OutputIndicesTableStereo = new int[4] { 0, 0, 1, 1 };
- private static readonly int[] TargetOutputFeedbackIndicesTableStereo = new int[4] { 2, 0, 3, 1 };
-
- private static readonly int[] OutputEarlyIndicesTableQuadraphonic = new int[10] { 0, 0, 1, 1, 0, 1, 2, 2, 3, 3 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableQuadraphonic = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
- private static readonly int[] OutputIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
- private static readonly int[] TargetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
-
- private static readonly int[] OutputEarlyIndicesTableSurround = new int[20] { 0, 5, 0, 5, 1, 5, 1, 5, 4, 5, 4, 5, 2, 5, 2, 5, 3, 5, 3, 5 };
- private static readonly int[] TargetEarlyDelayLineIndicesTableSurround = new int[20] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9 };
- private static readonly int[] OutputIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, 4, 5 };
- private static readonly int[] TargetOutputFeedbackIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, -1, 3 };
+ private static readonly int[] _outputEarlyIndicesTableMono = new int[10] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableMono = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ private static readonly int[] _outputIndicesTableMono = new int[4] { 0, 0, 0, 0 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableMono = new int[4] { 0, 1, 2, 3 };
+
+ private static readonly int[] _outputEarlyIndicesTableStereo = new int[10] { 0, 0, 1, 1, 0, 1, 0, 0, 1, 1 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableStereo = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ private static readonly int[] _outputIndicesTableStereo = new int[4] { 0, 0, 1, 1 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableStereo = new int[4] { 2, 0, 3, 1 };
+
+ private static readonly int[] _outputEarlyIndicesTableQuadraphonic = new int[10] { 0, 0, 1, 1, 0, 1, 2, 2, 3, 3 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableQuadraphonic = new int[10] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+ private static readonly int[] _outputIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableQuadraphonic = new int[4] { 0, 1, 2, 3 };
+
+ private static readonly int[] _outputEarlyIndicesTableSurround = new int[20] { 0, 5, 0, 5, 1, 5, 1, 5, 4, 5, 4, 5, 2, 5, 2, 5, 3, 5, 3, 5 };
+ private static readonly int[] _targetEarlyDelayLineIndicesTableSurround = new int[20] { 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9 };
+ private static readonly int[] _outputIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, 4, 5 };
+ private static readonly int[] _targetOutputFeedbackIndicesTableSurround = new int[Constants.ChannelCountMax] { 0, 1, 2, 3, -1, 3 };
public bool Enabled { get; set; }
@@ -82,10 +83,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
- OutputEarlyIndicesTableMono,
- TargetEarlyDelayLineIndicesTableMono,
- TargetOutputFeedbackIndicesTableMono,
- OutputIndicesTableMono);
+ _outputEarlyIndicesTableMono,
+ _targetEarlyDelayLineIndicesTableMono,
+ _targetOutputFeedbackIndicesTableMono,
+ _outputIndicesTableMono);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -95,10 +96,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
- OutputEarlyIndicesTableStereo,
- TargetEarlyDelayLineIndicesTableStereo,
- TargetOutputFeedbackIndicesTableStereo,
- OutputIndicesTableStereo);
+ _outputEarlyIndicesTableStereo,
+ _targetEarlyDelayLineIndicesTableStereo,
+ _targetOutputFeedbackIndicesTableStereo,
+ _outputIndicesTableStereo);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -108,10 +109,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
- OutputEarlyIndicesTableQuadraphonic,
- TargetEarlyDelayLineIndicesTableQuadraphonic,
- TargetOutputFeedbackIndicesTableQuadraphonic,
- OutputIndicesTableQuadraphonic);
+ _outputEarlyIndicesTableQuadraphonic,
+ _targetEarlyDelayLineIndicesTableQuadraphonic,
+ _targetOutputFeedbackIndicesTableQuadraphonic,
+ _outputIndicesTableQuadraphonic);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -121,10 +122,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
outputBuffers,
inputBuffers,
sampleCount,
- OutputEarlyIndicesTableSurround,
- TargetEarlyDelayLineIndicesTableSurround,
- TargetOutputFeedbackIndicesTableSurround,
- OutputIndicesTableSurround);
+ _outputEarlyIndicesTableSurround,
+ _targetEarlyDelayLineIndicesTableSurround,
+ _targetOutputFeedbackIndicesTableSurround,
+ _outputIndicesTableSurround);
}
private unsafe void ProcessReverbGeneric(ref ReverbState state, ReadOnlySpan<IntPtr> outputBuffers, ReadOnlySpan<IntPtr> inputBuffers, uint sampleCount, ReadOnlySpan<int> outputEarlyIndicesTable, ReadOnlySpan<int> targetEarlyDelayLineIndicesTable, ReadOnlySpan<int> targetOutputFeedbackIndicesTable, ReadOnlySpan<int> outputIndicesTable)
@@ -143,7 +144,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
for (int sampleIndex = 0; sampleIndex < sampleCount; sampleIndex++)
{
- outputValues.Fill(0);
+ outputValues.Clear();
for (int i = 0; i < targetEarlyDelayLineIndicesTable.Length; i++)
{
@@ -263,11 +264,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
if (IsEffectEnabled)
{
- if (Parameter.Status == Server.Effect.UsageState.Invalid)
+ if (Parameter.Status == UsageState.Invalid)
{
state = new ReverbState(ref _parameter, WorkBuffer, IsLongSizePreDelaySupported);
}
- else if (Parameter.Status == Server.Effect.UsageState.New)
+ else if (Parameter.Status == UsageState.New)
{
state.UpdateParameter(ref _parameter);
}
@@ -276,4 +277,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessReverb(context, ref state);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs
index 0870d59c..8882500c 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs
@@ -67,4 +67,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs
index 0628f6d8..5deeb07f 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeCommand.cs
@@ -134,4 +134,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessVolume(outputBuffer, inputBuffer);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeRampCommand.cs b/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeRampCommand.cs
index 5c0c8845..bffbcbc6 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeRampCommand.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Command/VolumeRampCommand.cs
@@ -53,4 +53,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
ProcessVolumeRamp(outputBuffer, inputBuffer, (int)context.SampleCount);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs
index 12e0f13f..98657bd1 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/DataSourceHelper.cs
@@ -76,7 +76,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
if (!info.DecodingBehaviour.HasFlag(DecodingBehaviour.SkipPitchAndSampleRateConversion))
{
- voiceState.Pitch.AsSpan().Slice(0, pitchMaxLength).CopyTo(tempBuffer);
+ voiceState.Pitch.AsSpan()[..pitchMaxLength].CopyTo(tempBuffer);
tempBufferIndex += pitchMaxLength;
}
@@ -107,7 +107,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
voiceState.LoopContext = memoryManager.Read<AdpcmLoopContext>(waveBuffer.Context);
}
- Span<short> tempSpan = tempBuffer.Slice(tempBufferIndex + y);
+ Span<short> tempSpan = tempBuffer[(tempBufferIndex + y)..];
int decodedSampleCount = -1;
@@ -168,7 +168,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
decodedSampleCount = PcmHelper.Decode(tempSpan, waveBufferPcmFloat, targetSampleStartOffset, targetSampleEndOffset, info.ChannelIndex, info.ChannelCount);
break;
default:
- Logger.Error?.Print(LogClass.AudioRenderer, $"Unsupported sample format " + info.SampleFormat);
+ Logger.Error?.Print(LogClass.AudioRenderer, "Unsupported sample format " + info.SampleFormat);
break;
}
@@ -220,7 +220,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
}
- Span<int> outputSpanInt = MemoryMarshal.Cast<float, int>(outputBuffer.Slice(i));
+ Span<int> outputSpanInt = MemoryMarshal.Cast<float, int>(outputBuffer[i..]);
if (info.DecodingBehaviour.HasFlag(DecodingBehaviour.SkipPitchAndSampleRateConversion))
{
@@ -231,9 +231,9 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
else
{
- Span<short> tempSpan = tempBuffer.Slice(tempBufferIndex + y);
+ Span<short> tempSpan = tempBuffer[(tempBufferIndex + y)..];
- tempSpan.Slice(0, sampleCountToDecode - y).Fill(0);
+ tempSpan[..(sampleCountToDecode - y)].Clear();
ToFloat(outputBuffer, outputSpanInt, sampleCountToProcess);
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DecayDelay.cs b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DecayDelay.cs
index 37e066bf..7253fdc9 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DecayDelay.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DecayDelay.cs
@@ -49,4 +49,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return _delayLine.Tap(sampleIndex);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLine.cs b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLine.cs
index 56890ebe..8a3590a2 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLine.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLine.cs
@@ -4,8 +4,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
{
public class DelayLine : IDelayLine
{
- private float[] _workBuffer;
- private uint _sampleRate;
+ private readonly float[] _workBuffer;
+ private readonly uint _sampleRate;
private uint _currentSampleIndex;
private uint _lastSampleIndex;
@@ -75,4 +75,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return TapUnsafe(sampleIndex, -1);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLineReverb3d.cs b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLineReverb3d.cs
index a2ac9d26..ed8e7cfe 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLineReverb3d.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Effect/DelayLineReverb3d.cs
@@ -4,8 +4,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
{
public class DelayLine3d : IDelayLine
{
- private float[] _workBuffer;
- private uint _sampleRate;
+ private readonly float[] _workBuffer;
+ private readonly uint _sampleRate;
private uint _currentSampleIndex;
private uint _lastSampleIndex;
@@ -73,4 +73,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return TapUnsafe(sampleIndex, -1);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Effect/ExponentialMovingAverage.cs b/src/Ryujinx.Audio/Renderer/Dsp/Effect/ExponentialMovingAverage.cs
index 78e46bf9..253400a5 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Effect/ExponentialMovingAverage.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Effect/ExponentialMovingAverage.cs
@@ -1,6 +1,4 @@
-using System.Runtime.CompilerServices;
-
-namespace Ryujinx.Audio.Renderer.Dsp.Effect
+namespace Ryujinx.Audio.Renderer.Dsp.Effect
{
public struct ExponentialMovingAverage
{
@@ -11,7 +9,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
_mean = mean;
}
- public float Read()
+ public readonly float Read()
{
return _mean;
}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs b/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs
index fd902525..b408e294 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs
@@ -34,4 +34,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.Effect
return (uint)MathF.Round(sampleRate * delayTime);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/FixedPointHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/FixedPointHelper.cs
index 280e47c0..d519de33 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/FixedPointHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/FixedPointHelper.cs
@@ -36,4 +36,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
return ToInt(value + half, qBits);
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs
index 6645e20a..b231dbb6 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/FloatingPointHelper.cs
@@ -1,5 +1,4 @@
using System;
-using System.Reflection.Metadata;
using System.Runtime.CompilerServices;
namespace Ryujinx.Audio.Renderer.Dsp
@@ -39,7 +38,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
return 1.0f;
}
- else if (x <= -5.3f)
+
+ if (x <= -5.3f)
{
return 0.0f;
}
@@ -112,4 +112,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
return MathF.Sin(DegreesToRadians(value));
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/PcmHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/PcmHelper.cs
index 0233a8d7..d209c515 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/PcmHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/PcmHelper.cs
@@ -1,5 +1,4 @@
using System;
-using System.Numerics;
using System.Runtime.CompilerServices;
namespace Ryujinx.Audio.Renderer.Dsp
@@ -62,7 +61,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
for (int i = 0; i < input.Length; i++)
{
- output[i] = ((int)input[i]) << 16;
+ output[i] = input[i] << 16;
}
}
@@ -127,4 +126,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
return (short)value;
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/ResamplerHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/ResamplerHelper.cs
index 7873c4d2..e44e9f41 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/ResamplerHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/ResamplerHelper.cs
@@ -1,6 +1,5 @@
using System;
using System.Linq;
-using System.Numerics;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.X86;
@@ -11,8 +10,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
public static class ResamplerHelper
{
#region "Default Quality Lookup Tables"
- private static short[] _normalCurveLut0 = new short[]
- {
+ private static readonly short[] _normalCurveLut0 = {
6600, 19426, 6722, 3, 6479, 19424, 6845, 9, 6359, 19419, 6968, 15, 6239, 19412, 7093, 22,
6121, 19403, 7219, 28, 6004, 19391, 7345, 34, 5888, 19377, 7472, 41, 5773, 19361, 7600, 48,
5659, 19342, 7728, 55, 5546, 19321, 7857, 62, 5434, 19298, 7987, 69, 5323, 19273, 8118, 77,
@@ -44,11 +42,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
109, 8646, 19148, 4890, 101, 8513, 19183, 4997, 92, 8381, 19215, 5104, 84, 8249, 19245, 5213,
77, 8118, 19273, 5323, 69, 7987, 19298, 5434, 62, 7857, 19321, 5546, 55, 7728, 19342, 5659,
48, 7600, 19361, 5773, 41, 7472, 19377, 5888, 34, 7345, 19391, 6004, 28, 7219, 19403, 6121,
- 22, 7093, 19412, 6239, 15, 6968, 19419, 6359, 9, 6845, 19424, 6479, 3, 6722, 19426, 6600
+ 22, 7093, 19412, 6239, 15, 6968, 19419, 6359, 9, 6845, 19424, 6479, 3, 6722, 19426, 6600,
};
- private static short[] _normalCurveLut1 = new short[]
- {
+ private static readonly short[] _normalCurveLut1 = {
-68, 32639, 69, -5, -200, 32630, 212, -15, -328, 32613, 359, -26, -450, 32586, 512, -36,
-568, 32551, 669, -47, -680, 32507, 832, -58, -788, 32454, 1000, -69, -891, 32393, 1174, -80,
-990, 32323, 1352, -92, -1084, 32244, 1536, -103, -1173, 32157, 1724, -115, -1258, 32061, 1919, -128,
@@ -80,11 +77,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
-180, 2747, 31593, -1554, -167, 2532, 31723, -1486, -153, 2322, 31844, -1414, -140, 2118, 31956, -1338,
-128, 1919, 32061, -1258, -115, 1724, 32157, -1173, -103, 1536, 32244, -1084, -92, 1352, 32323, -990,
-80, 1174, 32393, -891, -69, 1000, 32454, -788, -58, 832, 32507, -680, -47, 669, 32551, -568,
- -36, 512, 32586, -450, -26, 359, 32613, -328, -15, 212, 32630, -200, -5, 69, 32639, -68
+ -36, 512, 32586, -450, -26, 359, 32613, -328, -15, 212, 32630, -200, -5, 69, 32639, -68,
};
- private static short[] _normalCurveLut2 = new short[]
- {
+ private static readonly short[] _normalCurveLut2 = {
3195, 26287, 3329, -32, 3064, 26281, 3467, -34, 2936, 26270, 3608, -38, 2811, 26253, 3751, -42,
2688, 26230, 3897, -46, 2568, 26202, 4046, -50, 2451, 26169, 4199, -54, 2338, 26130, 4354, -58,
2227, 26085, 4512, -63, 2120, 26035, 4673, -67, 2015, 25980, 4837, -72, 1912, 25919, 5004, -76,
@@ -116,13 +112,12 @@ namespace Ryujinx.Audio.Renderer.Dsp
-98, 5701, 25621, 1531, -92, 5522, 25704, 1622, -87, 5347, 25780, 1716, -81, 5174, 25852, 1813,
-76, 5004, 25919, 1912, -72, 4837, 25980, 2015, -67, 4673, 26035, 2120, -63, 4512, 26085, 2227,
-58, 4354, 26130, 2338, -54, 4199, 26169, 2451, -50, 4046, 26202, 2568, -46, 3897, 26230, 2688,
- -42, 3751, 26253, 2811, -38, 3608, 26270, 2936, -34, 3467, 26281, 3064, -32, 3329, 26287, 3195
+ -42, 3751, 26253, 2811, -38, 3608, 26270, 2936, -34, 3467, 26281, 3064, -32, 3329, 26287, 3195,
};
#endregion
#region "High Quality Lookup Tables"
- private static short[] _highCurveLut0 = new short[]
- {
+ private static readonly short[] _highCurveLut0 = {
-582, -23, 8740, 16386, 8833, 8, -590, 0, -573, -54, 8647, 16385, 8925, 40, -598, -1,
-565, -84, 8555, 16383, 9018, 72, -606, -1, -557, -113, 8462, 16379, 9110, 105, -614, -2,
-549, -142, 8370, 16375, 9203, 139, -622, -2, -541, -170, 8277, 16369, 9295, 173, -630, -3,
@@ -189,8 +184,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
-1, -598, 40, 8925, 16385, 8647, -54, -573, 0, -590, 8, 8833, 16386, 8740, -23, -582,
};
- private static short[] _highCurveLut1 = new short[]
- {
+ private static readonly short[] _highCurveLut1 = {
-12, 47, -134, 32767, 81, -16, 2, 0, -26, 108, -345, 32760, 301, -79, 17, -1,
-40, 168, -552, 32745, 526, -144, 32, -2, -53, 226, -753, 32723, 755, -210, 47, -3,
-66, 284, -950, 32694, 989, -277, 63, -5, -78, 340, -1143, 32658, 1226, -346, 79, -6,
@@ -257,8 +251,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
-1, 17, -79, 301, 32760, -345, 108, -26, 0, 2, -16, 81, 32767, -134, 47, -12,
};
- private static short[] _highCurveLut2 = new short[]
- {
+ private static readonly short[] _highCurveLut2 = {
418, -2538, 6118, 24615, 6298, -2563, 417, 0, 420, -2512, 5939, 24611, 6479, -2588, 415, 1,
421, -2485, 5761, 24605, 6662, -2612, 412, 2, 422, -2458, 5585, 24595, 6846, -2635, 409, 3,
423, -2430, 5410, 24582, 7030, -2658, 406, 4, 423, -2402, 5236, 24565, 7216, -2680, 403, 5,
@@ -326,13 +319,13 @@ namespace Ryujinx.Audio.Renderer.Dsp
};
#endregion
- private static float[] _normalCurveLut0F;
- private static float[] _normalCurveLut1F;
- private static float[] _normalCurveLut2F;
+ private static readonly float[] _normalCurveLut0F;
+ private static readonly float[] _normalCurveLut1F;
+ private static readonly float[] _normalCurveLut2F;
- private static float[] _highCurveLut0F;
- private static float[] _highCurveLut1F;
- private static float[] _highCurveLut2F;
+ private static readonly float[] _highCurveLut0F;
+ private static readonly float[] _highCurveLut1F;
+ private static readonly float[] _highCurveLut2F;
static ResamplerHelper()
{
@@ -373,7 +366,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
return _normalCurveLut1F;
}
- else if (ratio > 1.333313f)
+
+ if (ratio > 1.333313f)
{
return _normalCurveLut0F;
}
@@ -514,7 +508,8 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
return _highCurveLut1F;
}
- else if (ratio > 1.333313f)
+
+ if (ratio > 1.333313f)
{
return _highCurveLut0F;
}
@@ -601,4 +596,4 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/AdpcmLoopContext.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/AdpcmLoopContext.cs
index 821a135e..f9ef201f 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/AdpcmLoopContext.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/AdpcmLoopContext.cs
@@ -9,4 +9,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
public short History0;
public short History1;
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/AuxiliaryBufferHeader.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/AuxiliaryBufferHeader.cs
index 4e8d11e4..97bbc80c 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/AuxiliaryBufferHeader.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/AuxiliaryBufferHeader.cs
@@ -71,4 +71,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
public AuxiliaryBufferInfo CpuBufferInfo;
public AuxiliaryBufferInfo DspBufferInfo;
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/BiquadFilterState.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/BiquadFilterState.cs
index 4220e6d5..f9a32b3f 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/BiquadFilterState.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/BiquadFilterState.cs
@@ -10,4 +10,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
public float State2;
public float State3;
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs
index 2a1e7f83..c56fa078 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/DelayState.cs
@@ -64,4 +64,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/LimiterState.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/LimiterState.cs
index 0560757c..80d1cb62 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/LimiterState.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/LimiterState.cs
@@ -20,12 +20,12 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
DetectorAverage.AsSpan().Fill(new ExponentialMovingAverage(0.0f));
CompressionGainAverage.AsSpan().Fill(new ExponentialMovingAverage(1.0f));
- DelayedSampleBufferPosition.AsSpan().Fill(0);
- DelayedSampleBuffer.AsSpan().Fill(0.0f);
+ DelayedSampleBufferPosition.AsSpan().Clear();
+ DelayedSampleBuffer.AsSpan().Clear();
UpdateParameter(ref parameter);
}
- public void UpdateParameter(ref LimiterParameter parameter) { }
+ public static void UpdateParameter(ref LimiterParameter parameter) { }
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs
index c0646603..5056b750 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/Reverb3dState.cs
@@ -6,11 +6,11 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
{
public class Reverb3dState
{
- private readonly float[] FdnDelayMinTimes = new float[4] { 5.0f, 6.0f, 13.0f, 14.0f };
- private readonly float[] FdnDelayMaxTimes = new float[4] { 45.704f, 82.782f, 149.94f, 271.58f };
- private readonly float[] DecayDelayMaxTimes1 = new float[4] { 17.0f, 13.0f, 9.0f, 7.0f };
- private readonly float[] DecayDelayMaxTimes2 = new float[4] { 19.0f, 11.0f, 10.0f, 6.0f };
- private readonly float[] EarlyDelayTimes = new float[20] { 0.017136f, 0.059154f, 0.16173f, 0.39019f, 0.42526f, 0.45541f, 0.68974f, 0.74591f, 0.83384f, 0.8595f, 0.0f, 0.075024f, 0.16879f, 0.2999f, 0.33744f, 0.3719f, 0.59901f, 0.71674f, 0.81786f, 0.85166f };
+ private readonly float[] _fdnDelayMinTimes = new float[4] { 5.0f, 6.0f, 13.0f, 14.0f };
+ private readonly float[] _fdnDelayMaxTimes = new float[4] { 45.704f, 82.782f, 149.94f, 271.58f };
+ private readonly float[] _decayDelayMaxTimes1 = new float[4] { 17.0f, 13.0f, 9.0f, 7.0f };
+ private readonly float[] _decayDelayMaxTimes2 = new float[4] { 19.0f, 11.0f, 10.0f, 6.0f };
+ private readonly float[] _earlyDelayTimes = new float[20] { 0.017136f, 0.059154f, 0.16173f, 0.39019f, 0.42526f, 0.45541f, 0.68974f, 0.74591f, 0.83384f, 0.8595f, 0.0f, 0.075024f, 0.16879f, 0.2999f, 0.33744f, 0.3719f, 0.59901f, 0.71674f, 0.81786f, 0.85166f };
public readonly float[] EarlyGain = new float[20] { 0.67096f, 0.61027f, 1.0f, 0.35680f, 0.68361f, 0.65978f, 0.51939f, 0.24712f, 0.45945f, 0.45021f, 0.64196f, 0.54879f, 0.92925f, 0.38270f, 0.72867f, 0.69794f, 0.5464f, 0.24563f, 0.45214f, 0.44042f };
public IDelayLine[] FdnDelayLines { get; }
@@ -46,9 +46,9 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
for (int i = 0; i < 4; i++)
{
- FdnDelayLines[i] = new DelayLine3d(sampleRate, FdnDelayMaxTimes[i]);
- DecayDelays1[i] = new DecayDelay(new DelayLine3d(sampleRate, DecayDelayMaxTimes1[i]));
- DecayDelays2[i] = new DecayDelay(new DelayLine3d(sampleRate, DecayDelayMaxTimes2[i]));
+ FdnDelayLines[i] = new DelayLine3d(sampleRate, _fdnDelayMaxTimes[i]);
+ DecayDelays1[i] = new DecayDelay(new DelayLine3d(sampleRate, _decayDelayMaxTimes1[i]));
+ DecayDelays2[i] = new DecayDelay(new DelayLine3d(sampleRate, _decayDelayMaxTimes2[i]));
}
PreDelayLine = new DelayLine3d(sampleRate, 400);
@@ -63,7 +63,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
EarlyDelayTime = new uint[20];
DryGain = parameter.DryGain;
- PreviousFeedbackOutputDecayed.AsSpan().Fill(0);
+ PreviousFeedbackOutputDecayed.AsSpan().Clear();
PreviousPreDelayValue = 0;
EarlyReflectionsGain = FloatingPointHelper.Pow10(Math.Min(parameter.RoomGain + parameter.ReflectionsGain, 5000.0f) / 2000.0f);
@@ -91,7 +91,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
for (int i = 0; i < FdnDelayLines.Length; i++)
{
- FdnDelayLines[i].SetDelay(FdnDelayMinTimes[i] + (parameter.Density / 100 * (FdnDelayMaxTimes[i] - FdnDelayMinTimes[i])));
+ FdnDelayLines[i].SetDelay(_fdnDelayMinTimes[i] + (parameter.Density / 100 * (_fdnDelayMaxTimes[i] - _fdnDelayMinTimes[i])));
uint tempSampleCount = FdnDelayLines[i].CurrentSampleCount + DecayDelays1[i].CurrentSampleCount + DecayDelays2[i].CurrentSampleCount;
@@ -111,9 +111,9 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
for (int i = 0; i < EarlyDelayTime.Length; i++)
{
- uint sampleCount = Math.Min(IDelayLine.GetSampleCount(sampleRate, (parameter.ReflectionDelay * 1000.0f) + (EarlyDelayTimes[i] * 1000.0f * ((parameter.ReverbDelayTime * 0.9998f) + 0.02f))), PreDelayLine.SampleCountMax);
+ uint sampleCount = Math.Min(IDelayLine.GetSampleCount(sampleRate, (parameter.ReflectionDelay * 1000.0f) + (_earlyDelayTimes[i] * 1000.0f * ((parameter.ReverbDelayTime * 0.9998f) + 0.02f))), PreDelayLine.SampleCountMax);
EarlyDelayTime[i] = sampleCount;
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs b/src/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs
index 1ffabe05..2f574f47 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/State/ReverbState.cs
@@ -7,7 +7,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
{
public class ReverbState
{
- private static readonly float[] FdnDelayTimes = new float[20]
+ private static readonly float[] _fdnDelayTimes = new float[20]
{
// Room
53.953247f, 79.192566f, 116.238770f, 130.615295f,
@@ -21,7 +21,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
53.953247f, 79.192566f, 116.238770f, 170.615295f,
};
- private static readonly float[] DecayDelayTimes = new float[20]
+ private static readonly float[] _decayDelayTimes = new float[20]
{
// Room
7f, 9f, 13f, 17f,
@@ -35,7 +35,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
7f, 9f, 13f, 17f,
};
- private static readonly float[] EarlyDelayTimes = new float[50]
+ private static readonly float[] _earlyDelayTimes = new float[50]
{
// Room
0.0f, 3.5f, 2.8f, 3.9f, 2.7f, 13.4f, 7.9f, 8.4f, 9.9f, 12.0f,
@@ -46,10 +46,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
// Cathedral
33.1f, 43.3f, 22.8f, 37.9f, 14.9f, 35.3f, 17.9f, 34.2f, 0.0f, 43.3f,
// Disabled
- 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f
+ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
};
- private static readonly float[] EarlyGainBase = new float[50]
+ private static readonly float[] _earlyGainBase = new float[50]
{
// Room
0.70f, 0.68f, 0.70f, 0.68f, 0.70f, 0.68f, 0.70f, 0.68f, 0.68f, 0.68f,
@@ -60,10 +60,10 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
// Cathedral
0.93f, 0.92f, 0.87f, 0.86f, 0.94f, 0.81f, 0.80f, 0.77f, 0.76f, 0.65f,
// Disabled
- 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f
+ 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f, 0.00f,
};
- private static readonly float[] PreDelayTimes = new float[5]
+ private static readonly float[] _preDelayTimes = new float[5]
{
// Room
12.5f,
@@ -74,7 +74,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
// Cathedral
50.0f,
// Disabled
- 0.0f
+ 0.0f,
};
public DelayLine[] FdnDelayLines { get; }
@@ -93,14 +93,14 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
private const int FixedPointPrecision = 14;
- private ReadOnlySpan<float> GetFdnDelayTimesByLateMode(ReverbLateMode lateMode)
+ private static ReadOnlySpan<float> GetFdnDelayTimesByLateMode(ReverbLateMode lateMode)
{
- return FdnDelayTimes.AsSpan((int)lateMode * 4, 4);
+ return _fdnDelayTimes.AsSpan((int)lateMode * 4, 4);
}
- private ReadOnlySpan<float> GetDecayDelayTimesByLateMode(ReverbLateMode lateMode)
+ private static ReadOnlySpan<float> GetDecayDelayTimesByLateMode(ReverbLateMode lateMode)
{
- return DecayDelayTimes.AsSpan((int)lateMode * 4, 4);
+ return _decayDelayTimes.AsSpan((int)lateMode * 4, 4);
}
public ReverbState(ref ReverbParameter parameter, ulong workBuffer, bool isLongSizePreDelaySupported)
@@ -148,8 +148,8 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
for (int i = 0; i < 10; i++)
{
- EarlyDelayTime[i] = Math.Min(IDelayLine.GetSampleCount(sampleRate, EarlyDelayTimes[i] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax) + 1;
- EarlyGain[i] = EarlyGainBase[i] * earlyGain;
+ EarlyDelayTime[i] = Math.Min(IDelayLine.GetSampleCount(sampleRate, _earlyDelayTimes[i] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax) + 1;
+ EarlyGain[i] = _earlyGainBase[i] * earlyGain;
}
if (parameter.ChannelCount == 2)
@@ -158,7 +158,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
EarlyGain[5] = EarlyGain[5] * 0.5f;
}
- PreDelayLineDelayTime = Math.Min(IDelayLine.GetSampleCount(sampleRate, PreDelayTimes[(int)parameter.EarlyMode] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax);
+ PreDelayLineDelayTime = Math.Min(IDelayLine.GetSampleCount(sampleRate, _preDelayTimes[(int)parameter.EarlyMode] + preDelayTimeInMilliseconds), PreDelayLine.SampleCountMax);
ReadOnlySpan<float> fdnDelayTimes = GetFdnDelayTimesByLateMode(parameter.LateMode);
ReadOnlySpan<float> decayDelayTimes = GetDecayDelayTimesByLateMode(parameter.LateMode);
@@ -201,4 +201,4 @@ namespace Ryujinx.Audio.Renderer.Dsp.State
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/UpsamplerHelper.cs b/src/Ryujinx.Audio/Renderer/Dsp/UpsamplerHelper.cs
index 54a63ace..5732cdb2 100644
--- a/src/Ryujinx.Audio/Renderer/Dsp/UpsamplerHelper.cs
+++ b/src/Ryujinx.Audio/Renderer/Dsp/UpsamplerHelper.cs
@@ -13,11 +13,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
private const int FilterBankLength = 20;
// Bank0 = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
private const int Bank0CenterIndex = 9;
- private static readonly Array20<float> Bank1 = PrecomputeFilterBank(1.0f / 6.0f);
- private static readonly Array20<float> Bank2 = PrecomputeFilterBank(2.0f / 6.0f);
- private static readonly Array20<float> Bank3 = PrecomputeFilterBank(3.0f / 6.0f);
- private static readonly Array20<float> Bank4 = PrecomputeFilterBank(4.0f / 6.0f);
- private static readonly Array20<float> Bank5 = PrecomputeFilterBank(5.0f / 6.0f);
+ private static readonly Array20<float> _bank1 = PrecomputeFilterBank(1.0f / 6.0f);
+ private static readonly Array20<float> _bank2 = PrecomputeFilterBank(2.0f / 6.0f);
+ private static readonly Array20<float> _bank3 = PrecomputeFilterBank(3.0f / 6.0f);
+ private static readonly Array20<float> _bank4 = PrecomputeFilterBank(4.0f / 6.0f);
+ private static readonly Array20<float> _bank5 = PrecomputeFilterBank(5.0f / 6.0f);
private static Array20<float> PrecomputeFilterBank(float offset)
{
@@ -39,7 +39,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
return A0 + A1 * MathF.Cos(2 * MathF.PI * x) + A2 * MathF.Cos(4 * MathF.PI * x);
}
- Array20<float> result = new Array20<float>();
+ Array20<float> result = new();
for (int i = 0; i < FilterBankLength; i++)
{
@@ -58,10 +58,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
{
state.Scale = inputSampleCount switch
{
- 40 => 6.0f,
- 80 => 3.0f,
+ 40 => 6.0f,
+ 80 => 3.0f,
160 => 1.5f,
- _ => throw new ArgumentOutOfRangeException()
+ _ => throw new ArgumentOutOfRangeException(nameof(inputSampleCount), inputSampleCount, null),
};
state.Initialized = true;
}
@@ -105,7 +105,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void NextInput(ref UpsamplerBufferState state, float input)
{
- state.History.AsSpan().Slice(1).CopyTo(state.History.AsSpan());
+ state.History.AsSpan()[1..].CopyTo(state.History.AsSpan());
state.History[HistoryLength - 1] = input;
}
@@ -123,19 +123,19 @@ namespace Ryujinx.Audio.Renderer.Dsp
outputBuffer[i] = state.History[Bank0CenterIndex];
break;
case 1:
- outputBuffer[i] = DoFilterBank(ref state, Bank1);
+ outputBuffer[i] = DoFilterBank(ref state, _bank1);
break;
case 2:
- outputBuffer[i] = DoFilterBank(ref state, Bank2);
+ outputBuffer[i] = DoFilterBank(ref state, _bank2);
break;
case 3:
- outputBuffer[i] = DoFilterBank(ref state, Bank3);
+ outputBuffer[i] = DoFilterBank(ref state, _bank3);
break;
case 4:
- outputBuffer[i] = DoFilterBank(ref state, Bank4);
+ outputBuffer[i] = DoFilterBank(ref state, _bank4);
break;
case 5:
- outputBuffer[i] = DoFilterBank(ref state, Bank5);
+ outputBuffer[i] = DoFilterBank(ref state, _bank5);
break;
}
@@ -152,10 +152,10 @@ namespace Ryujinx.Audio.Renderer.Dsp
outputBuffer[i] = state.History[Bank0CenterIndex];
break;
case 1:
- outputBuffer[i] = DoFilterBank(ref state, Bank2);
+ outputBuffer[i] = DoFilterBank(ref state, _bank2);
break;
case 2:
- outputBuffer[i] = DoFilterBank(ref state, Bank4);
+ outputBuffer[i] = DoFilterBank(ref state, _bank4);
break;
}
@@ -173,11 +173,11 @@ namespace Ryujinx.Audio.Renderer.Dsp
outputBuffer[i] = state.History[Bank0CenterIndex];
break;
case 1:
- outputBuffer[i] = DoFilterBank(ref state, Bank4);
+ outputBuffer[i] = DoFilterBank(ref state, _bank4);
break;
case 2:
NextInput(ref state, inputBuffer[inputBufferIndex++]);
- outputBuffer[i] = DoFilterBank(ref state, Bank2);
+ outputBuffer[i] = DoFilterBank(ref state, _bank2);
break;
}
@@ -185,7 +185,7 @@ namespace Ryujinx.Audio.Renderer.Dsp
}
break;
default:
- throw new ArgumentOutOfRangeException();
+ throw new ArgumentOutOfRangeException(nameof(state), state.Scale, null);
}
}
}