allow null output where get_y_z1 is present

This commit is contained in:
Stefano D'Angelo 2022-11-28 14:07:50 +01:00
parent c4fdc7d2e5
commit 4ebcac26de
4 changed files with 93 additions and 40 deletions

View File

@ -186,7 +186,6 @@ void bw_example_synth_process(bw_example_synth instance, const float** x, float*
instance->level = instance->buf[i + n - 1]; instance->level = instance->buf[i + n - 1];
} }
*/ */
instance->level = 0.f;
if (instance->params[p_a440] >= 0.5f) if (instance->params[p_a440] >= 0.5f)
for (int i = 0; i < n_samples; i++) { for (int i = 0; i < n_samples; i++) {
@ -197,8 +196,7 @@ void bw_example_synth_process(bw_example_synth instance, const float** x, float*
} }
bw_vol_process(&instance->vol_coeffs, y[0], y[0], n_samples); bw_vol_process(&instance->vol_coeffs, y[0], y[0], n_samples);
for (int i = 0; i < n_samples; i++) bw_env_follow_process(&instance->env_follow_coeffs, &instance->env_follow_state, y[0], NULL, n_samples);
bw_env_follow_process1(&instance->env_follow_coeffs, &instance->env_follow_state, y[0][i]);
instance->level = bw_env_follow_get_y_z1(&instance->env_follow_state); instance->level = bw_env_follow_get_y_z1(&instance->env_follow_state);
} }

View File

@ -155,10 +155,16 @@ static inline float bw_env_follow_process1(const bw_env_follow_coeffs *BW_RESTRI
static inline void bw_env_follow_process(bw_env_follow_coeffs *BW_RESTRICT coeffs, bw_env_follow_state *BW_RESTRICT state, const float *x, float *y, int n_samples) { static inline void bw_env_follow_process(bw_env_follow_coeffs *BW_RESTRICT coeffs, bw_env_follow_state *BW_RESTRICT state, const float *x, float *y, int n_samples) {
bw_env_follow_update_coeffs_ctrl(coeffs); bw_env_follow_update_coeffs_ctrl(coeffs);
for (int i = 0; i < n_samples; i++) { if (y)
bw_env_follow_update_coeffs_audio(coeffs); for (int i = 0; i < n_samples; i++) {
y[i] = bw_env_follow_process1(coeffs, state, x[i]); bw_env_follow_update_coeffs_audio(coeffs);
} y[i] = bw_env_follow_process1(coeffs, state, x[i]);
}
else
for (int i = 0; i < n_samples; i++) {
bw_env_follow_update_coeffs_audio(coeffs);
bw_env_follow_process1(coeffs, state, x[i]);
}
} }
static inline void bw_env_follow_set_attack_tau(bw_env_follow_coeffs *BW_RESTRICT coeffs, float value) { static inline void bw_env_follow_set_attack_tau(bw_env_follow_coeffs *BW_RESTRICT coeffs, float value) {

View File

@ -345,33 +345,63 @@ static inline float bw_one_pole_process1_asym_sticky_rel(const bw_one_pole_coeff
static inline void bw_one_pole_process(bw_one_pole_coeffs *BW_RESTRICT coeffs, bw_one_pole_state *BW_RESTRICT state, const float *x, float *y, int n_samples) { static inline void bw_one_pole_process(bw_one_pole_coeffs *BW_RESTRICT coeffs, bw_one_pole_state *BW_RESTRICT state, const float *x, float *y, int n_samples) {
bw_one_pole_update_coeffs_ctrl(coeffs); bw_one_pole_update_coeffs_ctrl(coeffs);
if (y) {
if (coeffs->mA1u != coeffs->mA1d) { if (coeffs->mA1u != coeffs->mA1d) {
if (coeffs->st2 != 0.f) { if (coeffs->st2 != 0.f) {
if (coeffs->sticky_mode == bw_one_pole_sticky_mode_abs) if (coeffs->sticky_mode == bw_one_pole_sticky_mode_abs)
for (int i = 0; i < n_samples; i++)
y[i] = bw_one_pole_process1_asym_sticky_abs(coeffs, state, x[i]);
else
for (int i = 0; i < n_samples; i++)
y[i] = bw_one_pole_process1_asym_sticky_rel(coeffs, state, x[i]);
}
else {
for (int i = 0; i < n_samples; i++) for (int i = 0; i < n_samples; i++)
y[i] = bw_one_pole_process1_asym_sticky_abs(coeffs, state, x[i]); y[i] = bw_one_pole_process1_asym(coeffs, state, x[i]);
else }
for (int i = 0; i < n_samples; i++)
y[i] = bw_one_pole_process1_asym_sticky_rel(coeffs, state, x[i]);
} }
else { else {
for (int i = 0; i < n_samples; i++) if (coeffs->st2 != 0.f) {
y[i] = bw_one_pole_process1_asym(coeffs, state, x[i]); if (coeffs->sticky_mode == bw_one_pole_sticky_mode_abs)
for (int i = 0; i < n_samples; i++)
y[i] = bw_one_pole_process1_sticky_abs(coeffs, state, x[i]);
else
for (int i = 0; i < n_samples; i++)
y[i] = bw_one_pole_process1_sticky_rel(coeffs, state, x[i]);
}
else {
for (int i = 0; i < n_samples; i++)
y[i] = bw_one_pole_process1(coeffs, state, x[i]);
}
} }
} } else {
else { if (coeffs->mA1u != coeffs->mA1d) {
if (coeffs->st2 != 0.f) { if (coeffs->st2 != 0.f) {
if (coeffs->sticky_mode == bw_one_pole_sticky_mode_abs) if (coeffs->sticky_mode == bw_one_pole_sticky_mode_abs)
for (int i = 0; i < n_samples; i++)
bw_one_pole_process1_asym_sticky_abs(coeffs, state, x[i]);
else
for (int i = 0; i < n_samples; i++)
bw_one_pole_process1_asym_sticky_rel(coeffs, state, x[i]);
}
else {
for (int i = 0; i < n_samples; i++) for (int i = 0; i < n_samples; i++)
y[i] = bw_one_pole_process1_sticky_abs(coeffs, state, x[i]); bw_one_pole_process1_asym(coeffs, state, x[i]);
else }
for (int i = 0; i < n_samples; i++)
y[i] = bw_one_pole_process1_sticky_rel(coeffs, state, x[i]);
} }
else { else {
for (int i = 0; i < n_samples; i++) if (coeffs->st2 != 0.f) {
y[i] = bw_one_pole_process1(coeffs, state, x[i]); if (coeffs->sticky_mode == bw_one_pole_sticky_mode_abs)
for (int i = 0; i < n_samples; i++)
bw_one_pole_process1_sticky_abs(coeffs, state, x[i]);
else
for (int i = 0; i < n_samples; i++)
bw_one_pole_process1_sticky_rel(coeffs, state, x[i]);
}
else {
for (int i = 0; i < n_samples; i++)
bw_one_pole_process1(coeffs, state, x[i]);
}
} }
} }
} }

View File

@ -217,20 +217,39 @@ static inline float bw_slew_lim_process1_down(const bw_slew_lim_coeffs *BW_RESTR
static inline void bw_slew_lim_process(bw_slew_lim_coeffs *BW_RESTRICT coeffs, bw_slew_lim_state *BW_RESTRICT state, const float *x, float *y, int n_samples) { static inline void bw_slew_lim_process(bw_slew_lim_coeffs *BW_RESTRICT coeffs, bw_slew_lim_state *BW_RESTRICT state, const float *x, float *y, int n_samples) {
bw_slew_lim_update_coeffs_ctrl(coeffs); bw_slew_lim_update_coeffs_ctrl(coeffs);
if (coeffs->max_rate_up != INFINITY) { if (y) {
if (coeffs->max_rate_down != INFINITY) if (coeffs->max_rate_up != INFINITY) {
for (int i = 0; i < n_samples; i++) if (coeffs->max_rate_down != INFINITY)
y[i] = bw_slew_lim_process1(coeffs, state, x[i]); for (int i = 0; i < n_samples; i++)
else y[i] = bw_slew_lim_process1(coeffs, state, x[i]);
for (int i = 0; i < n_samples; i++) else
y[i] = bw_slew_lim_process1_up(coeffs, state, x[i]); for (int i = 0; i < n_samples; i++)
y[i] = bw_slew_lim_process1_up(coeffs, state, x[i]);
} else {
if (coeffs->max_rate_down != INFINITY)
for (int i = 0; i < n_samples; i++)
y[i] = bw_slew_lim_process1_down(coeffs, state, x[i]);
else {
for (int i = 0; i < n_samples; i++)
y[i] = x[i];
state->y_z1 = x[n_samples - 1];
}
}
} else { } else {
if (coeffs->max_rate_down != INFINITY) if (coeffs->max_rate_up != INFINITY) {
for (int i = 0; i < n_samples; i++) if (coeffs->max_rate_down != INFINITY)
y[i] = bw_slew_lim_process1_down(coeffs, state, x[i]); for (int i = 0; i < n_samples; i++)
else bw_slew_lim_process1(coeffs, state, x[i]);
for (int i = 0; i < n_samples; i++) else
y[i] = x[i]; for (int i = 0; i < n_samples; i++)
bw_slew_lim_process1_up(coeffs, state, x[i]);
} else {
if (coeffs->max_rate_down != INFINITY)
for (int i = 0; i < n_samples; i++)
bw_slew_lim_process1_down(coeffs, state, x[i]);
else
state->y_z1 = x[n_samples - 1];
}
} }
} }