2020-08-17 21:49:37 -04: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 07:05:11 -04:00
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2020-08-17 21:49:37 -04: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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|