sfFDN
Loading...
Searching...
No Matches
parallel_gains.h
1// Copyright (C) 2025 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 <span>
11#include <vector>
12
13namespace sfFDN
14{
15
16std::unique_ptr<AudioProcessor> MakeParallelGainsFromConfig(const ParallelGainsOptions& options);
17
29{
30 public:
35
40
45 ParallelGains(ParallelGainsMode mode, std::span<const float> gains);
46
51
59 void SetGains(std::span<const float> gains);
60
65 void GetGains(std::span<float> gains) const;
66
77 void Process(const AudioBuffer& input, AudioBuffer& output) noexcept override;
78
82 uint32_t InputChannelCount() const override;
83
87 uint32_t OutputChannelCount() const override;
88
92 void Clear() override;
93
97 std::unique_ptr<AudioProcessor> Clone() const override;
98
99 private:
100 void ProcessBlockMultiplexed(const AudioBuffer& input, AudioBuffer& output);
101 void ProcessBlockDeMultiplexed(const AudioBuffer& input, AudioBuffer& output);
102 void ProcessBlockParallel(const AudioBuffer& input, AudioBuffer& output);
103
104 std::vector<float> gains_;
105 ParallelGainsMode mode_;
106};
107
113{
114 public:
119
124
132 void SetCenterGains(std::span<const float> gains);
133
138 void GetCenterGains(std::span<float> gains) const;
139
143 void SetModulation(std::span<const ModulationOptions> modulation_configs);
144
152 void SetLfoFrequency(std::span<const float> frequencies);
153
163 void SetLfoAmplitude(std::span<const float> amplitudes);
164
172 void SetLfoPhaseOffset(std::span<const float> phase_offsets);
173
184 void Process(const AudioBuffer& input, AudioBuffer& output) noexcept override;
185
187 uint32_t InputChannelCount() const override;
188
190 uint32_t OutputChannelCount() const override;
191
195 void Clear() override;
196
200 std::unique_ptr<AudioProcessor> Clone() const override;
201
202 private:
203 void ProcessBlockMultiplexed(const AudioBuffer& input, AudioBuffer& output);
204 void ProcessBlockDeMultiplexed(const AudioBuffer& input, AudioBuffer& output);
205 void ProcessBlockParallel(const AudioBuffer& input, AudioBuffer& output);
206
207 ParallelGainsMode mode_;
208 std::vector<SineWave> lfos_;
209};
210
211} // namespace sfFDN
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
A parallel gains processor.
Definition parallel_gains.h:29
void SetGains(std::span< const float > gains)
Sets the gains for each channel.
void Clear() override
Clears the internal state of the processor.
uint32_t OutputChannelCount() const override
Gets the number of output channels supported.
std::unique_ptr< AudioProcessor > Clone() const override
Creates a copy of the ParallelGains processor.
void GetGains(std::span< float > gains) const
Gets the gains for each channel.
void SetMode(ParallelGainsMode mode)
Sets the processing mode.
void Process(const AudioBuffer &input, AudioBuffer &output) noexcept override
Processes the audio buffer.
ParallelGains(const ParallelGainsOptions &options)
Constructs a ParallelGains processor.
uint32_t InputChannelCount() const override
Gets the number of input channels supported.
ParallelGains(ParallelGainsMode mode, std::span< const float > gains)
Constructs a ParallelGains processor.
ParallelGains(ParallelGainsMode mode)
Constructs a ParallelGains processor.
A time-varying parallel gains processor.
Definition parallel_gains.h:113
TimeVaryingParallelGains(const ParallelGainsOptions &options)
Constructs a TimeVaryingParallelGains processor.
void SetLfoAmplitude(std::span< const float > amplitudes)
Sets the LFO amplitude for each channel.
void SetLfoFrequency(std::span< const float > frequencies)
Sets the LFO frequency for each channel.
void SetLfoPhaseOffset(std::span< const float > phase_offsets)
Sets the LFO phase offset for each channel.
uint32_t InputChannelCount() const override
Gets the number of input channels.
void SetModulation(std::span< const ModulationOptions > modulation_configs)
Sets the modulation options for each channel.
std::unique_ptr< AudioProcessor > Clone() const override
Creates a copy of the TimeVaryingParallelGains processor.
void SetMode(ParallelGainsMode mode)
Sets the processing mode.
void Process(const AudioBuffer &input, AudioBuffer &output) noexcept override
Processes the audio buffer.
void GetCenterGains(std::span< float > gains) const
Gets the center gains for each channel.
uint32_t OutputChannelCount() const override
Gets the number of output channels.
void Clear() override
Clears the internal state of the processor.
void SetCenterGains(std::span< const float > gains)
Sets the center gains for each channel.
ParallelGainsMode
Enumeration for parallel gain processing modes.
Definition types.h:109
Options for configuring parallel gain processing.
Definition types.h:174