sfFDN
Loading...
Searching...
No Matches
delaybank.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/delay_interp.h"
9#include "sffdn/types.h"
10
11#include <cstdint>
12#include <span>
13#include <vector>
14
15namespace sfFDN
16{
17
26{
27 public:
33 DelayBank(const DelayBankOptions& config = {});
34
43 void SetDelays(std::span<const float> delays, uint32_t block_size = 512);
44
49 std::vector<float> GetDelays() const;
50
56 uint32_t InputChannelCount() const noexcept SFFDN_NONBLOCKING override;
57
63 uint32_t OutputChannelCount() const noexcept SFFDN_NONBLOCKING override;
64
69 void Clear() override;
70
78 void Process(const AudioBuffer& input, AudioBuffer& output) noexcept SFFDN_NONBLOCKING override;
79
85 void AddNextInputs(const AudioBuffer& input) noexcept SFFDN_NONBLOCKING;
86
92 void GetNextOutputs(AudioBuffer& output) noexcept SFFDN_NONBLOCKING;
93
97 std::unique_ptr<AudioProcessor> Clone() const override;
98
99 private:
100 std::vector<DelayInterp> delays_;
101 uint32_t block_size_{128};
103};
104} // namespace sfFDN
A class representing an audio buffer with multiple channels of non-interleaved audio data.
Definition audio_buffer.h:20
Base class for audio processors.
Definition audio_processor.h:24
A bank of parallel delay lines, each with its own delay setting.
Definition delaybank.h:26
uint32_t InputChannelCount() const noexcept SFFDN_NONBLOCKING override
Returns the number of input channels this processor expects.
void SetDelays(std::span< const float > delays, uint32_t block_size=512)
Sets the delay values for each channel in the delay bank.
std::vector< float > GetDelays() const
Returns the current delays for each delay line in the bank.
std::unique_ptr< AudioProcessor > Clone() const override
Creates a copy of the delay bank.
void GetNextOutputs(AudioBuffer &output) noexcept SFFDN_NONBLOCKING
Retrieves the next output samples from each delay line in the bank.
void AddNextInputs(const AudioBuffer &input) noexcept SFFDN_NONBLOCKING
Adds the next input samples to each delay line in the bank.
void Clear() override
Clears the internal delay buffers.
uint32_t OutputChannelCount() const noexcept SFFDN_NONBLOCKING override
Returns the number of output channels this processor produces.
void Process(const AudioBuffer &input, AudioBuffer &output) noexcept SFFDN_NONBLOCKING override
Processes a block of multi-channel audio.
DelayBank(const DelayBankOptions &config={})
Constructs a delay bank with a specified set of delays and block size.
Delay line with interpolation.
Definition delay_interp.h:23
DelayInterpolationType
Types of interpolation for fractional delay lengths.
Definition types.h:67
@ None
No interpolation. The delay length will be rounded to the nearest integer value.
Options for configuring a delay bank.
Definition types.h:232