Advanced version of bw_svf with cutoff, quality factor, and prewarping frequency modulation.
Parameter modulation is implemented as detailed in bwp_mod_func. Modulations are however internally limited to avoid instability.
We can privately hand you one or more example plugins if you are interested.
Module type: DSP
typedef struct bwp_svf_coeffs bwp_svf_coeffs;
Coefficients and related.
typedef struct bwp_svf_state bwp_svf_state;
Internal state and related.
static inline void bwp_svf_init(
bwp_svf_coeffs * BW_RESTRICT coeffs);
Initializes input parameter values in coeffs.
static inline void bwp_svf_set_sample_rate(
bwp_svf_coeffs * BW_RESTRICT coeffs,
float sample_rate);
Sets the sample_rate (Hz) value in coeffs.
static inline void bwp_svf_reset_coeffs(
bwp_svf_coeffs * BW_RESTRICT coeffs);
Resets coefficients in coeffs to assume their target values.
static inline void bwp_svf_reset_state(
const bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT state,
float x_0,
float * BW_RESTRICT y_lp_0,
float * BW_RESTRICT y_bp_0,
float * BW_RESTRICT y_hp_0);
Resets the given state to its initial values using the given coeffs and the initial input value x_0.
The corresponding initial lowpass, bandpass, and highpass output values are put into y_lp_0, y_bp_0, and y_hp_0 respectively.
static inline void bwp_svf_reset_state_multi(
const bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT const * BW_RESTRICT state,
const float * x_0,
float * y_lp_0,
float * y_bp_0,
float * y_hp_0,
size_t n_channels);
Resets each of the n_channels states to its initial values using the given coeffs and the corresponding initial input value in the x_0 array.
The corresponding initial lowpass, bandpass, and highpass output values are put into the y_lp_0, y_bp_0, and y_hp_0 arrays, respectively, if they are not BW_NULL.
static inline void bwp_svf_update_coeffs_ctrl(
bwp_svf_coeffs * BW_RESTRICT coeffs);
Triggers control-rate update of coefficients in coeffs.
static inline void bwp_svf_update_coeffs_audio(
bwp_svf_coeffs * BW_RESTRICT coeffs);
Triggers audio-rate update of coefficients in coeffs.
static inline void bwp_svf_process1(
const bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT state,
float x,
float * BW_RESTRICT y_lp,
float * BW_RESTRICT y_bp,
float * BW_RESTRICT y_hp);
static inline void bwp_svf_process1_mod_cutoff(
const bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT state,
float x,
float x_mod_cutoff,
float * BW_RESTRICT y_lp,
float * BW_RESTRICT y_bp,
float * BW_RESTRICT y_hp);
static inline void bwp_svf_process1_mod_Q(
const bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT state,
float x,
float x_mod_Q,
float * BW_RESTRICT y_lp,
float * BW_RESTRICT y_bp,
float * BW_RESTRICT y_hp);
static inline void bwp_svf_process1_mod_prewarp_freq(
const bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT state,
float x,
float x_mod_prewarp_freq,
float * BW_RESTRICT y_lp,
float * BW_RESTRICT y_bp,
float * BW_RESTRICT y_hp);
static inline void bwp_svf_process1_mod_cutoff_Q(
const bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT state,
float x,
float x_mod_cutoff,
float x_mod_Q,
float * BW_RESTRICT y_lp,
float * BW_RESTRICT y_bp,
float * BW_RESTRICT y_hp);
static inline void bwp_svf_process1_mod_cutoff_prewarp_freq(
const bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT state,
float x,
float x_mod_cutoff,
float x_mod_prewarp_freq,
float * BW_RESTRICT y_lp,
float * BW_RESTRICT y_bp,
float * BW_RESTRICT y_hp);
static inline void bwp_svf_process1_mod_Q_prewarp_freq(
const bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT state,
float x,
float x_mod_Q,
float x_mod_prewarp_freq,
float * BW_RESTRICT y_lp,
float * BW_RESTRICT y_bp,
float * BW_RESTRICT y_hp);
static inline void bwp_svf_process1_mod_cutoff_Q_prewarp_freq(
const bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT state,
float x,
float x_mod_cutoff,
float x_mod_Q,
float x_mod_prewarp_freq,
float * BW_RESTRICT y_lp,
float * BW_RESTRICT y_bp,
float * BW_RESTRICT y_hp);
These functions process one input sample x using coeffs, while using and updating state. The lowpass, bandpass, and highpass output samples are put into y_lp, y_bp, and y_hp respectively.
They take various combinations of audio-rate modulation signals as input, namely x_mod_cutoff, x_mod_Q, and x_mod_prewarp_freq.
Please note that these functions ignore prewarp_at_cutoff completely, so if you want to apply the same modulations to both cutoff and prewarp frequency you should call a variant which modulates both and pass the same value as x_mod_cutoff and x_mod_prewarp_freq.
static inline void bwp_svf_process(
bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT state,
const float * x,
const float * x_mod_cutoff,
const float * x_mod_Q,
const float * x_mod_prewarp_freq,
float * y_lp,
float * y_bp,
float * y_hp,
size_t n_samples);
Processes the first n_samples of the input buffer x and fills the first n_samples of the output buffers y_lp (lowpass), y_bp (bandpass), and y_hp (highpass), if they are not BW_NULL, while using and updating both coeffs and state (control and audio rate).
If x_mod_cutoff and/or x_mod_prewarp_freq are not BW_NULL, they are used as sources of cutoff and prewarping frequency modulation, respectively. Similarly, if x_mod_Q is not BW_NULL, it is used as a source of quality factor modulation.
In any case, if prewarp_at_cutoff is non-0 (on), x_mod_prewarp_freq is ignored and x_mod_cutoff is used as source of prewarping frequency modulation if it is not BW_NULL, or no modulation is applied otherwise.
static inline void bwp_svf_process_multi(
bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_svf_state * BW_RESTRICT const * BW_RESTRICT state,
const float * const * x,
const float * const * x_mod_cutoff,
const float * const * x_mod_Q,
const float * const * x_mod_prewarp_freq,
float * const * y_lp,
float * const * y_bp,
float * const * y_hp,
size_t n_channels,
size_t n_samples);
Processes the first n_samples of the n_channels input buffers x and fills the first n_samples of the n_channels output buffers y_lp (lowpass), y_bp (bandpass), and y_hp (highpass), while using and updating both the common coeffs and each of the n_channels states (control and audio rate).
If x_mod_cutoff and the channel-specific element are not BW_NULL, this is used as a source of cutoff fequency modulation for that channel. The same holds for x_mod_prewarp_freq w.r.t prewarping frequency modulation and for x_mod_Q w.r.t. quality factor modulation.
y_lp, y_bp, and y_hp, or any of their elements may be BW_NULL.
static inline void bwp_svf_set_cutoff(
bwp_svf_coeffs * BW_RESTRICT coeffs,
float value);
Sets the cutoff frequency to the given value (Hz) in coeffs.
Valid range: [1e-6f, 1e12f].
Default value: 1e3f.
static inline void bwp_svf_set_cutoff_mod(
bwp_svf_coeffs * BW_RESTRICT coeffs,
float value);
Sets the non-smoothed cutoff frequency modulation component to the given value in coeffs.
value must be finite.
Default value: 0.f.
static inline void bwp_svf_set_Q(
bwp_svf_coeffs * BW_RESTRICT coeffs,
float value);
Sets the quality factor to the given value in coeffs.
Valid range: [1e-6f, 1e6f].
Default value: 0.5f.
static inline void bwp_svf_set_Q_mod(
bwp_svf_coeffs * BW_RESTRICT coeffs,
float value);
Sets the non-smoothed quality factor modulation component to the given value in coeffs.
value must be finite.
Default value: 0.f.
static inline void bwp_svf_set_prewarp_at_cutoff(
bwp_svf_coeffs * BW_RESTRICT coeffs,
char value);
Sets whether bilinear transform prewarping frequency should match the cutoff frequency (non-0) or not (0).
Default value: non-0 (on).
static inline void bwp_svf_set_prewarp_freq(
bwp_svf_coeffs * BW_RESTRICT coeffs,
float value);
Sets the prewarping frequency value (Hz) in coeffs.
Only used when the prewarp_at_cutoff parameter is off and however internally limited to avoid instability.
Valid range: [1e-6f, 1e12f].
Default value: 1e3f.
static inline void bwp_svf_set_prewarp_freq_mod(
bwp_svf_coeffs * BW_RESTRICT coeffs,
float value);
Sets the non-smoothed prewarping frequency modulation component to the given value in coeffs.
value must be finite.
Default value: 0.f.
static inline void bwp_svf_set_mod_func_cutoff(
bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_mod_func value);
Sets the cutoff frequency modulation function.
Default value: bwp_mod_func_pow2.
static inline void bwp_svf_set_mod_func_Q(
bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_mod_func value);
Sets the quality factor modulation function.
Default value: bwp_mod_func_sum.
static inline void bwp_svf_set_mod_func_prewarp_freq(
bwp_svf_coeffs * BW_RESTRICT coeffs,
bwp_mod_func value);
Sets the prewarping frequency modulation function.
Default value: bwp_mod_func_pow2.
static inline char bwp_svf_coeffs_is_valid(
const bwp_svf_coeffs * BW_RESTRICT coeffs);
Tries to determine whether coeffs is valid and returns non-0 if it seems to be the case and 0 if it is certainly not. False positives are possible, false negatives are not.
coeffs must at least point to a readable memory block of size greater than or equal to that of bwp_svf_coeffs.
static inline char bwp_svf_state_is_valid(
const bwp_svf_coeffs * BW_RESTRICT coeffs,
const bwp_svf_state * BW_RESTRICT state);
Tries to determine whether state is valid and returns non-0 if it seems to be the case and 0 if it is certainly not. False positives are possible, false negatives are not.
If coeffs is not BW_NULL extra cross-checks might be performed (state is supposed to be associated to coeffs).
state must at least point to a readable memory block of size greater than or equal to that of bwp_svf_state.
template<size_t N_CHANNELS = 1>
class SVF {
public:
SVF();
void setSampleRate(
float sampleRate);
void reset(
float x0 = 0.f,
float * BW_RESTRICT yLp0 = BW_NULL,
float * BW_RESTRICT yBp0 = BW_NULL,
float * BW_RESTRICT yHp0 = BW_NULL);
# ifndef BW_CXX_NO_ARRAY
void reset(
float x0,
std::array<float, N_CHANNELS> * BW_RESTRICT yLp0,
std::array<float, N_CHANNELS> * BW_RESTRICT yBp0,
std::array<float, N_CHANNELS> * BW_RESTRICT yHp0);
# endif
void reset(
const float * x0,
float * yLp0 = BW_NULL,
float * yBp0 = BW_NULL,
float * yHp0 = BW_NULL);
# ifndef BW_CXX_NO_ARRAY
void reset(
std::array<float, N_CHANNELS> x0,
std::array<float, N_CHANNELS> * BW_RESTRICT yLp0 = BW_NULL,
std::array<float, N_CHANNELS> * BW_RESTRICT yBp0 = BW_NULL,
std::array<float, N_CHANNELS> * BW_RESTRICT yHp0 = BW_NULL);
# endif
void process(
const float * const * x,
const float * const * xModCutoff,
const float * const * xModQ,
const float * const * xModPrewarpFreq,
float * const * yLp,
float * const * yBp,
float * const * yHp,
size_t nSamples);
# ifndef BW_CXX_NO_ARRAY
void process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> xModCutoff,
std::array<const float *, N_CHANNELS> xModQ,
std::array<const float *, N_CHANNELS> xModPrewarpFreq,
std::array<float *, N_CHANNELS> yLp,
std::array<float *, N_CHANNELS> yBp,
std::array<float *, N_CHANNELS> yHp,
size_t nSamples);
# endif
void setCutoff(
float value);
void setCutoffMod(
float value);
void setQ(
float value);
void setQMod(
float value);
void setPrewarpAtCutoff(
bool value);
void setPrewarpFreq(
float value);
void setPrewarpFreqMod(
float value);
void setModFuncCutoff(
bwp_mod_func value);
void setModFuncQ(
bwp_mod_func value);
void setModFuncPrewarpFreq(
bwp_mod_func value);
...
}
bwp_svf_process*() functions.N_CHANNELS in C++ API.