MostlyHarmless 0.0.1
 
Loading...
Searching...
No Matches
marvin_DelayLine.h
Go to the documentation of this file.
1// ========================================================================================================
2// _______ _______ ______ ___ ___ _______ _______
3// | | | _ | __ \ | |_ _| | |
4// | | | < | |_| |_| |
5// |__|_|__|___|___|___|__|\_____/|_______|__|____|
6//
7// This file is part of the Marvin open source library and is licensed under the terms of the MIT License.
8//
9// ========================================================================================================
10
11#ifndef MARVIN_DELAYLINE_H
12#define MARVIN_DELAYLINE_H
14#include <vector>
15namespace marvin::dsp {
24
30 template <FloatType SampleType, DelayLineInterpolationType InterpolationType = DelayLineInterpolationType::Linear>
31 class DelayLine {
32 public:
41 explicit DelayLine(int maximumDelayInSamples);
47 void setDelay(SampleType newDelayInSamples);
52 [[nodiscard]] SampleType getDelay() const noexcept;
57 void initialise(double sampleRate);
63 void setMaximumDelayInSamples(int maxDelayInSamples);
68 [[nodiscard]] int getMaximumDelayInSamples() const noexcept;
72 void reset();
77 void pushSample(SampleType sample);
86 [[nodiscard]] SampleType popSample(SampleType delayInSamples = -1, bool updateReadPointer = true);
87
92 [[nodiscard]] int getReadPos() const noexcept;
93
98 [[nodiscard]] int getWritePos() const noexcept;
99
100 private:
101 [[nodiscard]] SampleType interpolateSample();
102 void updateInternalVariables();
103 double m_sampleRate{};
104 std::vector<SampleType> m_bufferData{};
105 int m_writePos{ 0 }, m_readPos{ 0 };
106 SampleType m_delay{ 0.0 };
107 SampleType m_delayFrac{ 0.0 };
108 int m_delayInt{ 0 };
109 int m_totalSize{ 4 };
110 };
111
112} // namespace marvin::dsp
113#endif
void setDelay(SampleType newDelayInSamples)
int getWritePos() const noexcept
int getReadPos() const noexcept
void setMaximumDelayInSamples(int maxDelayInSamples)
SampleType getDelay() const noexcept
SampleType popSample(SampleType delayInSamples=-1, bool updateReadPointer=true)
DelayLine(int maximumDelayInSamples)
void initialise(double sampleRate)
void pushSample(SampleType sample)
int getMaximumDelayInSamples() const noexcept
DSP helper and utility functions.
Definition marvin_DelayLine.h:15
DelayLineInterpolationType
Enum to configure the type of interpolation an instance of marvin::dsp::DelayLine should use.
Definition marvin_DelayLine.h:19
@ Linear
Definition marvin_DelayLine.h:21
@ Lagrange3rd
Definition marvin_DelayLine.h:22
@ None
Definition marvin_DelayLine.h:20