37 template<u
int32_t MaxWindow>
43 template<
class InterpolatorT = Thiran1stInterpolator>
55 JPL_ASSERT(delay >= 0.0f &&
"Delay must be non-negative");
65 auto data = delayLine.template GetReadWindow<InterpolatorType::InputLength>(
DelaySample);
83 mGainA = 0.5f * (1.0f + cosf(std::numbers::pi_v<float> * alpha));
84 mGainB = 1.0f - mGainA;
91 JPL_ASSERT(delay >= 0.0f &&
"Delay must be non-negative");
96 mLastDelay = mNewDelay;
97 mNewDelay =
static_cast<int>(delay);
112 const float tapA = delayLine.template GetReadWindow<InputLength>(mLastDelay);
113 const float tapB = delayLine.template GetReadWindow<InputLength>(mNewDelay);
114 return tapA * mGainA + tapB * mGainB;
129 template<u
int32_t MaxWindow = 2>
137 std::vector<float> mBuffer;
144 , mBuffer(mIndex.GetTotalSize(), 0.0f)
156 template<
class TapType>
requires (TapType::InterpolatorType::InputLength <=
WindowSize)
160 tap.SetDelay(initialDelay);
164 template<
class Interpolator>
requires (Interpolator::InputLength <=
WindowSize)
174 inline const float*
raw()
const {
return mBuffer.data(); }
178 std::fill(mBuffer.begin(), mBuffer.end(), 0.0f);
187 const auto [writeIndex, mirrorIndex] = mIndex--;
189 mBuffer[writeIndex] = sample;
190 mBuffer[mirrorIndex] = sample;
194 const auto writeIndex = mIndex--;
195 mBuffer[writeIndex] = sample;
201 template<u
int32_t WindowLength>
requires (WindowLength > 1 && WindowLength <=
WindowSize)
202 inline std::span<const float, WindowLength>
GetReadWindow(uint32_t intDelay)
const
206 const uint32_t readIndex = mIndex.
GetOffset(intDelay + WindowLength);
210 const uint32_t readIndex = mIndex.
GetOffset(intDelay + 1);
212 return std::span<const float, WindowLength>(&mBuffer[readIndex], WindowLength);
216 template<u
int32_t WindowLength>
requires (WindowLength <= 1)
220 static constexpr uint32_t windowLength = 1;
222 const uint32_t readIndex = mIndex.
GetOffset(intDelay + windowLength);
226 const uint32_t readIndex = mIndex.
GetOffset(intDelay + 1);
228 return mBuffer[readIndex];
#define JPL_ASSERT(inExpression,...)
Main assert macro, usage: JPL_ASSERT(condition, message) or JPL_ASSERT(condition)
Definition ErrorReporting.h:80
Forward declaration.
Definition AbstractIndex.h:83
uint32_t GetRingSize() const
Definition AbstractIndex.h:106
void Reset()
Definition AbstractIndex.h:108
uint32_t GetOffset(uint32_t offset) const
Get the index of the sample at an offset from the WriteIndex.
Definition AbstractIndex.h:141
Index GetCurrent() const
Definition AbstractIndex.h:107
uint32_t GetTotalSize() const
Get total size of the ring buffer including MaxWindow mirror length.
Definition AbstractIndex.h:105
Forward declaration.
Definition DelayLine.h:131
uint32_t GetSize() const
Definition DelayLine.h:172
void Resize(uint32_t newSize)
Definition DelayLine.h:150
DelayLine()
Definition DelayLine.h:148
uint32_t GetWriteIndex() const
Definition DelayLine.h:173
std::span< const float, WindowLength > GetReadWindow(uint32_t intDelay) const
Definition DelayLine.h:202
void Clear()
Definition DelayLine.h:176
static constexpr uint32_t WindowSize
Definition DelayLine.h:133
void Push(float sample)
Definition DelayLine.h:183
float GetReadWindow(uint32_t intDelay) const
Definition DelayLine.h:217
static DelayTap< Interpolator > CreateTap(float initialDelay=0.0f)
Definition DelayLine.h:165
const float * raw() const
Definition DelayLine.h:174
static TapType CreateTap(float initialDelay=0.0f)
Definition DelayLine.h:157
DelayLine(uint32_t minSize)
Definition DelayLine.h:142
Definition AcousticMaterial.h:36
AbstractRingIndex< MaxWindow, RingImpl::EWriteDirection::Backward, RingImpl::EOperationMode::Pow2BitManip > RingIndexBackwardFast
Definition AbstractIndex.h:67
uint32_t WriteIndex
Definition AbstractIndex.h:90
Definition DelayLine.h:74
float Process(const DelayLine &delayLine)
Process delay crossfade and get the delayed sample.
Definition DelayLine.h:110
void SetDelay(float delay)
Definition DelayLine.h:89
void SetCrossfade(float alpha)
Definition DelayLine.h:81
static constexpr uint32_t InputLength
Definition DelayLine.h:75
Definition DelayLine.h:45
InterpolatorType Interpolator
Definition DelayLine.h:50
InterpolatorT InterpolatorType
Definition DelayLine.h:47
int DelaySample
Definition DelayLine.h:49
float Process(const DelayLine &delayLine)
Process delay interpolation and get the delayed sample.
Definition DelayLine.h:63
void SetDelay(float delay)
Set delay is in samples, can be fractional.
Definition DelayLine.h:53