Archived
1
0
Fork 0
forked from Mirror/Ryujinx
This repository has been archived on 2024-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
jinx/Ryujinx.Audio/Renderer/Dsp/Effect/IDelayLine.cs

37 lines
1 KiB
C#
Raw Normal View History

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);
}
}
}