finalized bw_env_follow, untested + wip bw_comp
This commit is contained in:
parent
0ef455722f
commit
69b74c4ccb
@ -31,8 +31,10 @@
|
|||||||
* <ul>
|
* <ul>
|
||||||
* <li>Version <strong>1.0.0</strong>:
|
* <li>Version <strong>1.0.0</strong>:
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>Added initial value arguments in
|
* <li>Added <code>bw_comp_reset_state_multi()</code> and updated C++
|
||||||
* <code>bw_comp_reset_state()</code>.</li>
|
* API in this regard.</li>
|
||||||
|
* <li>Now <code>bw_comp_reset_state()</code> returns the initial
|
||||||
|
* output value.</li>
|
||||||
* <li>Added overloaded C++ <code>reset()</code> functions taking
|
* <li>Added overloaded C++ <code>reset()</code> functions taking
|
||||||
* arrays as arguments.</li>
|
* arrays as arguments.</li>
|
||||||
* <li><code>bw_comp_process()</code> and
|
* <li><code>bw_comp_process()</code> and
|
||||||
@ -44,6 +46,8 @@
|
|||||||
* <li>Added overloaded C++ <code>process()</code> function taking
|
* <li>Added overloaded C++ <code>process()</code> function taking
|
||||||
* C-style arrays as arguments.</li>
|
* C-style arrays as arguments.</li>
|
||||||
* <li>Removed usage of reserved identifiers.</li>
|
* <li>Removed usage of reserved identifiers.</li>
|
||||||
|
* <li>Clearly specified parameter validity ranges.</li>
|
||||||
|
* <li>Added debugging code.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* </li>
|
* </li>
|
||||||
* <li>Version <strong>0.6.0</strong>:
|
* <li>Version <strong>0.6.0</strong>:
|
||||||
@ -92,45 +96,77 @@ typedef struct bw_comp_state bw_comp_state;
|
|||||||
*
|
*
|
||||||
* #### bw_comp_init()
|
* #### bw_comp_init()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_init(bw_comp_coeffs *BW_RESTRICT coeffs);
|
static inline void bw_comp_init(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Initializes input parameter values in `coeffs`.
|
* Initializes input parameter values in `coeffs`.
|
||||||
*
|
*
|
||||||
* #### bw_comp_set_sample_rate()
|
* #### bw_comp_set_sample_rate()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_set_sample_rate(bw_comp_coeffs *BW_RESTRICT coeffs, float sample_rate);
|
static inline void bw_comp_set_sample_rate(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float sample_rate);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Sets the `sample_rate` (Hz) value in `coeffs`.
|
* Sets the `sample_rate` (Hz) value in `coeffs`.
|
||||||
*
|
*
|
||||||
* #### bw_comp_reset_coeffs()
|
* #### bw_comp_reset_coeffs()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_reset_coeffs(bw_comp_coeffs *BW_RESTRICT coeffs);
|
static inline void bw_comp_reset_coeffs(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Resets coefficients in `coeffs` to assume their target values.
|
* Resets coefficients in `coeffs` to assume their target values.
|
||||||
*
|
*
|
||||||
* #### bw_comp_reset_state()
|
* #### bw_comp_reset_state()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_reset_state(const bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state, float x_0, float x_sc_0);
|
static inline float bw_comp_reset_state(
|
||||||
|
const bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_comp_state * BW_RESTRICT state,
|
||||||
|
float x_0,
|
||||||
|
float x_sc_0);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Resets the given `state` to its initial values using the given `coeffs`
|
* Resets the given `state` to its initial values using the given `coeffs`
|
||||||
* and the quiescent/initial input value `x_0` and sidechain input value
|
* and the initial input value `x_0` and sidechain input value `x_sc_0`.
|
||||||
* `x_sc_0`.
|
*
|
||||||
|
* Returns the corresponding initial output value.
|
||||||
|
*
|
||||||
|
* #### bw_comp_reset_state_multi()
|
||||||
|
* ```>>> */
|
||||||
|
static inline void bw_comp_reset_state_multi(
|
||||||
|
const bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_comp_state * BW_RESTRICT const * BW_RESTRICT state,
|
||||||
|
const float * x_0,
|
||||||
|
const float * x_sc_0,
|
||||||
|
float * y_0,
|
||||||
|
size_t n_channels);
|
||||||
|
/*! <<<```
|
||||||
|
* Resets each of the `n_channels` `state`s to its initial values using the
|
||||||
|
* given `coeffs` and the corresponding initial input value in the `x_0`
|
||||||
|
* array and sidechain input value in the `x_sc_0` array.
|
||||||
|
*
|
||||||
|
* The corresponding initial output values are written into the `y_0` array,
|
||||||
|
* if not `NULL`.
|
||||||
*
|
*
|
||||||
* #### bw_comp_update_coeffs_ctrl()
|
* #### bw_comp_update_coeffs_ctrl()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_update_coeffs_ctrl(bw_comp_coeffs *BW_RESTRICT coeffs);
|
static inline void bw_comp_update_coeffs_ctrl(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Triggers control-rate update of coefficients in `coeffs`.
|
* Triggers control-rate update of coefficients in `coeffs`.
|
||||||
*
|
*
|
||||||
* #### bw_comp_update_coeffs_audio()
|
* #### bw_comp_update_coeffs_audio()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_update_coeffs_audio(bw_comp_coeffs *BW_RESTRICT coeffs);
|
static inline void bw_comp_update_coeffs_audio(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Triggers audio-rate update of coefficients in `coeffs`.
|
* Triggers audio-rate update of coefficients in `coeffs`.
|
||||||
*
|
*
|
||||||
* #### bw_comp_process1()
|
* #### bw_comp_process1()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline float bw_comp_process1(const bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state, float x, float x_sc);
|
static inline float bw_comp_process1(
|
||||||
|
const bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_comp_state * BW_RESTRICT state,
|
||||||
|
float x,
|
||||||
|
float x_sc);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Processes one input sample `x` and the corresponding sidechain input
|
* Processes one input sample `x` and the corresponding sidechain input
|
||||||
* sample `x_sc` using `coeffs`, while using and updating `state`. Returns
|
* sample `x_sc` using `coeffs`, while using and updating `state`. Returns
|
||||||
@ -138,7 +174,13 @@ static inline float bw_comp_process1(const bw_comp_coeffs *BW_RESTRICT coeffs, b
|
|||||||
*
|
*
|
||||||
* #### bw_comp_process()
|
* #### bw_comp_process()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_process(bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state, const float *x, const float *x_sc, float *y, size_t n_samples);
|
static inline void bw_comp_process(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_comp_state * BW_RESTRICT state,
|
||||||
|
const float * x,
|
||||||
|
const float * x_sc,
|
||||||
|
float * y,
|
||||||
|
size_t n_samples);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Processes the first `n_samples` of the input buffer `x` and the first
|
* Processes the first `n_samples` of the input buffer `x` and the first
|
||||||
* `n_samples` of the sidechain input buffer `x_sc`, and fills the first
|
* `n_samples` of the sidechain input buffer `x_sc`, and fills the first
|
||||||
@ -147,7 +189,14 @@ static inline void bw_comp_process(bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_s
|
|||||||
*
|
*
|
||||||
* #### bw_comp_process_multi()
|
* #### bw_comp_process_multi()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_process_multi(bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, const float * const *x_sc, float * const *y, size_t n_channels, size_t n_samples);
|
static inline void bw_comp_process_multi(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_comp_state * BW_RESTRICT const * BW_RESTRICT state,
|
||||||
|
const float * const * x,
|
||||||
|
const float * const * x_sc,
|
||||||
|
float * const * y,
|
||||||
|
size_t n_channels,
|
||||||
|
size_t n_samples);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Processes the first `n_samples` of the `n_channels` input buffers `x` and
|
* Processes the first `n_samples` of the `n_channels` input buffers `x` and
|
||||||
* the first `n_samples` of the `n_channels` sidechain input buffers `x_sc`,
|
* the first `n_samples` of the `n_channels` sidechain input buffers `x_sc`,
|
||||||
@ -157,23 +206,33 @@ static inline void bw_comp_process_multi(bw_comp_coeffs *BW_RESTRICT coeffs, bw_
|
|||||||
*
|
*
|
||||||
* #### bw_comp_set_thresh_lin()
|
* #### bw_comp_set_thresh_lin()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_set_thresh_lin(bw_comp_coeffs *BW_RESTRICT coeffs, float value);
|
static inline void bw_comp_set_thresh_lin(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Sets the threshold `value` (linear) in `coeffs`.
|
* Sets the threshold `value` (linear) in `coeffs`.
|
||||||
*
|
*
|
||||||
|
* Valid range: [`1e-20f`, `1e20f`].
|
||||||
|
*
|
||||||
* Default value: `1.f`.
|
* Default value: `1.f`.
|
||||||
*
|
*
|
||||||
* #### bw_comp_set_thresh_dBFS()
|
* #### bw_comp_set_thresh_dBFS()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_set_thresh_dBFS(bw_comp_coeffs *BW_RESTRICT coeffs, float value);
|
static inline void bw_comp_set_thresh_dBFS(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Sets the threshold `value` (dBFS) in `coeffs`.
|
* Sets the threshold `value` (dBFS) in `coeffs`.
|
||||||
*
|
*
|
||||||
|
* Valid range: [`-400.f`, `400.f`].
|
||||||
|
*
|
||||||
* Default value: `0.f`.
|
* Default value: `0.f`.
|
||||||
*
|
*
|
||||||
* #### bw_comp_set_ratio()
|
* #### bw_comp_set_ratio()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_set_ratio(bw_comp_coeffs *BW_RESTRICT coeffs, float value);
|
static inline void bw_comp_set_ratio(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Sets the compression ratio `value` in `coeffs`.
|
* Sets the compression ratio `value` in `coeffs`.
|
||||||
*
|
*
|
||||||
@ -186,34 +245,50 @@ static inline void bw_comp_set_ratio(bw_comp_coeffs *BW_RESTRICT coeffs, float v
|
|||||||
*
|
*
|
||||||
* #### bw_comp_set_attack_tau()
|
* #### bw_comp_set_attack_tau()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_set_attack_tau(bw_comp_coeffs *BW_RESTRICT coeffs, float value);
|
static inline void bw_comp_set_attack_tau(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Sets the attack time constant `value` (s) in `coeffs`.
|
* Sets the attack time constant `value` (s) in `coeffs`.
|
||||||
*
|
*
|
||||||
|
* `value` must be non-negative.
|
||||||
|
*
|
||||||
* Default value: `0.f`.
|
* Default value: `0.f`.
|
||||||
*
|
*
|
||||||
* #### bw_comp_set_release_tau()
|
* #### bw_comp_set_release_tau()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_set_release_tau(bw_comp_coeffs *BW_RESTRICT coeffs, float value);
|
static inline void bw_comp_set_release_tau(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Sets the release time constant `value` (s) in `coeffs`.
|
* Sets the release time constant `value` (s) in `coeffs`.
|
||||||
*
|
*
|
||||||
|
* `value` must be non-negative.
|
||||||
|
*
|
||||||
* Default value: `0.f`.
|
* Default value: `0.f`.
|
||||||
*
|
*
|
||||||
* #### bw_comp_set_gain_lin()
|
* #### bw_comp_set_gain_lin()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_set_gain_lin(bw_comp_coeffs *BW_RESTRICT coeffs, float value);
|
static inline void bw_comp_set_gain_lin(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Sets the output makeup gain `value` (linear ratio) in `coeffs`.
|
* Sets the output makeup gain `value` (linear ratio) in `coeffs`.
|
||||||
*
|
*
|
||||||
|
* `value` must be finite.
|
||||||
|
*
|
||||||
* Default value: `1.f`.
|
* Default value: `1.f`.
|
||||||
*
|
*
|
||||||
* #### bw_comp_set_gain_dB()
|
* #### bw_comp_set_gain_dB()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_comp_set_gain_dB(bw_comp_coeffs *BW_RESTRICT coeffs, float value);
|
static inline void bw_comp_set_gain_dB(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Sets the output makeup gain `value` (dB) in `coeffs`.
|
* Sets the output makeup gain `value` (dB) in `coeffs`.
|
||||||
*
|
*
|
||||||
|
* `value` must be less than or equal to `770.630f`.
|
||||||
|
*
|
||||||
* Default value: `0.f`.
|
* Default value: `0.f`.
|
||||||
* }}} */
|
* }}} */
|
||||||
|
|
||||||
@ -235,49 +310,110 @@ static inline void bw_comp_set_gain_dB(bw_comp_coeffs *BW_RESTRICT coeffs, float
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
enum bw_comp_coeffs_state {
|
||||||
|
bw_comp_coeffs_state_invalid,
|
||||||
|
bw_comp_coeffs_state_init,
|
||||||
|
bw_comp_coeffs_state_set_sample_rate,
|
||||||
|
bw_comp_coeffs_state_reset_coeffs
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct bw_comp_coeffs {
|
struct bw_comp_coeffs {
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
uint32_t hash;
|
||||||
|
enum bw_comp_coeffs_state state;
|
||||||
|
uint32_t reset_id;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Sub-components
|
// Sub-components
|
||||||
bw_env_follow_coeffs env_follow_coeffs;
|
bw_env_follow_coeffs env_follow_coeffs;
|
||||||
bw_gain_coeffs gain_coeffs;
|
bw_gain_coeffs gain_coeffs;
|
||||||
bw_one_pole_coeffs smooth_coeffs;
|
bw_one_pole_coeffs smooth_coeffs;
|
||||||
bw_one_pole_state smooth_thresh_state;
|
bw_one_pole_state smooth_thresh_state;
|
||||||
bw_one_pole_state smooth_ratio_state;
|
bw_one_pole_state smooth_ratio_state;
|
||||||
|
|
||||||
// Coefficients
|
// Coefficients
|
||||||
float kc;
|
float kc;
|
||||||
|
|
||||||
// Parameters
|
// Parameters
|
||||||
float thresh;
|
float thresh;
|
||||||
float ratio;
|
float ratio;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bw_comp_state {
|
struct bw_comp_state {
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
uint32_t hash;
|
||||||
|
uint32_t coeffs_reset_id;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Sub-components
|
||||||
bw_env_follow_state env_follow_state;
|
bw_env_follow_state env_follow_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void bw_comp_init(bw_comp_coeffs *BW_RESTRICT coeffs) {
|
static inline void bw_comp_init(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
|
||||||
bw_env_follow_init(&coeffs->env_follow_coeffs);
|
bw_env_follow_init(&coeffs->env_follow_coeffs);
|
||||||
bw_gain_init(&coeffs->gain_coeffs);
|
bw_gain_init(&coeffs->gain_coeffs);
|
||||||
bw_one_pole_set_tau(&coeffs->smooth_coeffs, 0.05f);
|
bw_one_pole_set_tau(&coeffs->smooth_coeffs, 0.05f);
|
||||||
coeffs->thresh = 1.f;
|
coeffs->thresh = 1.f;
|
||||||
coeffs->ratio = 1.f;
|
coeffs->ratio = 1.f;
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
coeffs->hash = bw_hash_sdbm("bw_comp_coeffs");
|
||||||
|
coeffs->state = bw_comp_coeffs_state_init;
|
||||||
|
coeffs->reset_id = coeffs->hash + 1;
|
||||||
|
#endif
|
||||||
|
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state == bw_comp_coeffs_state_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_comp_set_sample_rate(bw_comp_coeffs *BW_RESTRICT coeffs, float sample_rate) {
|
static inline void bw_comp_set_sample_rate(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float sample_rate) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_init);
|
||||||
|
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||||
|
|
||||||
bw_env_follow_set_sample_rate(&coeffs->env_follow_coeffs, sample_rate);
|
bw_env_follow_set_sample_rate(&coeffs->env_follow_coeffs, sample_rate);
|
||||||
bw_gain_set_sample_rate(&coeffs->gain_coeffs, sample_rate);
|
bw_gain_set_sample_rate(&coeffs->gain_coeffs, sample_rate);
|
||||||
bw_one_pole_set_sample_rate(&coeffs->smooth_coeffs, sample_rate);
|
bw_one_pole_set_sample_rate(&coeffs->smooth_coeffs, sample_rate);
|
||||||
bw_one_pole_reset_coeffs(&coeffs->smooth_coeffs);
|
bw_one_pole_reset_coeffs(&coeffs->smooth_coeffs);
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
coeffs->state = bw_comp_coeffs_state_set_sample_rate;
|
||||||
|
#endif
|
||||||
|
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state == bw_comp_coeffs_state_set_sample_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_comp_reset_coeffs(bw_comp_coeffs *BW_RESTRICT coeffs) {
|
static inline void bw_comp_reset_coeffs(
|
||||||
|
bw_comp_coeffs * BW_RESTRICT coeffs) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_set_sample_rate);
|
||||||
|
|
||||||
bw_env_follow_reset_coeffs(&coeffs->env_follow_coeffs);
|
bw_env_follow_reset_coeffs(&coeffs->env_follow_coeffs);
|
||||||
bw_gain_reset_coeffs(&coeffs->gain_coeffs);
|
bw_gain_reset_coeffs(&coeffs->gain_coeffs);
|
||||||
bw_one_pole_reset_state(&coeffs->smooth_coeffs, &coeffs->smooth_thresh_state, coeffs->thresh);
|
bw_one_pole_reset_state(&coeffs->smooth_coeffs, &coeffs->smooth_thresh_state, coeffs->thresh);
|
||||||
bw_one_pole_reset_state(&coeffs->smooth_coeffs, &coeffs->smooth_ratio_state, coeffs->ratio);
|
bw_one_pole_reset_state(&coeffs->smooth_coeffs, &coeffs->smooth_ratio_state, coeffs->ratio);
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
coeffs->state = bw_comp_coeffs_state_reset_coeffs;
|
||||||
|
coeffs->reset_id++;
|
||||||
|
#endif
|
||||||
|
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state == bw_comp_coeffs_state_reset_coeffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_comp_reset_state(const bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state, float x_0, float x_sc_0) {
|
static inline float bw_comp_reset_state(
|
||||||
|
const bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_comp_state * BW_RESTRICT state,
|
||||||
|
float x_0,
|
||||||
|
float x_sc_0) {
|
||||||
(void)x_0;
|
(void)x_0;
|
||||||
bw_env_follow_reset_state(&coeffs->env_follow_coeffs, &state->env_follow_state, x_sc_0);
|
bw_env_follow_reset_state(&coeffs->env_follow_coeffs, &state->env_follow_state, x_sc_0);
|
||||||
}
|
}
|
||||||
@ -297,8 +433,18 @@ static inline void bw_comp_update_coeffs_audio(bw_comp_coeffs *BW_RESTRICT coeff
|
|||||||
static inline float bw_comp_process1(const bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state, float x, float x_sc) {
|
static inline float bw_comp_process1(const bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state, float x, float x_sc) {
|
||||||
const float env = bw_env_follow_process1(&coeffs->env_follow_coeffs, &state->env_follow_state, x_sc);
|
const float env = bw_env_follow_process1(&coeffs->env_follow_coeffs, &state->env_follow_state, x_sc);
|
||||||
const float thresh = bw_one_pole_get_y_z1(&coeffs->smooth_thresh_state);
|
const float thresh = bw_one_pole_get_y_z1(&coeffs->smooth_thresh_state);
|
||||||
const float y = env > thresh ? bw_pow2f(coeffs->kc * bw_log2f(thresh * bw_rcpf(env))) * x : x;
|
float y;
|
||||||
return bw_gain_process1(&coeffs->gain_coeffs, y);
|
if (env > thresh) {
|
||||||
|
float v = thresh * bw_rcpf(env);
|
||||||
|
if (v >= 1.175494350822287e-38f) {
|
||||||
|
v = coeffs->kc * bw_log2f(v);
|
||||||
|
y = v > -126.f ? bw_pow2f(v) * x: thresh;
|
||||||
|
} else
|
||||||
|
y = thresh;
|
||||||
|
} else
|
||||||
|
y = x;
|
||||||
|
y = bw_gain_process1(&coeffs->gain_coeffs, y);
|
||||||
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_comp_process(bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state, const float *x, const float *x_sc, float *y, size_t n_samples) {
|
static inline void bw_comp_process(bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state, const float *x, const float *x_sc, float *y, size_t n_samples) {
|
||||||
|
@ -30,6 +30,12 @@
|
|||||||
* <ul>
|
* <ul>
|
||||||
* <li>Version <strong>1.0.0</strong>:
|
* <li>Version <strong>1.0.0</strong>:
|
||||||
* <ul>
|
* <ul>
|
||||||
|
* <li>Added <code>bw_env_follow_reset_state_multi()</code> and updated
|
||||||
|
* C++ API in this regard.</li>
|
||||||
|
* <li>Now <code>bw_env_follow_reset_state()</code> returns the initial
|
||||||
|
* output value.</li>
|
||||||
|
* <li>Added overloaded C++ <code>reset()</code> functions taking
|
||||||
|
* arrays as arguments.</li>
|
||||||
* <li><code>bw_env_follow_process()</code> and
|
* <li><code>bw_env_follow_process()</code> and
|
||||||
* <code>bw_env_follow_process_multi()</code> now use
|
* <code>bw_env_follow_process_multi()</code> now use
|
||||||
* <code>size_t</code> to count samples and channels.</li>
|
* <code>size_t</code> to count samples and channels.</li>
|
||||||
@ -39,6 +45,8 @@
|
|||||||
* <li>Added overloaded C++ <code>process()</code> function taking
|
* <li>Added overloaded C++ <code>process()</code> function taking
|
||||||
* C-style arrays as arguments.</li>
|
* C-style arrays as arguments.</li>
|
||||||
* <li>Removed usage of reserved identifiers.</li>
|
* <li>Removed usage of reserved identifiers.</li>
|
||||||
|
* <li>Clearly specified parameter validity ranges.</li>
|
||||||
|
* <li>Added debugging code.</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
* </li>
|
* </li>
|
||||||
* <li>Version <strong>0.6.0</strong>:
|
* <li>Version <strong>0.6.0</strong>:
|
||||||
@ -95,50 +103,86 @@ typedef struct bw_env_follow_state bw_env_follow_state;
|
|||||||
*
|
*
|
||||||
* #### bw_env_follow_init()
|
* #### bw_env_follow_init()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_env_follow_init(bw_env_follow_coeffs *BW_RESTRICT coeffs);
|
static inline void bw_env_follow_init(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Initializes input parameter values in `coeffs`.
|
* Initializes input parameter values in `coeffs`.
|
||||||
*
|
*
|
||||||
* #### bw_env_follow_set_sample_rate()
|
* #### bw_env_follow_set_sample_rate()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_env_follow_set_sample_rate(bw_env_follow_coeffs *BW_RESTRICT coeffs, float sample_rate);
|
static inline void bw_env_follow_set_sample_rate(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float sample_rate);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Sets the `sample_rate` (Hz) value in `coeffs`.
|
* Sets the `sample_rate` (Hz) value in `coeffs`.
|
||||||
*
|
*
|
||||||
* #### bw_env_follow_reset_coeffs()
|
* #### bw_env_follow_reset_coeffs()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_env_follow_reset_coeffs(bw_env_follow_coeffs *BW_RESTRICT coeffs);
|
static inline void bw_env_follow_reset_coeffs(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Resets coefficients in `coeffs` to assume their target values.
|
* Resets coefficients in `coeffs` to assume their target values.
|
||||||
*
|
*
|
||||||
* #### bw_env_follow_reset_state()
|
* #### bw_env_follow_reset_state()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_env_follow_reset_state(const bw_env_follow_coeffs *BW_RESTRICT coeffs, bw_env_follow_state *BW_RESTRICT state);
|
static inline float bw_env_follow_reset_state(
|
||||||
|
const bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_env_follow_state * BW_RESTRICT state,
|
||||||
|
float x_0);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Resets the given `state` to its initial values using the given `coeffs`.
|
* Resets the given `state` to its initial values using the given `coeffs`
|
||||||
|
* and the initial input value `x_0`.
|
||||||
|
*
|
||||||
|
* Returns the corresponding initial output value.
|
||||||
|
*
|
||||||
|
* #### bw_env_follow_reset_state_multi()
|
||||||
|
* ```>>> */
|
||||||
|
static inline void bw_env_follow_reset_state_multi(
|
||||||
|
const bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_env_follow_state * BW_RESTRICT const * BW_RESTRICT state,
|
||||||
|
const float * x_0,
|
||||||
|
float * y_0,
|
||||||
|
size_t n_channels);
|
||||||
|
/*! <<<```
|
||||||
|
* Resets each of the `n_channels` `state`s to its initial values using the
|
||||||
|
* given `coeffs` and the corresponding initial input value in the `x_0`
|
||||||
|
* array.
|
||||||
|
*
|
||||||
|
* The corresponding initial output values are written into the `y_0` array,
|
||||||
|
* if not `NULL`.
|
||||||
*
|
*
|
||||||
* #### bw_env_follow_update_coeffs_ctrl()
|
* #### bw_env_follow_update_coeffs_ctrl()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_env_follow_update_coeffs_ctrl(bw_env_follow_coeffs *BW_RESTRICT coeffs);
|
static inline void bw_env_follow_update_coeffs_ctrl(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Triggers control-rate update of coefficients in `coeffs`.
|
* Triggers control-rate update of coefficients in `coeffs`.
|
||||||
*
|
*
|
||||||
* #### bw_env_follow_update_coeffs_audio()
|
* #### bw_env_follow_update_coeffs_audio()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_env_follow_update_coeffs_audio(bw_env_follow_coeffs *BW_RESTRICT coeffs);
|
static inline void bw_env_follow_update_coeffs_audio(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Triggers audio-rate update of coefficients in `coeffs`.
|
* Triggers audio-rate update of coefficients in `coeffs`.
|
||||||
*
|
*
|
||||||
* #### bw_env_follow_process1()
|
* #### bw_env_follow_process1()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline float bw_env_follow_process1(const bw_env_follow_coeffs *BW_RESTRICT coeffs, bw_env_follow_state *BW_RESTRICT state, float x);
|
static inline float bw_env_follow_process1(
|
||||||
|
const bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_env_follow_state * BW_RESTRICT state,
|
||||||
|
float x);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Processes one input sample `x` using `coeffs`, while using and updating
|
* Processes one input sample `x` using `coeffs`, while using and updating
|
||||||
* `state`. Returns the corresponding output sample.
|
* `state`. Returns the corresponding output sample.
|
||||||
*
|
*
|
||||||
* #### bw_env_follow_process()
|
* #### bw_env_follow_process()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
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, size_t 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,
|
||||||
|
size_t n_samples);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Processes the first `n_samples` of the input buffer `x` and fills the
|
* Processes the first `n_samples` of the input buffer `x` and fills the
|
||||||
* first `n_samples` of the output buffer `y`, while using and updating both
|
* first `n_samples` of the output buffer `y`, while using and updating both
|
||||||
@ -148,7 +192,13 @@ static inline void bw_env_follow_process(bw_env_follow_coeffs *BW_RESTRICT coeff
|
|||||||
*
|
*
|
||||||
* #### bw_env_follow_process_multi()
|
* #### bw_env_follow_process_multi()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_env_follow_process_multi(bw_env_follow_coeffs *BW_RESTRICT coeffs, bw_env_follow_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t n_channels, size_t n_samples);
|
static inline void bw_env_follow_process_multi(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_env_follow_state * BW_RESTRICT const * BW_RESTRICT state,
|
||||||
|
const float * const * x,
|
||||||
|
float * const * y,
|
||||||
|
size_t n_channels,
|
||||||
|
size_t n_samples);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Processes the first `n_samples` of the `n_channels` input buffers `x` and
|
* Processes the first `n_samples` of the `n_channels` input buffers `x` and
|
||||||
* fills the first `n_samples` of the `n_channels` output buffers `y`, while
|
* fills the first `n_samples` of the `n_channels` output buffers `y`, while
|
||||||
@ -159,27 +209,64 @@ static inline void bw_env_follow_process_multi(bw_env_follow_coeffs *BW_RESTRICT
|
|||||||
*
|
*
|
||||||
* #### bw_env_follow_set_attack_tau()
|
* #### bw_env_follow_set_attack_tau()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
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);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Sets the upgoing (attack) time constant in `coeffs` of the one-pole filter
|
* Sets the upgoing (attack) time constant in `coeffs` of the one-pole filter
|
||||||
* to `value` (s).
|
* to `value` (s).
|
||||||
*
|
*
|
||||||
|
* `value` must be non-negative.
|
||||||
|
*
|
||||||
* Default value: `0.f`.
|
* Default value: `0.f`.
|
||||||
*
|
*
|
||||||
* #### bw_env_follow_set_release_tau()
|
* #### bw_env_follow_set_release_tau()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline void bw_env_follow_set_release_tau(bw_env_follow_coeffs *BW_RESTRICT coeffs, float value);
|
static inline void bw_env_follow_set_release_tau(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Sets the downgoing (release) time constant in `coeffs` of the one-pole
|
* Sets the downgoing (release) time constant in `coeffs` of the one-pole
|
||||||
* filter to `value` (s).
|
* filter to `value` (s).
|
||||||
*
|
*
|
||||||
|
* `value` must be non-negative.
|
||||||
|
*
|
||||||
* Default value: `0.f`.
|
* Default value: `0.f`.
|
||||||
*
|
*
|
||||||
* #### bw_env_follow_get_y_z1()
|
* #### bw_env_follow_get_y_z1()
|
||||||
* ```>>> */
|
* ```>>> */
|
||||||
static inline float bw_env_follow_get_y_z1(const bw_env_follow_state *BW_RESTRICT state);
|
static inline float bw_env_follow_get_y_z1(
|
||||||
|
const bw_env_follow_state * BW_RESTRICT state);
|
||||||
/*! <<<```
|
/*! <<<```
|
||||||
* Returns the last output sample as stored in `state`.
|
* Returns the last output sample as stored in `state`.
|
||||||
|
*
|
||||||
|
* #### bw_env_follow_coeffs_is_valid()
|
||||||
|
* ```>>> */
|
||||||
|
static inline char bw_env_follow_coeffs_is_valid(
|
||||||
|
const bw_env_follow_coeffs * BW_RESTRICT coeffs);
|
||||||
|
/*! <<<```
|
||||||
|
* Tries to determine whether `coeffs` is valid and returns non-`0` if it
|
||||||
|
* seems to be the case and `0` if it is certainly not. False positives are
|
||||||
|
* possible, false negatives are not.
|
||||||
|
*
|
||||||
|
* `coeffs` must at least point to a readable memory block of size greater
|
||||||
|
* than or equal to that of `bw_env_follow_coeffs`.
|
||||||
|
*
|
||||||
|
* #### bw_env_follow_state_is_valid()
|
||||||
|
* ```>>> */
|
||||||
|
static inline char bw_env_follow_state_is_valid(
|
||||||
|
const bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
const bw_env_follow_state * BW_RESTRICT state);
|
||||||
|
/*! <<<```
|
||||||
|
* Tries to determine whether `state` is valid and returns non-`0` if it
|
||||||
|
* seems to be the case and `0` if it is certainly not. False positives are
|
||||||
|
* possible, false negatives are not.
|
||||||
|
*
|
||||||
|
* If `coeffs` is not `NULL` extra cross-checks might be performed (`state`
|
||||||
|
* is supposed to be associated to `coeffs`).
|
||||||
|
*
|
||||||
|
* `state` must at least point to a readable memory block of size greater
|
||||||
|
* than or equal to that of `bw_env_follow_state`.
|
||||||
* }}} */
|
* }}} */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -198,45 +285,193 @@ static inline float bw_env_follow_get_y_z1(const bw_env_follow_state *BW_RESTRIC
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
enum bw_env_follow_coeffs_state {
|
||||||
|
bw_env_follow_coeffs_state_invalid,
|
||||||
|
bw_env_follow_coeffs_state_init,
|
||||||
|
bw_env_follow_coeffs_state_set_sample_rate,
|
||||||
|
bw_env_follow_coeffs_state_reset_coeffs
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
struct bw_env_follow_coeffs {
|
struct bw_env_follow_coeffs {
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
uint32_t hash;
|
||||||
|
enum bw_env_follow_coeffs_state state;
|
||||||
|
uint32_t reset_id;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Sub-components
|
// Sub-components
|
||||||
bw_one_pole_coeffs one_pole_coeffs;
|
bw_one_pole_coeffs one_pole_coeffs;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct bw_env_follow_state {
|
struct bw_env_follow_state {
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
uint32_t hash;
|
||||||
|
uint32_t coeffs_reset_id;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Sub-components
|
||||||
bw_one_pole_state one_pole_state;
|
bw_one_pole_state one_pole_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void bw_env_follow_init(bw_env_follow_coeffs *BW_RESTRICT coeffs) {
|
static inline void bw_env_follow_init(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
|
||||||
bw_one_pole_init(&coeffs->one_pole_coeffs);
|
bw_one_pole_init(&coeffs->one_pole_coeffs);
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
coeffs->hash = bw_hash_sdbm("bw_env_follow_coeffs");
|
||||||
|
coeffs->state = bw_env_follow_coeffs_state_init;
|
||||||
|
coeffs->reset_id = coeffs->hash + 1;
|
||||||
|
#endif
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state == bw_env_follow_coeffs_state_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_env_follow_set_sample_rate(bw_env_follow_coeffs *BW_RESTRICT coeffs, float sample_rate) {
|
static inline void bw_env_follow_set_sample_rate(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float sample_rate) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_init);
|
||||||
|
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||||
|
|
||||||
bw_one_pole_set_sample_rate(&coeffs->one_pole_coeffs, sample_rate);
|
bw_one_pole_set_sample_rate(&coeffs->one_pole_coeffs, sample_rate);
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
coeffs->state = bw_env_follow_coeffs_state_set_sample_rate;
|
||||||
|
#endif
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state == bw_env_follow_coeffs_state_set_sample_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_env_follow_reset_coeffs(bw_env_follow_coeffs *BW_RESTRICT coeffs) {
|
static inline void bw_env_follow_reset_coeffs(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_set_sample_rate);
|
||||||
|
|
||||||
bw_one_pole_reset_coeffs(&coeffs->one_pole_coeffs);
|
bw_one_pole_reset_coeffs(&coeffs->one_pole_coeffs);
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
coeffs->state = bw_env_follow_coeffs_state_reset_coeffs;
|
||||||
|
coeffs->reset_id++;
|
||||||
|
#endif
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state == bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_env_follow_reset_state(const bw_env_follow_coeffs *BW_RESTRICT coeffs, bw_env_follow_state *BW_RESTRICT state) {
|
static inline float bw_env_follow_reset_state(
|
||||||
bw_one_pole_reset_state(&coeffs->one_pole_coeffs, &state->one_pole_state, 0.f);
|
const bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_env_follow_state * BW_RESTRICT state,
|
||||||
|
float x_0) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
|
BW_ASSERT(state != NULL);
|
||||||
|
BW_ASSERT(bw_is_finite(x_0));
|
||||||
|
|
||||||
|
const float x = bw_absf(x_0);
|
||||||
|
const float y = bw_one_pole_reset_state(&coeffs->one_pole_coeffs, &state->one_pole_state, x);
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
state->hash = bw_hash_sdbm("bw_env_follow_state");
|
||||||
|
state->coeffs_reset_id = coeffs->reset_id;
|
||||||
|
#endif
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_state_is_valid(coeffs, state));
|
||||||
|
BW_ASSERT(bw_is_finite(y));
|
||||||
|
|
||||||
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_env_follow_update_coeffs_ctrl(bw_env_follow_coeffs *BW_RESTRICT coeffs) {
|
static inline void bw_env_follow_reset_state_multi(
|
||||||
|
const bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_env_follow_state * BW_RESTRICT const * BW_RESTRICT state,
|
||||||
|
const float * x_0,
|
||||||
|
float * y_0,
|
||||||
|
size_t n_channels) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
|
BW_ASSERT(state != NULL);
|
||||||
|
BW_ASSERT(x_0 != NULL);
|
||||||
|
|
||||||
|
if (y_0 != NULL)
|
||||||
|
for (size_t i = 0; i < n_channels; i++)
|
||||||
|
y_0[i] = bw_env_follow_reset_state(coeffs, state[i], x_0[i]);
|
||||||
|
else
|
||||||
|
for (size_t i = 0; i < n_channels; i++)
|
||||||
|
bw_env_follow_reset_state(coeffs, state[i], x_0[i]);
|
||||||
|
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
|
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void bw_env_follow_update_coeffs_ctrl(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
|
|
||||||
bw_one_pole_update_coeffs_ctrl(&coeffs->one_pole_coeffs);
|
bw_one_pole_update_coeffs_ctrl(&coeffs->one_pole_coeffs);
|
||||||
|
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_env_follow_update_coeffs_audio(bw_env_follow_coeffs *BW_RESTRICT coeffs) {
|
static inline void bw_env_follow_update_coeffs_audio(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
|
|
||||||
bw_one_pole_update_coeffs_audio(&coeffs->one_pole_coeffs);
|
bw_one_pole_update_coeffs_audio(&coeffs->one_pole_coeffs);
|
||||||
|
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float bw_env_follow_process1(const bw_env_follow_coeffs *BW_RESTRICT coeffs, bw_env_follow_state *BW_RESTRICT state, float x) {
|
static inline float bw_env_follow_process1(
|
||||||
|
const bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_env_follow_state * BW_RESTRICT state,
|
||||||
|
float x) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
|
BW_ASSERT(state != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_state_is_valid(coeffs, state));
|
||||||
|
BW_ASSERT(bw_is_finite(x));
|
||||||
|
|
||||||
x = bw_absf(x);
|
x = bw_absf(x);
|
||||||
return bw_one_pole_process1_asym(&coeffs->one_pole_coeffs, &state->one_pole_state, x);
|
const float y = bw_one_pole_process1_asym(&coeffs->one_pole_coeffs, &state->one_pole_state, x);
|
||||||
|
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_state_is_valid(coeffs, state));
|
||||||
|
BW_ASSERT(bw_is_finite(y));
|
||||||
|
|
||||||
|
return y;
|
||||||
}
|
}
|
||||||
|
|
||||||
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, size_t 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,
|
||||||
|
size_t n_samples) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
|
BW_ASSERT(state != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_state_is_valid(coeffs, state));
|
||||||
|
BW_ASSERT(x != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||||
|
|
||||||
bw_env_follow_update_coeffs_ctrl(coeffs);
|
bw_env_follow_update_coeffs_ctrl(coeffs);
|
||||||
if (y != NULL)
|
if (y != NULL)
|
||||||
for (size_t i = 0; i < n_samples; i++) {
|
for (size_t i = 0; i < n_samples; i++) {
|
||||||
@ -248,9 +483,26 @@ static inline void bw_env_follow_process(bw_env_follow_coeffs *BW_RESTRICT coeff
|
|||||||
bw_env_follow_update_coeffs_audio(coeffs);
|
bw_env_follow_update_coeffs_audio(coeffs);
|
||||||
bw_env_follow_process1(coeffs, state, x[i]);
|
bw_env_follow_process1(coeffs, state, x[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_state_is_valid(coeffs, state));
|
||||||
|
BW_ASSERT_DEEP(y != NULL ? bw_has_only_finite(y, n_samples) : 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_env_follow_process_multi(bw_env_follow_coeffs *BW_RESTRICT coeffs, bw_env_follow_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t n_channels, size_t n_samples) {
|
static inline void bw_env_follow_process_multi(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
bw_env_follow_state * BW_RESTRICT const * BW_RESTRICT state,
|
||||||
|
const float * const * x,
|
||||||
|
float * const * y,
|
||||||
|
size_t n_channels,
|
||||||
|
size_t n_samples) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
|
BW_ASSERT(state != NULL);
|
||||||
|
BW_ASSERT(x != NULL);
|
||||||
|
|
||||||
bw_env_follow_update_coeffs_ctrl(coeffs);
|
bw_env_follow_update_coeffs_ctrl(coeffs);
|
||||||
if (y != NULL)
|
if (y != NULL)
|
||||||
for (size_t i = 0; i < n_samples; i++) {
|
for (size_t i = 0; i < n_samples; i++) {
|
||||||
@ -267,20 +519,81 @@ static inline void bw_env_follow_process_multi(bw_env_follow_coeffs *BW_RESTRICT
|
|||||||
for (size_t j = 0; j < n_channels; j++)
|
for (size_t j = 0; j < n_channels; j++)
|
||||||
bw_env_follow_process1(coeffs, state[j], x[j][i]);
|
bw_env_follow_process1(coeffs, state[j], x[j][i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_init);
|
||||||
|
BW_ASSERT(!bw_is_nan(value));
|
||||||
|
BW_ASSERT(value >= 0.f);
|
||||||
|
|
||||||
bw_one_pole_set_tau_up(&coeffs->one_pole_coeffs, value);
|
bw_one_pole_set_tau_up(&coeffs->one_pole_coeffs, value);
|
||||||
|
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bw_env_follow_set_release_tau(bw_env_follow_coeffs *BW_RESTRICT coeffs, float value) {
|
static inline void bw_env_follow_set_release_tau(
|
||||||
|
bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
float value) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_init);
|
||||||
|
BW_ASSERT(!bw_is_nan(value));
|
||||||
|
BW_ASSERT(value >= 0.f);
|
||||||
|
|
||||||
bw_one_pole_set_tau_down(&coeffs->one_pole_coeffs, value);
|
bw_one_pole_set_tau_down(&coeffs->one_pole_coeffs, value);
|
||||||
|
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||||
|
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline float bw_env_follow_get_y_z1(const bw_env_follow_state *BW_RESTRICT state) {
|
static inline float bw_env_follow_get_y_z1(
|
||||||
|
const bw_env_follow_state * BW_RESTRICT state) {
|
||||||
|
BW_ASSERT(state != NULL);
|
||||||
|
BW_ASSERT_DEEP(bw_env_follow_state_is_valid(NULL, state));
|
||||||
|
|
||||||
return bw_one_pole_get_y_z1(&state->one_pole_state);
|
return bw_one_pole_get_y_z1(&state->one_pole_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline char bw_env_follow_coeffs_is_valid(
|
||||||
|
const bw_env_follow_coeffs * BW_RESTRICT coeffs) {
|
||||||
|
BW_ASSERT(coeffs != NULL);
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
if (coeffs->hash != bw_hash_sdbm("bw_env_follow_coeffs"))
|
||||||
|
return 0;
|
||||||
|
if (coeffs->state < bw_env_follow_coeffs_state_init || coeffs->state > bw_env_follow_coeffs_state_reset_coeffs)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return bw_one_pole_coeffs_is_valid(&coeffs->one_pole_coeffs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline char bw_env_follow_state_is_valid(
|
||||||
|
const bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||||
|
const bw_env_follow_state * BW_RESTRICT state) {
|
||||||
|
BW_ASSERT(state != NULL);
|
||||||
|
|
||||||
|
#ifdef BW_DEBUG_DEEP
|
||||||
|
if (state->hash != bw_hash_sdbm("bw_env_follow_state"))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
(void)coeffs;
|
||||||
|
|
||||||
|
return bw_one_pole_state_is_valid(&coeffs->one_pole_coeffs, &state->one_pole_state);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,21 +611,43 @@ class EnvFollow {
|
|||||||
public:
|
public:
|
||||||
EnvFollow();
|
EnvFollow();
|
||||||
|
|
||||||
void setSampleRate(float sampleRate);
|
void setSampleRate(
|
||||||
void reset();
|
float sampleRate);
|
||||||
|
|
||||||
|
void reset(
|
||||||
|
float x0 = 0.f,
|
||||||
|
float * BW_RESTRICT y0 = nullptr);
|
||||||
|
|
||||||
|
void reset(
|
||||||
|
float x0,
|
||||||
|
std::array<float, N_CHANNELS> * BW_RESTRICT y0);
|
||||||
|
|
||||||
|
void reset(
|
||||||
|
const float * x0,
|
||||||
|
float * y0 = nullptr);
|
||||||
|
|
||||||
|
void reset(
|
||||||
|
std::array<float, N_CHANNELS> x0,
|
||||||
|
std::array<float, N_CHANNELS> * BW_RESTRICT y0 = nullptr);
|
||||||
|
|
||||||
void process(
|
void process(
|
||||||
const float * const *x,
|
const float * const * x,
|
||||||
float * const *y,
|
float * const * y,
|
||||||
size_t nSamples);
|
size_t nSamples);
|
||||||
|
|
||||||
void process(
|
void process(
|
||||||
std::array<const float *, N_CHANNELS> x,
|
std::array<const float *, N_CHANNELS> x,
|
||||||
std::array<float *, N_CHANNELS> y,
|
std::array<float *, N_CHANNELS> y,
|
||||||
size_t nSamples);
|
size_t nSamples);
|
||||||
|
|
||||||
void setAttackTau(float value);
|
void setAttackTau(
|
||||||
void setReleaseTau(float value);
|
float value);
|
||||||
|
|
||||||
float getYZ1(size_t channel);
|
void setReleaseTau(
|
||||||
|
float value);
|
||||||
|
|
||||||
|
float getYZ1(
|
||||||
|
size_t channel);
|
||||||
/*! <<<...
|
/*! <<<...
|
||||||
* }
|
* }
|
||||||
* ```
|
* ```
|
||||||
@ -324,9 +659,9 @@ public:
|
|||||||
* change at any time in future versions. Please, do not use it directly. */
|
* change at any time in future versions. Please, do not use it directly. */
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bw_env_follow_coeffs coeffs;
|
bw_env_follow_coeffs coeffs;
|
||||||
bw_env_follow_state states[N_CHANNELS];
|
bw_env_follow_state states[N_CHANNELS];
|
||||||
bw_env_follow_state *BW_RESTRICT statesP[N_CHANNELS];
|
bw_env_follow_state * BW_RESTRICT statesP[N_CHANNELS];
|
||||||
};
|
};
|
||||||
|
|
||||||
template<size_t N_CHANNELS>
|
template<size_t N_CHANNELS>
|
||||||
@ -337,45 +672,77 @@ inline EnvFollow<N_CHANNELS>::EnvFollow() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<size_t N_CHANNELS>
|
template<size_t N_CHANNELS>
|
||||||
inline void EnvFollow<N_CHANNELS>::setSampleRate(float sampleRate) {
|
inline void EnvFollow<N_CHANNELS>::setSampleRate(
|
||||||
|
float sampleRate) {
|
||||||
bw_env_follow_set_sample_rate(&coeffs, sampleRate);
|
bw_env_follow_set_sample_rate(&coeffs, sampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t N_CHANNELS>
|
template<size_t N_CHANNELS>
|
||||||
inline void EnvFollow<N_CHANNELS>::reset() {
|
inline void EnvFollow<N_CHANNELS>::reset(
|
||||||
|
float x0,
|
||||||
|
float * BW_RESTRICT y0) {
|
||||||
bw_env_follow_reset_coeffs(&coeffs);
|
bw_env_follow_reset_coeffs(&coeffs);
|
||||||
for (size_t i = 0; i < N_CHANNELS; i++)
|
if (y0 != nullptr)
|
||||||
bw_env_follow_reset_state(&coeffs, states + i);
|
for (size_t i = 0; i < N_CHANNELS; i++)
|
||||||
|
y0[i] = bw_env_follow_reset_state(&coeffs, states + i, x0);
|
||||||
|
else
|
||||||
|
for (size_t i = 0; i < N_CHANNELS; i++)
|
||||||
|
bw_env_follow_reset_state(&coeffs, states + i, x0);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<size_t N_CHANNELS>
|
||||||
|
inline void EnvFollow<N_CHANNELS>::reset(
|
||||||
|
float x0,
|
||||||
|
std::array<float, N_CHANNELS> * BW_RESTRICT y0) {
|
||||||
|
reset(x0, y0 != nullptr ? y0->data() : nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<size_t N_CHANNELS>
|
||||||
|
inline void EnvFollow<N_CHANNELS>::reset(
|
||||||
|
const float * x0,
|
||||||
|
float * y0) {
|
||||||
|
bw_env_follow_reset_coeffs(&coeffs);
|
||||||
|
bw_env_follow_reset_state_multi(&coeffs, statesP, x0, y0, N_CHANNELS);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<size_t N_CHANNELS>
|
||||||
|
inline void EnvFollow<N_CHANNELS>::reset(
|
||||||
|
std::array<float, N_CHANNELS> x0,
|
||||||
|
std::array<float, N_CHANNELS> * BW_RESTRICT y0) {
|
||||||
|
reset(x0.data(), y0 != nullptr ? y0->data() : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t N_CHANNELS>
|
template<size_t N_CHANNELS>
|
||||||
inline void EnvFollow<N_CHANNELS>::process(
|
inline void EnvFollow<N_CHANNELS>::process(
|
||||||
const float * const *x,
|
const float * const * x,
|
||||||
float * const *y,
|
float * const * y,
|
||||||
size_t nSamples) {
|
size_t nSamples) {
|
||||||
bw_env_follow_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples);
|
bw_env_follow_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t N_CHANNELS>
|
template<size_t N_CHANNELS>
|
||||||
inline void EnvFollow<N_CHANNELS>::process(
|
inline void EnvFollow<N_CHANNELS>::process(
|
||||||
std::array<const float *, N_CHANNELS> x,
|
std::array<const float *, N_CHANNELS> x,
|
||||||
std::array<float *, N_CHANNELS> y,
|
std::array<float *, N_CHANNELS> y,
|
||||||
size_t nSamples) {
|
size_t nSamples) {
|
||||||
process(x.data(), y.data(), nSamples);
|
process(x.data(), y.data(), nSamples);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t N_CHANNELS>
|
template<size_t N_CHANNELS>
|
||||||
inline void EnvFollow<N_CHANNELS>::setAttackTau(float value) {
|
inline void EnvFollow<N_CHANNELS>::setAttackTau(
|
||||||
|
float value) {
|
||||||
bw_env_follow_set_attack_tau(&coeffs, value);
|
bw_env_follow_set_attack_tau(&coeffs, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t N_CHANNELS>
|
template<size_t N_CHANNELS>
|
||||||
inline void EnvFollow<N_CHANNELS>::setReleaseTau(float value) {
|
inline void EnvFollow<N_CHANNELS>::setReleaseTau(
|
||||||
|
float value) {
|
||||||
bw_env_follow_set_release_tau(&coeffs, value);
|
bw_env_follow_set_release_tau(&coeffs, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<size_t N_CHANNELS>
|
template<size_t N_CHANNELS>
|
||||||
inline float EnvFollow<N_CHANNELS>::getYZ1(size_t channel) {
|
inline float EnvFollow<N_CHANNELS>::getYZ1(
|
||||||
|
size_t channel) {
|
||||||
return bw_env_follow_get_y_z1(states + channel);
|
return bw_env_follow_get_y_z1(states + channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user