2020-08-18 02:49:37 +01:00
|
|
|
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);
|
|
|
|
|
2021-07-18 12:05:11 +01:00
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2020-08-18 02:49:37 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2022-07-25 19:46:33 +01:00
|
|
|
}
|