sfFDN
Loading...
Searching...
No Matches
time_varying_feedback_matrix.h
1// Copyright (C) 2026 Alexandre St-Onge
2// SPDX-License-Identifier: MIT
3#pragma once
4
5#include "sffdn/audio_processor.h"
6#include "sffdn/oscillator.h"
7#include "sffdn/types.h"
8
9#include <cstdint>
10#include <memory>
11#include <span>
12#include <vector>
13
14namespace sfFDN
15{
16
17namespace detail
18{
19class TimeVaryingFeedbackMatrixTestAccess;
20}
21
51{
52 public:
60
65 void SetModulation(std::span<const ModulationOptions> modulation_configs);
66
71 void SetLfoFrequency(std::span<const float> frequencies);
72
78 void SetLfoAmplitude(std::span<const float> amplitudes);
79
84 void SetLfoPhaseOffset(std::span<const float> phase_offsets);
85
89 void SetBaseAngles(std::span<const float> radians);
90
96 void Process(const AudioBuffer& input, AudioBuffer& output) noexcept SFFDN_NONBLOCKING override;
97
101 uint32_t InputChannelCount() const noexcept SFFDN_NONBLOCKING override;
102
106 uint32_t OutputChannelCount() const noexcept SFFDN_NONBLOCKING override;
107
113 uint32_t RotationBlockCount() const noexcept SFFDN_NONBLOCKING;
114
126 bool GetMatrix(std::span<float> matrix, uint64_t sample_index = 0) const;
127
129 void Clear() override;
130
134 std::unique_ptr<AudioProcessor> Clone() const override;
135
136 private:
137 friend class detail::TimeVaryingFeedbackMatrixTestAccess;
138
140 std::span<const float> custom_base_matrix);
141
142 uint32_t order_;
144 std::vector<float> base_angles_;
145 std::vector<SineWave> lfos_;
146 std::vector<float> lfo_phases_;
147 std::vector<float> schur_basis_;
148 std::vector<uint32_t> rotation_starts_;
149 std::vector<float> scalar_signs_;
150 std::vector<float> scratch_;
151};
152
153} // 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 sine wave oscillator.
Definition oscillator.h:33
An orthogonal time-varying feedback matrix for an FDN.
Definition time_varying_feedback_matrix.h:51
void Clear() override
Resets the phase of all LFOs to their configured phase offsets.
TimeVaryingFeedbackMatrix(const TimeVaryingFeedbackMatrixOptions &options)
Constructs a time-varying feedback matrix.
void SetBaseAngles(std::span< const float > radians)
Sets the base rotation angle for each rotation block.
void Process(const AudioBuffer &input, AudioBuffer &output) noexcept SFFDN_NONBLOCKING override
Processes the audio buffer.
void SetLfoPhaseOffset(std::span< const float > phase_offsets)
Sets the LFO phase offset for each rotation block.
void SetLfoFrequency(std::span< const float > frequencies)
Sets the LFO frequency for each rotation block.
bool GetMatrix(std::span< float > matrix, uint64_t sample_index=0) const
Materializes the feedback matrix that Process applies at a given sample index.
void SetModulation(std::span< const ModulationOptions > modulation_configs)
Sets the modulation options for each rotation block.
uint32_t RotationBlockCount() const noexcept SFFDN_NONBLOCKING
Gets the number of 2x2 rotation blocks.
std::unique_ptr< AudioProcessor > Clone() const override
Creates a copy of the time-varying feedback matrix.
void SetLfoAmplitude(std::span< const float > amplitudes)
Sets the LFO amplitude for each rotation block.
uint32_t InputChannelCount() const noexcept SFFDN_NONBLOCKING override
Gets the number of input channels.
uint32_t OutputChannelCount() const noexcept SFFDN_NONBLOCKING override
Gets the number of output channels.
TimeVaryingMatrixMode
Construction modes for a TimeVaryingFeedbackMatrix.
Definition types.h:127
Options for configuring a TimeVaryingFeedbackMatrix.
Definition types.h:197