bwp_ladder4

Digital model of the Moog® ladder filter circuit with separated outputs.

The cutoff and resonance parameters implement modulation as detailed in bwp_mod_func. Modulations are however internally limited to avoid instability.

Examples

We can privately hand you one or more example plugins if you are interested.

Contact us

API

Module type: DSP

bwp_ladder4_coeffs

typedef struct bwp_ladder4_coeffs bwp_ladder4_coeffs;

Coefficients and related.

bwp_ladder4_state

typedef struct bwp_ladder4_state bwp_ladder4_state;

Internal state and related.

bwp_ladder4_init()

static inline void bwp_ladder4_init(
	bwp_ladder4_coeffs * BW_RESTRICT coeffs);

Initializes input parameter values in coeffs.

bwp_ladder4_set_sample_rate()

static inline void bwp_ladder4_set_sample_rate(
	bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	float                            sample_rate);

Sets the sample_rate (Hz) value in coeffs.

bwp_ladder4_reset_coeffs()

static inline void bwp_ladder4_reset_coeffs(
	bwp_ladder4_coeffs * BW_RESTRICT coeffs);

Resets coefficients in coeffs to assume their target values.

bwp_ladder4_reset_state()

static inline void bwp_ladder4_reset_state(
	const bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	bwp_ladder4_state * BW_RESTRICT        state,
	char                                   self_osc,
	float                                  x_0,
	float * BW_RESTRICT                    y_lp1_0,
	float * BW_RESTRICT                    y_lp2_0,
	float * BW_RESTRICT                    y_lp3_0,
	float * BW_RESTRICT                    y_lp4_0);

Resets the given state to its initial values using the given coeffs and the initial input value x_0.

The corresponding initial 1st-, 2nd-, 3rd-, and 4th-order lowpass output values are put into y_lp1_0, y_lp2_0, y_lp3_0, and y_lp4_0 respectively.

If self_osc is 1, initial states are computed taking eventual self-oscillation into account. Please note that this calculation is approximate and relatively computationally expensive. Otherwise, set it to 0 to not take self-oscillation into account. Other values for this argument are reserved.

bwp_ladder4_reset_state_multi()

static inline void bwp_ladder4_reset_state_multi(
	const bwp_ladder4_coeffs * BW_RESTRICT              coeffs,
	bwp_ladder4_state * BW_RESTRICT const * BW_RESTRICT state,
	char                                                self_osc,
	const float *                                       x_0,
	float *                                             y_lp1_0,
	float *                                             y_lp2_0,
	float *                                             y_lp3_0,
	float *                                             y_lp4_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 1st-, 2nd-, 3rd-, and 4th-order lowpass output values are put into the y_lp1_0, y_lp2_0, y_lp3_0, and y_lp4_0 arrays, respectively, if they are not BW_NULL.

If self_osc is 1, initial states are computed taking eventual self-oscillation into account. Please note that this calculation is approximate and relatively computationally expensive. Otherwise, set it to 0 to not take self-oscillation into account. Other values for this argument are reserved.

bwp_ladder4_update_coeffs_ctrl()

static inline void bwp_ladder4_update_coeffs_ctrl(
	bwp_ladder4_coeffs * BW_RESTRICT coeffs);

Triggers control-rate update of coefficients in coeffs.

bwp_ladder4_update_coeffs_audio()

static inline void bwp_ladder4_update_coeffs_audio(
	bwp_ladder4_coeffs * BW_RESTRICT coeffs);

Triggers audio-rate update of coefficients in coeffs.

bwp_ladder4_process1*()

static inline void bwp_ladder4_process1(
	const bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	bwp_ladder4_state * BW_RESTRICT        state,
	float                                  x,
	float * BW_RESTRICT                    y_lp1,
	float * BW_RESTRICT                    y_lp2,
	float * BW_RESTRICT                    y_lp3,
	float * BW_RESTRICT                    y_lp4);

static inline void bwp_ladder4_process1_mod_cutoff(
	const bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	bwp_ladder4_state * BW_RESTRICT        state,
	float                                  x,
	float                                  x_mod_cutoff,
	float * BW_RESTRICT                    y_lp1,
	float * BW_RESTRICT                    y_lp2,
	float * BW_RESTRICT                    y_lp3,
	float * BW_RESTRICT                    y_lp4);

static inline void bwp_ladder4_process1_mod_resonance(
	const bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	bwp_ladder4_state * BW_RESTRICT        state,
	float                                  x,
	float                                  x_mod_resonance,
	float * BW_RESTRICT                    y_lp1,
	float * BW_RESTRICT                    y_lp2,
	float * BW_RESTRICT                    y_lp3,
	float * BW_RESTRICT                    y_lp4);

static inline void bwp_ladder4_process1_mod_cutoff_resonance(
	const bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	bwp_ladder4_state * BW_RESTRICT        state,
	float                                  x,
	float                                  x_mod_cutoff,
	float                                  x_mod_resonance,
	float * BW_RESTRICT                    y_lp1,
	float * BW_RESTRICT                    y_lp2,
	float * BW_RESTRICT                    y_lp3,
	float * BW_RESTRICT                    y_lp4);

These function process one input sample x using coeffs, while using and updating state. The 1st-, 2nd-, 3rd-, and 4th-order lowpass output samples are put into y_lp1, y_lp2, y_lp3, and y_lp4 respectively.

They take various combinations of audio-rate modulation signals as input, namely x_mod_cutoff and x_mod_resonance.

bwp_ladder4_process()

static inline void bwp_ladder4_process(
	bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	bwp_ladder4_state * BW_RESTRICT  state,
	const float *                    x,
	const float *                    x_mod_cutoff,
	const float *                    x_mod_resonance,
	float *                          y_lp1,
	float *                          y_lp2,
	float *                          y_lp3,
	float *                          y_lp4,
	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_lp1, y_lp2, y_lp3, and y_lp4 (1st-, 2nd-, 3rd-, and 4th-order lowpass respectively), if they are not BW_NULL, while using and updating both coeffs and state (control and audio rate).

If x_mod_cutoff is not BW_NULL, it is used as a source of cutoff frequency modulation. The same holds for x_mod_resonance w.r.t. resonance modulation.

bwp_ladder4_process_multi()

static inline void bwp_ladder4_process_multi(
	bwp_ladder4_coeffs * BW_RESTRICT                    coeffs,
	bwp_ladder4_state * BW_RESTRICT const * BW_RESTRICT state,
	const float * const *                               x,
	const float * const *                               x_mod_cutoff,
	const float * const *                               x_mod_resonance,
	float * const *                                     y_lp1,
	float * const *                                     y_lp2,
	float * const *                                     y_lp3,
	float * const *                                     y_lp4,
	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_lp1, y_lp2, y_lp3, and y_lp4 (1st-, 2nd-, 3rd-, and 4th-order lowpass), 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 frequency modulation for that channel. The same hold for x_mod_resonance w.r.t.resonance modulation.

y_lp1, y_lp2, y_lp3, and y_lp4 or any of their elements may be BW_NULL.

bwp_ladder4_set_cutoff()

static inline void bwp_ladder4_set_cutoff(
	bwp_ladder4_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.

bwp_ladder4_set_cutoff_mod()

static inline void bwp_ladder4_set_cutoff_mod(
	bwp_ladder4_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.

bwp_ladder4_set_resonance()

static inline void bwp_ladder4_set_resonance(
	bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	float                            value);

Sets the resonance (feedback gain) to the given value in coeffs.

Valid range: [0.f, 1e6f].

Default value: 0.f.

bwp_ladder4_set_resonance_mod()

static inline void bwp_ladder4_set_resonance_mod(
	bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	float                            value);

Sets the non-smoothed resonance (feedback gain) modulation component to the given value in coeffs.

value must be finite.

Default value: 0.f.

bwp_ladder4_set_mod_func_cutoff()

static inline void bwp_ladder4_set_mod_func_cutoff(
	bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	bwp_mod_func                     value);

Sets the cutoff frequency modulation function.

Default value: bwp_mod_func_pow2.

bwp_ladder4_set_mod_func_resonance()

static inline void bwp_ladder4_set_mod_func_resonance(
	bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	bwp_mod_func                     value);

Sets the quality factor modulation function.

Default value: bwp_mod_func_sum.

bwp_ladder4_coeffs_is_valid()

static inline char bwp_ladder4_coeffs_is_valid(
	const bwp_ladder4_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_ladder4_coeffs.

bwp_ladder4_state_is_valid()

static inline char bwp_ladder4_state_is_valid(
	const bwp_ladder4_coeffs * BW_RESTRICT coeffs,
	const bwp_ladder4_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_ladder4_state.

C++ wrapper

BrickworksPro::Ladder4
template<size_t N_CHANNELS = 1>
class Ladder4 {
public:
	Ladder4();

	void setSampleRate(
		float sampleRate);

	void reset(
		char                selfOsc = 0,
		float               x0 = 0.f,
		float * BW_RESTRICT yLp10 = BW_NULL,
		float * BW_RESTRICT yLp20 = BW_NULL,
		float * BW_RESTRICT yLp30 = BW_NULL,
		float * BW_RESTRICT yLp40 = BW_NULL);

# ifndef BW_CXX_NO_ARRAY
	void reset(
		char                                        selfOsc,
		float                                       x0,
		std::array<float, N_CHANNELS> * BW_RESTRICT yLp10,
		std::array<float, N_CHANNELS> * BW_RESTRICT yLp20,
		std::array<float, N_CHANNELS> * BW_RESTRICT yLp30,
		std::array<float, N_CHANNELS> * BW_RESTRICT yLp40);
# endif

	void reset(
		char          selfOsc,
		const float * x0,
		float *       yLp10 = BW_NULL,
		float *       yLp20 = BW_NULL,
		float *       yLp30 = BW_NULL,
		float *       yLp40 = BW_NULL);

# ifndef BW_CXX_NO_ARRAY
	void reset(
		char                                        selfOsc,
		std::array<float, N_CHANNELS>               x0,
		std::array<float, N_CHANNELS> * BW_RESTRICT yLp10 = BW_NULL,
		std::array<float, N_CHANNELS> * BW_RESTRICT yLp20 = BW_NULL,
		std::array<float, N_CHANNELS> * BW_RESTRICT yLp30 = BW_NULL,
		std::array<float, N_CHANNELS> * BW_RESTRICT yLp40 = BW_NULL);
# endif

	void process(
		const float * const * x,
		const float * const * xModCutoff,
		const float * const * xModResonance,
		float * const *       yLp1,
		float * const *       yLp2,
		float * const *       yLp3,
		float * const *       yLp4,
		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> xModResonance,
		std::array<float *, N_CHANNELS>       yLp1,
		std::array<float *, N_CHANNELS>       yLp2,
		std::array<float *, N_CHANNELS>       yLp3,
		std::array<float *, N_CHANNELS>       yLp4,
		size_t                                nSamples);
# endif

	void setCutoff(
		float value);

	void setCutoffMod(
		float value);

	void setResonance(
		float value);

	void setResonanceMod(
		float value);

	void setModFuncCutoff(
		bwp_mod_func value);

	void setModFuncResonance(
		bwp_mod_func value);
...
}

Changelog

  • Version 1.0.0:
    • First release.