blob: b408e294dc586dc5dc3771ca1975e1e161d07de9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
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);
}
}
}
|