aboutsummaryrefslogtreecommitdiff
path: root/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs
diff options
context:
space:
mode:
authormerry <git@mary.rs>2023-01-15 04:20:49 +0000
committerGitHub <noreply@github.com>2023-01-15 05:20:49 +0100
commit41bba5310a5324f54fa5c0200aff2bf697ced000 (patch)
treea1db4c44f1e5f1b090c8ddabd8ebc07fb275966d /Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs
parent8071c8c8c044ee56bc7578a4ba3178d2d03733db (diff)
Audren: Implement polyphase upsampler (#4256)1.1.558
* Audren: Implement polyphase upsampler * prefer shifting to modulo * prefer MathF * fix nits * rm ResampleForUpsampler * oop * Array20 * nits
Diffstat (limited to 'Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs')
-rw-r--r--Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs12
1 files changed, 7 insertions, 5 deletions
diff --git a/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs b/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs
index 1617a642..0870d59c 100644
--- a/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs
+++ b/Ryujinx.Audio/Renderer/Dsp/Command/UpsampleCommand.cs
@@ -40,6 +40,12 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
info.InputBufferIndices[i] = (ushort)(bufferOffset + inputBufferOffset[i]);
}
+ if (info.BufferStates?.Length != (int)inputCount)
+ {
+ // Keep state if possible.
+ info.BufferStates = new UpsamplerBufferState[(int)inputCount];
+ }
+
UpsamplerInfo = info;
}
@@ -50,8 +56,6 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
public void Process(CommandList context)
{
- float ratio = (float)InputSampleRate / Constants.TargetSampleRate;
-
uint bufferCount = Math.Min(BufferCount, UpsamplerInfo.SourceSampleCount);
for (int i = 0; i < bufferCount; i++)
@@ -59,9 +63,7 @@ namespace Ryujinx.Audio.Renderer.Dsp.Command
Span<float> inputBuffer = context.GetBuffer(UpsamplerInfo.InputBufferIndices[i]);
Span<float> outputBuffer = GetBuffer(UpsamplerInfo.InputBufferIndices[i], (int)UpsamplerInfo.SampleCount);
- float fraction = 0.0f;
-
- ResamplerHelper.ResampleForUpsampler(outputBuffer, inputBuffer, ratio, ref fraction, (int)(InputSampleCount / ratio));
+ UpsamplerHelper.Upsample(outputBuffer, inputBuffer, (int)UpsamplerInfo.SampleCount, (int)InputSampleCount, ref UpsamplerInfo.BufferStates[i]);
}
}
}