2020-08-18 01:49:37 +00: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 11:05:11 +00:00
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2020-08-18 01:49:37 +00: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 18:46:33 +00:00
|
|
|
}
|