diff --git a/include/bw_one_pole.h b/include/bw_one_pole.h index 45337c7..9534482 100644 --- a/include/bw_one_pole.h +++ b/include/bw_one_pole.h @@ -89,7 +89,7 @@ static inline void bw_one_pole_set_sample_rate(bw_one_pole_coeffs *BW_RESTRICT c * * #### bw_one_pole_reset_state() * ```>>> */ -static inline void bw_one_pole_reset_state(const bw_one_pole_coeffs *BW_RESTRICT coeffs, bw_one_pole_state *BW_RESTRICT state); +static inline void bw_one_pole_reset_state(const bw_one_pole_coeffs *BW_RESTRICT coeffs, bw_one_pole_state *BW_RESTRICT state, float y_z1); /*! <<<``` * Resets the given `state` to the initial state using the given `coeffs`. * >>> */ @@ -116,20 +116,6 @@ static inline void bw_one_pole_process(bw_one_pole_coeffs *BW_RESTRICT coeffs, b * buffer `y`. * >>> */ -/*! ... - * #### bw_one_pole_set_init_val() - * ```>>> */ -static inline void bw_one_pole_set_init_val(bw_one_pole_coeffs *BW_RESTRICT coeffs, float value); -/*! <<<``` - * Sets the initial/quiescent `value` for the given `instance`. - * - * In practice, when processing the first buffer after a reset, the past - * input and output are both assumed to have virtually been constant and of - * the specified `value`. - * - * Default value: `0.f`. - * >>> */ - /*! ... * #### bw_one_pole_set_cutoff() * ```>>> */ @@ -258,7 +244,6 @@ struct _bw_one_pole_coeffs { float st2; // Parameters - float init_val; float cutoff_up; float cutoff_down; float sticky_thresh; @@ -277,7 +262,6 @@ struct _bw_one_pole_state { #include static inline void bw_one_pole_init(bw_one_pole_coeffs *BW_RESTRICT coeffs) { - coeffs->init_val = 0.f; coeffs->cutoff_up = INFINITY; coeffs->cutoff_down = INFINITY; coeffs->sticky_thresh = 0.f; @@ -292,8 +276,8 @@ static inline void bw_one_pole_reset_coeffs(bw_one_pole_coeffs *BW_RESTRICT coef bw_one_pole_update_coeffs_ctrl(coeffs); } -static inline void bw_one_pole_reset_state(const bw_one_pole_coeffs *BW_RESTRICT coeffs, bw_one_pole_state *BW_RESTRICT state) { - state->y_z1 = coeffs->init_val; +static inline void bw_one_pole_reset_state(const bw_one_pole_coeffs *BW_RESTRICT coeffs, bw_one_pole_state *BW_RESTRICT state, float y_z1) { + state->y_z1 = y_z1; } static inline void bw_one_pole_update_coeffs_ctrl(bw_one_pole_coeffs *BW_RESTRICT coeffs) { @@ -392,10 +376,6 @@ static inline void bw_one_pole_process(bw_one_pole_coeffs *BW_RESTRICT coeffs, b } } -static inline void bw_one_pole_set_init_val(bw_one_pole_coeffs *BW_RESTRICT coeffs, float value) { - coeffs->init_val = value; -} - static inline void bw_one_pole_set_cutoff(bw_one_pole_coeffs *BW_RESTRICT coeffs, float value) { bw_one_pole_set_cutoff_up(coeffs, value); bw_one_pole_set_cutoff_down(coeffs, value); diff --git a/include/bw_phase_gen.h b/include/bw_phase_gen.h index 077186a..8bf3e6b 100644 --- a/include/bw_phase_gen.h +++ b/include/bw_phase_gen.h @@ -173,9 +173,8 @@ static inline void _bw_phase_gen_do_update_coeffs_ctrl(bw_phase_gen_coeffs *BW_R static inline void bw_phase_gen_reset_coeffs(bw_phase_gen_coeffs *BW_RESTRICT coeffs) { _bw_phase_gen_do_update_coeffs_ctrl(coeffs, 1); - bw_one_pole_set_init_val(&coeffs->portamento_coeffs, coeffs->portamento_target); bw_one_pole_reset_coeffs(&coeffs->portamento_coeffs); - bw_one_pole_reset_state(&coeffs->portamento_coeffs, &coeffs->portamento_state); + bw_one_pole_reset_state(&coeffs->portamento_coeffs, &coeffs->portamento_state, coeffs->portamento_target); } static inline void bw_phase_gen_reset_state(const bw_phase_gen_coeffs *BW_RESTRICT coeffs, bw_phase_gen_state *BW_RESTRICT state) { diff --git a/include/bw_svf.h b/include/bw_svf.h index 1be8c2d..c3ff3c1 100644 --- a/include/bw_svf.h +++ b/include/bw_svf.h @@ -196,12 +196,10 @@ static inline void _bw_svf_do_update_coeffs(bw_svf_coeffs *BW_RESTRICT coeffs, c } static inline void bw_svf_reset_coeffs(bw_svf_coeffs *BW_RESTRICT coeffs) { - bw_one_pole_set_init_val(&coeffs->smooth_cutoff_coeffs, coeffs->cutoff); bw_one_pole_reset_coeffs(&coeffs->smooth_cutoff_coeffs); - bw_one_pole_reset_state(&coeffs->smooth_cutoff_coeffs, &coeffs->smooth_cutoff_state); - bw_one_pole_set_init_val(&coeffs->smooth_Q_coeffs, coeffs->Q); + bw_one_pole_reset_state(&coeffs->smooth_cutoff_coeffs, &coeffs->smooth_cutoff_state, coeffs->cutoff); bw_one_pole_reset_coeffs(&coeffs->smooth_Q_coeffs); - bw_one_pole_reset_state(&coeffs->smooth_Q_coeffs, &coeffs->smooth_Q_state); + bw_one_pole_reset_state(&coeffs->smooth_Q_coeffs, &coeffs->smooth_Q_state, coeffs->Q); _bw_svf_do_update_coeffs(coeffs, 1); }