|
|
|
@ -42,6 +42,7 @@
|
|
|
|
|
* <li>Removed usage of reserved identifiers.</li>
|
|
|
|
|
* <li>Now using backward Euler rather than impulse invariant
|
|
|
|
|
* method.</li>
|
|
|
|
|
* <li>Added more debugging code.</li>
|
|
|
|
|
* </ul>
|
|
|
|
|
* </li>
|
|
|
|
|
* <li>Version <strong>0.6.0</strong>:
|
|
|
|
@ -264,6 +265,8 @@ static inline void bw_one_pole_set_cutoff(
|
|
|
|
|
* `bw_one_pole_set_tau()` with same `coeffs` and
|
|
|
|
|
* value = 1 / (2 * pi * `value`) (net of numerical errors).
|
|
|
|
|
*
|
|
|
|
|
* `value` must be non-negative.
|
|
|
|
|
*
|
|
|
|
|
* Default value: `INFINITY`.
|
|
|
|
|
*
|
|
|
|
|
* #### bw_one_pole_set_cutoff_up()
|
|
|
|
@ -278,6 +281,8 @@ static inline void bw_one_pole_set_cutoff_up(
|
|
|
|
|
* This is equivalent to calling `bw_one_pole_set_tau_up()` with same
|
|
|
|
|
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
|
|
|
|
*
|
|
|
|
|
* `value` must be non-negative.
|
|
|
|
|
*
|
|
|
|
|
* Default value: `INFINITY`.
|
|
|
|
|
*
|
|
|
|
|
* #### bw_one_pole_set_cutoff_down()
|
|
|
|
@ -292,6 +297,8 @@ static inline void bw_one_pole_set_cutoff_down(
|
|
|
|
|
* This is equivalent to calling `bw_one_pole_set_tau_down()` with same
|
|
|
|
|
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
|
|
|
|
*
|
|
|
|
|
* `value` must be non-negative.
|
|
|
|
|
*
|
|
|
|
|
* Default value: `INFINITY`.
|
|
|
|
|
*
|
|
|
|
|
* #### bw_one_pole_set_tau()
|
|
|
|
@ -308,6 +315,8 @@ static inline void bw_one_pole_set_tau(
|
|
|
|
|
* `bw_one_pole_set_cutoff()` with same `coeffs` and
|
|
|
|
|
* value = 1 / (2 * pi * `value`) (net of numerical errors).
|
|
|
|
|
*
|
|
|
|
|
* `value` must be non-negative.
|
|
|
|
|
*
|
|
|
|
|
* Default value: `0.f`.
|
|
|
|
|
*
|
|
|
|
|
* #### bw_one_pole_set_tau_up()
|
|
|
|
@ -322,6 +331,8 @@ static inline void bw_one_pole_set_tau_up(
|
|
|
|
|
* This is equivalent to calling `bw_one_pole_set_cutoff_up()` with same
|
|
|
|
|
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
|
|
|
|
*
|
|
|
|
|
* `value` must be non-negative.
|
|
|
|
|
*
|
|
|
|
|
* Default value: `0.f`.
|
|
|
|
|
*
|
|
|
|
|
* #### bw_one_pole_set_tau_down()
|
|
|
|
@ -336,6 +347,8 @@ static inline void bw_one_pole_set_tau_down(
|
|
|
|
|
* This is equivalent to calling `bw_one_pole_set_cutoff_down()` with same
|
|
|
|
|
* `coeffs` and value = 1 / (2 * pi * `value`) (net of numerical errors).
|
|
|
|
|
*
|
|
|
|
|
* `value` must be non-negative.
|
|
|
|
|
*
|
|
|
|
|
* Default value: `0.f`.
|
|
|
|
|
*
|
|
|
|
|
* #### bw_one_pole_set_sticky_thresh()
|
|
|
|
@ -351,6 +364,8 @@ static inline void bw_one_pole_set_sticky_thresh(
|
|
|
|
|
* `bw_one_pole_set_sticky_mode()`), the output is forcefully set to be equal
|
|
|
|
|
* to the input value.
|
|
|
|
|
*
|
|
|
|
|
* Valid range: [`0.f`, `1e18f`].
|
|
|
|
|
*
|
|
|
|
|
* Default value: `0.f`.
|
|
|
|
|
*
|
|
|
|
|
* #### bw_one_pole_set_sticky_mode()
|
|
|
|
@ -470,6 +485,7 @@ static inline void bw_one_pole_init(
|
|
|
|
|
coeffs->reset_id = coeffs->hash + 1;
|
|
|
|
|
#endif
|
|
|
|
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
|
|
|
|
BW_ASSERT_DEEP(coeffs->state == bw_one_pole_coeffs_state_init);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void bw_one_pole_set_sample_rate(
|
|
|
|
@ -478,6 +494,7 @@ static inline void bw_one_pole_set_sample_rate(
|
|
|
|
|
BW_ASSERT(coeffs != NULL);
|
|
|
|
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
|
|
|
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_init);
|
|
|
|
|
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
|
|
|
|
|
|
|
|
|
coeffs->fs_2pi = 0.15915494309189535f * sample_rate;
|
|
|
|
|
|
|
|
|
@ -485,6 +502,7 @@ static inline void bw_one_pole_set_sample_rate(
|
|
|
|
|
coeffs->state = bw_one_pole_coeffs_state_set_sample_rate;
|
|
|
|
|
#endif
|
|
|
|
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
|
|
|
|
BW_ASSERT_DEEP(coeffs->state == bw_one_pole_coeffs_state_set_sample_rate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void bw_one_pole_do_update_coeffs_ctrl(
|
|
|
|
@ -516,6 +534,7 @@ static inline void bw_one_pole_reset_coeffs(
|
|
|
|
|
coeffs->reset_id++;
|
|
|
|
|
#endif
|
|
|
|
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
|
|
|
|
BW_ASSERT_DEEP(coeffs->state == bw_one_pole_coeffs_state_reset_coeffs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void bw_one_pole_reset_state(
|
|
|
|
@ -538,6 +557,7 @@ static inline void bw_one_pole_reset_state(
|
|
|
|
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
|
|
|
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs);
|
|
|
|
|
BW_ASSERT_DEEP(bw_one_pole_state_is_valid(state));
|
|
|
|
|
BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void bw_one_pole_update_coeffs_ctrl(
|
|
|
|
@ -810,7 +830,8 @@ static inline void bw_one_pole_process_multi(
|
|
|
|
|
BW_ASSERT(coeffs != NULL);
|
|
|
|
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
|
|
|
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs);
|
|
|
|
|
//...
|
|
|
|
|
BW_ASSERT(state != NULL);
|
|
|
|
|
BW_ASSERT(x != NULL);
|
|
|
|
|
|
|
|
|
|
bw_one_pole_update_coeffs_ctrl(coeffs);
|
|
|
|
|
if (y != NULL) {
|
|
|
|
@ -910,7 +931,8 @@ static inline void bw_one_pole_process_multi(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//...
|
|
|
|
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
|
|
|
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static inline void bw_one_pole_set_cutoff(bw_one_pole_coeffs *BW_RESTRICT coeffs, float value) {
|
|
|
|
@ -1017,7 +1039,8 @@ static inline void bw_one_pole_set_sticky_thresh(
|
|
|
|
|
BW_ASSERT(coeffs != NULL);
|
|
|
|
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
|
|
|
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_init);
|
|
|
|
|
//...
|
|
|
|
|
BW_ASSERT(!bw_is_nan(value));
|
|
|
|
|
BW_ASSERT(value >= 0.f && value <= 1e18f);
|
|
|
|
|
|
|
|
|
|
if (coeffs->sticky_thresh != value) {
|
|
|
|
|
coeffs->sticky_thresh = value;
|
|
|
|
@ -1034,7 +1057,7 @@ static inline void bw_one_pole_set_sticky_mode(
|
|
|
|
|
BW_ASSERT(coeffs != NULL);
|
|
|
|
|
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
|
|
|
|
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_init);
|
|
|
|
|
//...
|
|
|
|
|
BW_ASSERT(value == bw_one_pole_sticky_mode_abs || value == bw_one_pole_sticky_mode_rel);
|
|
|
|
|
|
|
|
|
|
coeffs->sticky_mode = value;
|
|
|
|
|
|
|
|
|
@ -1057,9 +1080,34 @@ static inline char bw_one_pole_coeffs_is_valid(
|
|
|
|
|
#ifdef BW_DEBUG_DEEP
|
|
|
|
|
if (coeffs->hash != bw_hash_sdbm("bw_one_pole_coeffs"))
|
|
|
|
|
return 0;
|
|
|
|
|
if (coeffs->state < bw_one_pole_coeffs_state_init || coeffs->state > bw_one_pole_coeffs_state_reset_coeffs)
|
|
|
|
|
return 0;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
if (coeffs->cutoff_up < 0.f)
|
|
|
|
|
return 0;
|
|
|
|
|
if (coeffs->cutoff_down < 0.f)
|
|
|
|
|
return 0;
|
|
|
|
|
if (coeffs->sticky_thresh < 0.f || coeffs->sticky_thresh > 1e18f)
|
|
|
|
|
return 0;
|
|
|
|
|
if (coeffs->sticky_mode != bw_one_pole_sticky_mode_abs && coeffs->sticky_mode != bw_one_pole_sticky_mode_rel)
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
#ifdef BW_DEBUG_DEEP
|
|
|
|
|
if (coeffs->state >= bw_one_pole_coeffs_state_set_sample_rate) {
|
|
|
|
|
if (!bw_is_finite(coeffs->fs_2pi) || coeffs->fs_2pi < 0.f)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs) {
|
|
|
|
|
if (!bw_is_finite(coeffs->mA1u) || coeffs->mA1u < 0.f || coeffs->mA1u > 1.f)
|
|
|
|
|
return 0;
|
|
|
|
|
if (!bw_is_finite(coeffs->mA1d) || coeffs->mA1d < 0.f || coeffs->mA1d > 1.f)
|
|
|
|
|
return 0;
|
|
|
|
|
if (!bw_is_finite(coeffs->st2) || coeffs->st2 < 0.f)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
(void)coeffs;
|
|
|
|
|
//...
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|