proper computing of initial values in finalized modules

This commit is contained in:
Stefano D'Angelo 2023-09-12 17:05:51 +02:00
parent 1d763ef31e
commit 13987673f5
15 changed files with 31 additions and 9 deletions

View File

@ -310,6 +310,7 @@ struct bw_ap1_state {
uint32_t coeffs_reset_id;
#endif
// Sub-components
bw_lp1_state lp1_state;
};
@ -371,8 +372,8 @@ static inline float bw_ap1_reset_state(
BW_ASSERT(state != NULL);
BW_ASSERT(bw_is_finite(x_0));
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
const float y = x_0;
const float lp = bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
const float y = lp + lp - x_0;
#ifdef BW_DEBUG_DEEP
state->hash = bw_hash_sdbm("bw_ap1_state");

View File

@ -319,6 +319,7 @@ struct bw_ap2_state {
uint32_t coeffs_reset_id;
#endif
// Sub-components
bw_svf_state svf_state;
};
@ -382,7 +383,8 @@ static inline float bw_ap2_reset_state(
float lp, bp, hp;
bw_svf_reset_state(&coeffs->svf_coeffs, &state->svf_state, x_0, &lp, &bp, &hp);
const float y = x_0;
const float lh = lp + hp;
const float y = lh + lh - x_0;
#ifdef BW_DEBUG_DEEP
state->hash = bw_hash_sdbm("bw_ap2_state");

View File

@ -308,6 +308,7 @@ struct bw_hp1_state {
uint32_t coeffs_reset_id;
#endif
// Sub-components
bw_lp1_state lp1_state;
};
@ -369,7 +370,8 @@ static inline float bw_hp1_reset_state(
BW_ASSERT(state != NULL);
BW_ASSERT(bw_is_finite(x_0));
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
const float lp = bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
const float y = x_0 - lp;
#ifdef BW_DEBUG_DEEP
state->hash = bw_hash_sdbm("bw_hp1_state");
@ -378,8 +380,9 @@ static inline float bw_hp1_reset_state(
BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
BW_ASSERT_DEEP(bw_hp1_state_is_valid(coeffs, state));
BW_ASSERT(bw_is_finite(y));
return 0.f;
return y;
}
static inline void bw_hp1_reset_state_multi(

View File

@ -355,6 +355,7 @@ struct bw_hs1_state {
uint32_t coeffs_reset_id;
#endif
// Sub-components
bw_mm1_state mm1_state;
};

View File

@ -375,6 +375,7 @@ struct bw_hs2_state {
uint32_t coeffs_reset_id;
#endif
// Sub-components
bw_mm2_state mm2_state;
};

View File

@ -326,6 +326,7 @@ struct bw_lp1_state {
uint32_t coeffs_reset_id;
#endif
// States
float y_z1;
float X_z1;
};

View File

@ -357,6 +357,7 @@ struct bw_ls1_state {
uint32_t coeffs_reset_id;
#endif
// Sub-components
bw_mm1_state mm1_state;
};

View File

@ -372,6 +372,7 @@ struct bw_ls2_state {
uint32_t coeffs_reset_id;
#endif
// Sub-components
bw_mm2_state mm2_state;
};

View File

@ -332,6 +332,7 @@ struct bw_mm1_state {
uint32_t coeffs_reset_id;
#endif
// Sub-components
bw_lp1_state lp1_state;
};
@ -403,8 +404,8 @@ static inline float bw_mm1_reset_state(
BW_ASSERT(state != NULL);
BW_ASSERT(bw_is_finite(x_0));
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
const float y = (bw_gain_get_gain_lin(&coeffs->gain_x_coeffs) + bw_gain_get_gain_lin(&coeffs->gain_lp_coeffs)) * x_0;
const float lp = bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
const float y = bw_gain_get_gain_lin(&coeffs->gain_x_coeffs) * x_0 + bw_gain_get_gain_lin(&coeffs->gain_lp_coeffs) * lp;
#ifdef BW_DEBUG_DEEP
state->hash = bw_hash_sdbm("bw_mm1_state");

View File

@ -371,6 +371,7 @@ struct bw_mm2_state {
uint32_t coeffs_reset_id;
#endif
// Sub-components
bw_svf_state svf_state;
};
@ -454,7 +455,11 @@ static inline float bw_mm2_reset_state(
float lp, bp, hp;
bw_svf_reset_state(&coeffs->svf_coeffs, &state->svf_state, x_0, &lp, &bp, &hp);
const float y = (bw_gain_get_gain_lin(&coeffs->gain_x_coeffs) + bw_gain_get_gain_lin(&coeffs->gain_lp_coeffs)) * x_0;
const float y =
bw_gain_get_gain_lin(&coeffs->gain_x_coeffs) * x_0
+ bw_gain_get_gain_lin(&coeffs->gain_lp_coeffs) * lp
+ bw_gain_get_gain_lin(&coeffs->gain_bp_coeffs) * bp
+ bw_gain_get_gain_lin(&coeffs->gain_hp_coeffs) * hp;
#ifdef BW_DEBUG_DEEP
state->hash = bw_hash_sdbm("bw_mm2_state");

View File

@ -319,6 +319,7 @@ struct bw_notch_state {
uint32_t coeffs_reset_id;
#endif
// Sub-components
bw_svf_state svf_state;
};
@ -382,7 +383,7 @@ static inline float bw_notch_reset_state(
float lp, bp, hp;
bw_svf_reset_state(&coeffs->svf_coeffs, &state->svf_state, x_0, &lp, &bp, &hp);
const float y = x_0;
const float y = lp + hp;
#ifdef BW_DEBUG_DEEP
state->hash = bw_hash_sdbm("bw_notch_state");

View File

@ -495,6 +495,7 @@ struct bw_one_pole_state {
uint32_t coeffs_reset_id;
#endif
// States
float y_z1;
};

View File

@ -407,6 +407,7 @@ struct bw_peak_state {
uint32_t coeffs_reset_id;
#endif
// Sub-components
bw_mm2_state mm2_state;
};

View File

@ -368,6 +368,7 @@ struct bw_slew_lim_state {
uint32_t coeffs_reset_id;
#endif
// States
float y_z1;
};

View File

@ -391,6 +391,7 @@ struct bw_svf_state {
uint32_t coeffs_reset_id;
#endif
// States
float hp_z1;
float lp_z1;
float bp_z1;