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