sfFDN
Loading...
Searching...
No Matches
delay_interp.h
1// Copyright (C) 2025 Alexandre St-Onge
2// SPDX-License-Identifier: MIT
3#pragma once
4
5#include "sffdn/audio_buffer.h"
6#include "sffdn/audio_processor.h"
7#include "sffdn/delay.h"
8#include "sffdn/filter.h"
9#include "sffdn/types.h"
10
11#include <cstdint>
12#include <vector>
13
14namespace sfFDN
15{
16
22{
23 public:
28 DelayInterp(const DelayOptions& config = {});
29
31 void Clear() override;
32
34 uint32_t GetMaximumDelay() const;
35
40 void SetMaximumDelay(uint32_t delay);
41
46 void SetDelay(float delay);
47
49 float GetDelay() const;
50
56 float Tick(float input);
57
63 void Process(const AudioBuffer& input, AudioBuffer& output) noexcept override;
64
73 bool AddNextInputs(std::span<const float> input);
74
79 void GetNextOutputs(std::span<float> output);
80
81 uint32_t InputChannelCount() const override
82 {
83 return 1;
84 }
85
86 uint32_t OutputChannelCount() const override
87 {
88 return 1;
89 }
90
91 std::unique_ptr<AudioProcessor> Clone() const override;
92
93 private:
94 Delay delayline_;
95
96 float delay_;
97 uint32_t int_delay_;
98 float frac_delay_;
100
101 AllpassFilter allpass_;
102
103 std::vector<float> lagrange_coeffs_;
104 Fir lagrange_filter_;
105 float linear_last_out_;
106};
107
108} // namespace sfFDN
Implements a simple allpass filter with differential equation .
Definition filter.h:100
A class representing an audio buffer with multiple channels of non-interleaved audio data.
Definition audio_buffer.h:18
Base class for audio processors.
Definition audio_processor.h:23
Delay line with interpolation.
Definition delay_interp.h:22
void SetMaximumDelay(uint32_t delay)
Sets the maximum delay for the delay line.
DelayInterp(const DelayOptions &config={})
Constructs a delay line with interpolation.
uint32_t OutputChannelCount() const override
Returns the number of output channels this processor produces.
Definition delay_interp.h:86
uint32_t GetMaximumDelay() const
Gets the maximum delay-line length.
bool AddNextInputs(std::span< const float > input)
Adds the next input samples to the delay line.
void Clear() override
Clears all internal states of the delay line.
void GetNextOutputs(std::span< float > output)
Gets the next output samples from the delay line.
float GetDelay() const
Returns the current delay in samples.
void SetDelay(float delay)
Sets the delay for the delay line.
uint32_t InputChannelCount() const override
Returns the number of input channels this processor expects.
Definition delay_interp.h:81
void Process(const AudioBuffer &input, AudioBuffer &output) noexcept override
Processes a block of input samples.
std::unique_ptr< AudioProcessor > Clone() const override
Creates a copy of the audio processor.
float Tick(float input)
Processes a single sample through the delay line.
A simple non-interpolating delay line implementation.
Definition delay.h:16
Implements an FIR filter with arbitrary coefficients.
Definition filter.h:222
DelayInterpolationType
Types of interpolation for fractional delay lengths.
Definition types.h:65
Options for configuring delays.
Definition types.h:185