3#include <nlohmann/json.hpp>
22 using Ts::operator()...;
28constexpr uint32_t kDefaultSampleRate = 48000;
29constexpr uint32_t kDefaultBlockSize = 128;
157 std::optional<float>
arg{std::nullopt};
200 std::vector<ModulationOptions>
212 std::vector<ModulationOptions>
221 uint32_t max_delay{512};
225 std::optional<sfFDN::ModulationOptions> lfo_config{
236 uint32_t block_size{kDefaultBlockSize};
245 std::vector<float> delays;
247 uint32_t max_delay{0};
251 std::vector<ModulationOptions> time_varying_config;
293 std::vector<std::pair<uint32_t, float>> coeffs;
299 std::vector<FilterCoefficients> coeffs;
305 std::vector<float> coeffs{1.f};
310 std::vector<std::vector<float>> coeffs;
317 std::vector<float> delays;
318 std::vector<float> gains;
320 bool parallel{
false};
328 std::vector<SchroederAllpassSectionOptions> sections;
340 std::vector<ModulationOptions>
348 std::vector<TimeVaryingSchroederAllpassSectionOptions> sections;
377 float blend{0.7071f};
378 float feedforward{1.f};
379 float feedback{0.7071f};
392 std::vector<DattorroDelayOptions> delays;
420 std::vector<std::optional<ControllableFullWaveRectifierOptions>> channels;
440 std::vector<std::optional<SignalDependentFractionalDelayOptions>> channels;
466 std::vector<std::optional<RingModulatorOptions>> channels;
476 float sample_rate = kDefaultSampleRate;
488 std::array<float, 2>
t60s{1.f, 0.5f};
491 float sample_rate = kDefaultSampleRate;
500 std::array<float, 3> t60s{1.f, 0.5f, 0.25f};
503 std::array<float, 2> freqs{800.f, 8000.f};
504 float q = 1.f / std::numbers::sqrt2_v<float>;
506 float sample_rate = kDefaultSampleRate;
520 std::array<float, 10>
t60s = {1.f, 0.9f, 0.8f, 0.7f, 0.6f, 0.5f, 0.4f, 0.3f, 0.2f, 0.1f};
535 std::variant<HomogenousFilterOptions, TwoBandFilterOptions, ThreeBandFilterOptions, TenBandFilterOptions>;
559 std::variant<CascadedFeedbackMatrixOptions, ScalarFeedbackMatrixOptions, TimeVaryingFeedbackMatrixOptions>;
587 {ScalarMatrixType::Count,
"Count"}});
609void to_json(nlohmann::json& j,
const ScalarFeedbackMatrixOptions& config);
610void from_json(
const nlohmann::json& j, ScalarFeedbackMatrixOptions& config);
611NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(CascadedFeedbackMatrixOptions, matrix_size, stage_count, sparsity, type,
613NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ModulationOptions, frequency, amplitude, initial_phase);
614NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TimeVaryingFeedbackMatrixOptions, matrix_size, mode, time_varying_config, rng_seed);
615NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ParallelGainsOptions, mode, gains, time_varying_config);
616void to_json(nlohmann::json& j,
const DelayOptions& config);
617void from_json(
const nlohmann::json& j, DelayOptions& config);
618NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DelayBankOptions, delays, block_size, interpolation_type);
619NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DelayBankTimeVaryingOptions, delays, max_delay, interpolation_type,
620 time_varying_config);
621NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FilterCoefficients, b0, b1, b2, a0, a1, a2);
622NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(AllpassFilterOptions, coeff);
623NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SparseFirOptions, coeffs);
624NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(CascadedBiquadsOptions, coeffs);
625NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FirOptions, coeffs);
626NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultichannelFirOptions, coeffs);
627NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SchroederAllpassSectionOptions, delays, gains, parallel);
628NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TimeVaryingSchroederAllpassSectionOptions, delays, gains, time_varying_config,
630NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(DattorroDelayOptions, delay_config, blend, feedforward, feedback);
631NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultichannelSchroederAllpassSectionOptions, sections);
632NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultichannelTimeVaryingSchroederAllpassSectionOptions, sections);
633NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(MultichannelDattorroDelayOptions, delays);
634NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ControllableFullWaveRectifierOptions, alpha, antialiasing, dc_block, sample_rate);
635NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(SignalDependentFractionalDelayOptions, d);
636NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(RingModulatorOptions, frequency, amplitude, initial_phase);
639void to_json(nlohmann::json& j,
const MultichannelControllableFullWaveRectifierOptions& config);
640void from_json(
const nlohmann::json& j, MultichannelControllableFullWaveRectifierOptions& config);
641void to_json(nlohmann::json& j,
const MultichannelSignalDependentFractionalDelayOptions& config);
642void from_json(
const nlohmann::json& j, MultichannelSignalDependentFractionalDelayOptions& config);
643void to_json(nlohmann::json& j,
const MultichannelRingModulatorOptions& config);
644void from_json(
const nlohmann::json& j, MultichannelRingModulatorOptions& config);
645NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(HomogenousFilterOptions, t60, delay, sample_rate);
646NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TwoBandFilterOptions, t60s, delay, sample_rate);
647NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(ThreeBandFilterOptions, t60s, delay, freqs, q, sample_rate);
648NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(TenBandFilterOptions, t60s, delay, sample_rate, shelf_cutoff);
649NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(GraphicEQOptions, gains_db, freqs, sample_rate);
651void to_json(nlohmann::json& j,
const AttenuationFilterBankOptions& config);
652void from_json(
const nlohmann::json& j, AttenuationFilterBankOptions& config);
std::optional< float > arg
Optional argument for certain matrix types. For example, for the VariableDiffusion type,...
Definition types.h:157
float coeff
The coefficient for the allpass filter.
Definition types.h:287
ParallelGainsMode mode
Mode of parallel gain processing.
Definition types.h:209
bool antialiasing
If true, approximate the rectifier with first-order antiderivative antialiasing, equation (4) of the ...
Definition types.h:407
std::vector< ModulationOptions > time_varying_config
One LFO configuration per rotation block, or empty to disable modulation.
Definition types.h:201
float shelf_cutoff
Cutoff frequency for the shelf filters.
Definition types.h:530
float initial_phase
Finite initial phase of the modulation, normalized to [0, 1].
Definition types.h:188
DelayOptions delay_config
Configuration of the delay line.
Definition types.h:375
float frequency
Finite LFO frequency in cycles per sample, normalized by the sample rate.
Definition types.h:181
uint32_t rng_seed
Seed for the RealSchur random orthogonal basis.
Definition types.h:202
bool dc_block
If true, follow the rectifier with a dc blocker with energy compensation, equations (7) and (8) of th...
Definition types.h:410
std::vector< ModulationOptions > time_varying_config
Optional time-varying modulation configuration for each channel.
Definition types.h:213
ScalarMatrixType type
Type of the feedback matrix.
Definition types.h:145
bool parallel
If true, process stages in parallel.
Definition types.h:342
std::vector< float > gains
Base gain values.
Definition types.h:339
uint32_t matrix_size
Size of the feedback matrix.
Definition types.h:142
uint32_t matrix_size
Dimension of the square feedback matrix.
Definition types.h:198
std::array< float, 10 > freqs
Frequency values for the ten bands in Hz.
Definition types.h:551
float alpha
Distortion amount, in [0, 1].
Definition types.h:404
ScalarMatrixType type
Type of the feedback matrix.
Definition types.h:173
std::vector< attenuation_filter_variant_t > filter_configs
Vector of attenuation filter configurations.
Definition types.h:541
float sample_rate
Sample rate in Hz.
Definition types.h:413
float amplitude
Linear gain applied to the modulating sinusoid.
Definition types.h:457
std::vector< float > delays
Fixed delay values in samples.
Definition types.h:338
std::array< float, 2 > t60s
Target T60 values for the low and high bands.
Definition types.h:488
float delay
Delay in samples for the delay line preceding the filter. If set to <= 0, it will be updated automati...
Definition types.h:524
uint32_t rng_seed
Optional. Seed for random number generation when type is Random or RandomHouseholder.
Definition types.h:153
float initial_phase
Initial phase of the modulating sinusoid, normalized to [0, 1].
Definition types.h:459
float sample_rate
Sample rate in Hz. This is used to calculate the filter coefficients based on the specified T60 value...
Definition types.h:527
float amplitude
For TimeVaryingFeedbackMatrix, normalized peak angular deviation with |amplitude| <= 1.
Definition types.h:183
uint32_t stage_count
Number of stages.
Definition types.h:170
std::optional< std::vector< float > > custom_matrix
Optional custom matrix values in row-major order: custom_matrix[row * matrix_size + column] is A[row,...
Definition types.h:150
float d
Interpolation weight, in [0, 1].
Definition types.h:433
std::array< float, 10 > gains_db
Target gains for the ten bands in dB.
Definition types.h:548
std::vector< float > gains
Gain values for each channel.
Definition types.h:211
std::vector< ModulationOptions > time_varying_config
Gain modulation per stage.
Definition types.h:341
float frequency
Modulation frequency in cycles per sample, normalized by the sample rate.
Definition types.h:453
uint32_t matrix_size
Size of the feedback matrix.
Definition types.h:169
TimeVaryingMatrixMode mode
Construction mode for the orthogonal matrix.
Definition types.h:199
float sample_rate
Sample rate in Hz.
Definition types.h:554
float sparsity
Sparsity level (>= 1).
Definition types.h:171
std::array< float, 10 > t60s
Target T60 values for the ten bands.
Definition types.h:520
float gain_per_samples
Gain per sample.
Definition types.h:175
std::variant< CascadedFeedbackMatrixOptions, ScalarFeedbackMatrixOptions, TimeVaryingFeedbackMatrixOptions > feedback_matrix_variant_t
Variant type for holding different feedback matrix options.
Definition types.h:558
TimeVaryingMatrixMode
Construction modes for a TimeVaryingFeedbackMatrix.
Definition types.h:127
std::variant< ParallelGainsOptions, MultichannelSchroederAllpassSectionOptions, MultichannelTimeVaryingSchroederAllpassSectionOptions, MultichannelDattorroDelayOptions, AttenuationFilterBankOptions, DelayBankOptions, DelayBankTimeVaryingOptions, CascadedFeedbackMatrixOptions, ScalarFeedbackMatrixOptions, MultichannelFirOptions, MultichannelControllableFullWaveRectifierOptions, MultichannelSignalDependentFractionalDelayOptions, MultichannelRingModulatorOptions > multi_channel_processor_variant_t
Variant type for holding different multi-channel processor options.
Definition types.h:568
std::variant< SchroederAllpassSectionOptions, TimeVaryingSchroederAllpassSectionOptions, AllpassFilterOptions, CascadedBiquadsOptions, FirOptions, DelayOptions, GraphicEQOptions, DattorroDelayOptions, ControllableFullWaveRectifierOptions, SignalDependentFractionalDelayOptions, RingModulatorOptions > single_channel_processor_variant_t
Variant type for holding different single-channel processor options.
Definition types.h:562
DattorroEffectType
Classic delay-line effects, as described in Table 1 of Jon Dattorro, "Effect Design Part 2: Delay-Lin...
Definition types.h:354
ParallelGainsMode
Enumeration for parallel gain processing modes.
Definition types.h:111
DelayInterpolationType
Types of interpolation for fractional delay lengths.
Definition types.h:67
ScalarMatrixType
Represents the type of a scalar matrix.
Definition types.h:52
DelayLengthType
Types of delay length distributions.
Definition types.h:86
std::variant< HomogenousFilterOptions, TwoBandFilterOptions, ThreeBandFilterOptions, TenBandFilterOptions > attenuation_filter_variant_t
Variant type for holding different attenuation filter options.
Definition types.h:534
@ RealSchur
Uses V * blockdiag(R(theta)) * V^T.
@ Hadamard
Uses H^T * blockdiag(R(theta)) * H.
@ Count
Number of time-varying matrix modes.
@ Flanger
Short modulated delay with negative feedback.
@ Vibrato
Fully wet, modulated delay.
@ WhiteChorus
Medium modulated delay with positive feedback.
@ Doubling
Long modulated delay without feedback.
@ Echo
Long unmodulated delay with feedback.
@ Merge
Process each input channel separately and output to one channel.
@ Split
Process input as a single channel and output to multiple channels.
@ Parallel
Process each input channel separately and output to the same number of channels.
@ Lagrange
Third-order Lagrange interpolation.
@ Linear
Linear interpolation.
@ None
No interpolation. The delay length will be rounded to the nearest integer value.
@ Allpass
Allpass interpolation.
@ NestedAllpass
Nested Allpass matrix.
@ Householder
Householder matrix.
@ Random
Random orthogonal matrix.
@ VariableDiffusion
Variable diffusion matrix as described in [3].
@ Circulant
Circulant matrix as described in [1].
@ RandomHouseholder
Random Householder matrix.
@ Hadamard
Hadamard matrix.
@ Identity
Identity matrix.
@ Random
Delay lengths are generated randomly within the specified range based on a uniform distribution.
@ SteamAudio
Delay lengths are generated using the algorithm from the SteamAudio library.
@ PrimePower
Delay lengths are generated as powers of prime numbers within the specified range....
@ Uniform
Delay lengths are uniformly distributed within the specified range.
@ Primes
Delay lengths are selected randomly from a list of prime numbers within the specified range.
@ Gaussian
Delay lengths are generated based on a Gaussian distribution within the specified range.
Options for configuring an allpass filter.
Definition types.h:285
Options for configuring an attenuation filter bank.
Definition types.h:539
Options for configuring cascaded biquad filters.
Definition types.h:298
Information structure for constructing a cascaded feedback matrix (also known as a filter feedback ma...
Definition types.h:168
Options for configuring a controllable full-wave rectifier.
Definition types.h:401
Options for configuring a Dattorro delay-line effect.
Definition types.h:368
Options for configuring a delay bank.
Definition types.h:232
Options for configuring a time-varying delay bank.
Definition types.h:244
Options for configuring delays.
Definition types.h:219
Options for configuring a FIR filter.
Definition types.h:304
Options for configuring a graphic equalizer.
Definition types.h:546
Options for configuring a homogenous filter.
Definition types.h:472
Options for configuring signal modulation.
Definition types.h:180
Options for configuring a multichannel bank of controllable full-wave rectifiers.
Definition types.h:419
Options for configuring a multichannel bank of Dattorro delay-line effects.
Definition types.h:391
Options for configuring a multichannel bank of ring modulators.
Definition types.h:465
Options for configuring a multichannel bank of Schroeder allpass sections.
Definition types.h:327
Options for configuring a multichannel bank of signal-dependent fractional delays.
Definition types.h:439
Options for configuring a multichannel bank of time-varying Schroeder allpass sections.
Definition types.h:347
Options for configuring parallel gain processing.
Definition types.h:208
Options for configuring a ring modulator.
Definition types.h:450
Options for configuring a scalar feedback matrix.
Definition types.h:140
Options for configuring a Schroeder allpass section consisting of N Schroeder allpass in series or in...
Definition types.h:316
Options for configuring a signal-dependent fractional delay.
Definition types.h:429
Options for configuring a sparse FIR filter.
Definition types.h:292
Options for configuring a ten-band filter.
Definition types.h:518
Options for configuring a three-band filter.
Definition types.h:499
Options for configuring a TimeVaryingFeedbackMatrix.
Definition types.h:197
Options for configuring an energy-preserving time-varying Schroeder allpass section.
Definition types.h:337
Options for configuring a two-band filter.
Definition types.h:487
Coefficients for a digital IIR filter.
Definition types.h:257
float b1
Feedforward coefficients.
Definition types.h:262
float a1
Feedback coefficient.
Definition types.h:271
float a2
Feedback coefficient.
Definition types.h:274
float b2
Feedforward coefficients.
Definition types.h:265
float b0
Feedforward coefficients.
Definition types.h:259
FilterCoefficients Normalize() const
Returns the filter coefficients normalized so that a0 is equal to 1.
Definition types.h:277
float a0
Feedback coefficient.
Definition types.h:268