one pole init value not a parameter but reset_state argument

This commit is contained in:
Stefano D'Angelo 2022-11-26 11:33:50 +01:00
parent 13e29a3304
commit dbabc619d7
3 changed files with 6 additions and 29 deletions

View File

@ -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 <bw_math.h>
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);

View File

@ -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) {

View File

@ -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);
}