aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs')
-rw-r--r--src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs b/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs
new file mode 100644
index 00000000..fd902525
--- /dev/null
+++ b/src/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs
@@ -0,0 +1,37 @@
+using System;
+using System.Runtime.CompilerServices;
+
+namespace Ryujinx.Audio.Renderer.Dsp.Effect
+{
+ public interface IDelayLine
+ {
+ uint CurrentSampleCount { get; }
+ uint SampleCountMax { get; }
+
+ void SetDelay(float delayTime);
+ float Read();
+ float Update(float value);
+
+ float TapUnsafe(uint sampleIndex, int offset);
+ float Tap(uint sampleIndex);
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static float Tap(Span<float> workBuffer, int baseIndex, int sampleIndex, int delaySampleCount)
+ {
+ int targetIndex = baseIndex - sampleIndex;
+
+ if (targetIndex < 0)
+ {
+ targetIndex += delaySampleCount;
+ }
+
+ return workBuffer[targetIndex];
+ }
+
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public static uint GetSampleCount(uint sampleRate, float delayTime)
+ {
+ return (uint)MathF.Round(sampleRate * delayTime);
+ }
+ }
+} \ No newline at end of file