fix debug in bw_{one_pole,slew_lim,lp1,hp1} + force min out in bw_ppm + cosmetics

This commit is contained in:
Stefano D'Angelo 2023-08-30 17:54:09 +02:00
parent d15e7951f7
commit 537cd5d17b
7 changed files with 188 additions and 72 deletions

View File

@ -92,44 +92,56 @@ typedef struct bw_gain_coeffs bw_gain_coeffs;
*
* #### bw_gain_init()
* ```>>> */
static inline void bw_gain_init(bw_gain_coeffs *BW_RESTRICT coeffs);
static inline void bw_gain_init(
bw_gain_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Initializes input parameter values in `coeffs`.
*
* #### bw_gain_set_sample_rate()
* ```>>> */
static inline void bw_gain_set_sample_rate(bw_gain_coeffs *BW_RESTRICT coeffs, float sample_rate);
static inline void bw_gain_set_sample_rate(
bw_gain_coeffs * BW_RESTRICT coeffs,
float sample_rate);
/*! <<<```
* Sets the `sample_rate` (Hz) value in `coeffs`.
*
* #### bw_gain_reset_coeffs()
* ```>>> */
static inline void bw_gain_reset_coeffs(bw_gain_coeffs *BW_RESTRICT coeffs);
static inline void bw_gain_reset_coeffs(
bw_gain_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Resets coefficients in `coeffs` to assume their target values.
*
* #### bw_gain_update_coeffs_ctrl()
* ```>>> */
static inline void bw_gain_update_coeffs_ctrl(bw_gain_coeffs *BW_RESTRICT coeffs);
static inline void bw_gain_update_coeffs_ctrl(
bw_gain_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Triggers control-rate update of coefficients in `coeffs`.
*
* #### bw_gain_update_coeffs_audio()
* ```>>> */
static inline void bw_gain_update_coeffs_audio(bw_gain_coeffs *BW_RESTRICT coeffs);
static inline void bw_gain_update_coeffs_audio(
bw_gain_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Triggers audio-rate update of coefficients in `coeffs`.
*
* #### bw_gain_process1()
* ```>>> */
static inline float bw_gain_process1(const bw_gain_coeffs *BW_RESTRICT coeffs, float x);
static inline float bw_gain_process1(
const bw_gain_coeffs * BW_RESTRICT coeffs,
float x);
/*! <<<```
* Processes one input sample `x` using `coeffs` and returns the
* corresponding output sample.
*
* #### bw_gain_process()
* ```>>> */
static inline void bw_gain_process(bw_gain_coeffs *BW_RESTRICT coeffs, const float *x, float *y, size_t n_samples);
static inline void bw_gain_process(
bw_gain_coeffs * BW_RESTRICT coeffs,
const float * x,
float * y,
size_t n_samples);
/*! <<<```
* 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
@ -137,7 +149,12 @@ static inline void bw_gain_process(bw_gain_coeffs *BW_RESTRICT coeffs, const flo
*
* #### bw_gain_process_multi()
* ```>>> */
static inline void bw_gain_process_multi(bw_gain_coeffs *BW_RESTRICT coeffs, const float * const *x, float * const *y, size_t n_channels, size_t n_samples);
static inline void bw_gain_process_multi(
bw_gain_coeffs * BW_RESTRICT coeffs,
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
* fills the first `n_samples` of the `n_channels` output buffers `y`, while
@ -145,7 +162,9 @@ static inline void bw_gain_process_multi(bw_gain_coeffs *BW_RESTRICT coeffs, con
*
* #### bw_gain_set_gain_lin()
* ```>>> */
static inline void bw_gain_set_gain_lin(bw_gain_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_gain_set_gain_lin(
bw_gain_coeffs * BW_RESTRICT coeffs,
float value);
/*! <<<```
* Sets the gain parameter to the given `value` (linear gain) in `coeffs`.
*
@ -153,7 +172,9 @@ static inline void bw_gain_set_gain_lin(bw_gain_coeffs *BW_RESTRICT coeffs, floa
*
* #### bw_gain_set_gain_dB()
* ```>>> */
static inline void bw_gain_set_gain_dB(bw_gain_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_gain_set_gain_dB(
bw_gain_coeffs * BW_RESTRICT coeffs,
float value);
/*! <<<```
* Sets the gain parameter to the given `value` (dB) in `coeffs`.
*
@ -161,7 +182,9 @@ static inline void bw_gain_set_gain_dB(bw_gain_coeffs *BW_RESTRICT coeffs, float
*
* #### bw_gain_set_smooth_tau()
* ```>>> */
static inline void bw_gain_set_smooth_tau(bw_gain_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_gain_set_smooth_tau(
bw_gain_coeffs * BW_RESTRICT coeffs,
float value);
/*! <<<```
* Sets the smoothing time constant `value` (s) in `coeffs`.
*
@ -169,7 +192,8 @@ static inline void bw_gain_set_smooth_tau(bw_gain_coeffs *BW_RESTRICT coeffs, fl
*
* #### bw_gain_get_gain()
* ```>>> */
static inline float bw_gain_get_gain(const bw_gain_coeffs *BW_RESTRICT coeffs);
static inline float bw_gain_get_gain(
const bw_gain_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Returns the actual current gain coefficient (linear gain) in `coeffs`.
* }}} */

View File

@ -414,7 +414,7 @@ static inline void bw_hp1_process(
BW_ASSERT_DEEP(bw_hp1_state_is_valid(state));
BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
BW_ASSERT(x != NULL);
BW_ASSERT_DEEP(!bw_has_nan(x, n_samples));
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
BW_ASSERT(y != NULL);
bw_hp1_update_coeffs_ctrl(coeffs);
@ -427,7 +427,7 @@ static inline void bw_hp1_process(
BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
BW_ASSERT_DEEP(bw_hp1_state_is_valid(state));
BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
BW_ASSERT_DEEP(!bw_has_nan(y, n_samples));
BW_ASSERT_DEEP(bw_has_only_finite(y, n_samples));
}
static inline void bw_hp1_process_multi(
@ -461,7 +461,7 @@ static inline void bw_hp1_set_cutoff(
BW_ASSERT(coeffs != NULL);
BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_init);
BW_ASSERT(!bw_is_nan(value));
BW_ASSERT(bw_is_finite(value));
BW_ASSERT(value >= 1e-6f && value <= 1e6f);
bw_lp1_set_cutoff(&coeffs->lp1_coeffs, value);
@ -489,6 +489,7 @@ static inline void bw_hp1_set_prewarp_freq(
BW_ASSERT(coeffs != NULL);
BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_init);
BW_ASSERT(bw_is_finite(value));
BW_ASSERT(value >= 1e-6f && value <= 1e6f);
bw_lp1_set_prewarp_freq(&coeffs->lp1_coeffs, value);

View File

@ -468,7 +468,7 @@ static inline void bw_lp1_process(
BW_ASSERT_DEEP(bw_lp1_state_is_valid(state));
BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
BW_ASSERT(x != NULL);
BW_ASSERT_DEEP(!bw_has_nan(x, n_samples));
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
BW_ASSERT(y != NULL);
for (size_t i = 0; i < n_samples; i++) {
@ -480,7 +480,7 @@ static inline void bw_lp1_process(
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_reset_coeffs);
BW_ASSERT_DEEP(bw_lp1_state_is_valid(state));
BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
BW_ASSERT_DEEP(!bw_has_nan(y, n_samples));
BW_ASSERT_DEEP(bw_has_only_finite(y, n_samples));
}
static inline void bw_lp1_process_multi(
@ -513,7 +513,7 @@ static inline void bw_lp1_set_cutoff(
BW_ASSERT(coeffs != NULL);
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_init);
BW_ASSERT(!bw_is_nan(value));
BW_ASSERT(bw_is_finite(value));
BW_ASSERT(value >= 1e-6f && value <= 1e6f);
coeffs->cutoff = value;
@ -541,6 +541,7 @@ static inline void bw_lp1_set_prewarp_freq(
BW_ASSERT(coeffs != NULL);
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_init);
BW_ASSERT(bw_is_finite(value));
BW_ASSERT(value >= 1e-6f && value <= 1e6f);
coeffs->prewarp_freq = value;

View File

@ -90,51 +90,68 @@ typedef struct bw_mm1_state bw_mm1_state;
*
* #### bw_mm1_init()
* ```>>> */
static inline void bw_mm1_init(bw_mm1_coeffs *BW_RESTRICT coeffs);
static inline void bw_mm1_init(
bw_mm1_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Initializes input parameter values in `coeffs`.
*
* #### bw_mm1_set_sample_rate()
* ```>>> */
static inline void bw_mm1_set_sample_rate(bw_mm1_coeffs *BW_RESTRICT coeffs, float sample_rate);
static inline void bw_mm1_set_sample_rate(
bw_mm1_coeffs * BW_RESTRICT coeffs,
float sample_rate);
/*! <<<```
* Sets the `sample_rate` (Hz) value in `coeffs`.
*
* #### bw_mm1_reset_coeffs()
* ```>>> */
static inline void bw_mm1_reset_coeffs(bw_mm1_coeffs *BW_RESTRICT coeffs);
static inline void bw_mm1_reset_coeffs(
bw_mm1_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Resets coefficients in `coeffs` to assume their target values.
*
* #### bw_mm1_reset_state()
* ```>>> */
static inline void bw_mm1_reset_state(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, float x_0);
static inline void bw_mm1_reset_state(
const bw_mm1_coeffs * BW_RESTRICT coeffs,
bw_mm1_state * BW_RESTRICT state,
float x_0);
/*! <<<```
* Resets the given `state` to its initial values using the given `coeffs`
* and the quiescent/initial input value `x_0`.
*
* #### bw_mm1_update_coeffs_ctrl()
* ```>>> */
static inline void bw_mm1_update_coeffs_ctrl(bw_mm1_coeffs *BW_RESTRICT coeffs);
static inline void bw_mm1_update_coeffs_ctrl(
bw_mm1_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Triggers control-rate update of coefficients in `coeffs`.
*
* #### bw_mm1_update_coeffs_audio()
* ```>>> */
static inline void bw_mm1_update_coeffs_audio(bw_mm1_coeffs *BW_RESTRICT coeffs);
static inline void bw_mm1_update_coeffs_audio(
bw_mm1_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Triggers audio-rate update of coefficients in `coeffs`.
*
* #### bw_mm1_process1()
* ```>>> */
static inline float bw_mm1_process1(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, float x);
static inline float bw_mm1_process1(
const bw_mm1_coeffs * BW_RESTRICT coeffs,
bw_mm1_state * BW_RESTRICT state,
float x);
/*! <<<```
* Processes one input sample `x` using `coeffs`, while using and updating
* `state`. Returns the corresponding output sample.
*
* #### bw_mm1_process()
* ```>>> */
static inline void bw_mm1_process(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples);
static inline void bw_mm1_process(
bw_mm1_coeffs * BW_RESTRICT coeffs,
bw_mm1_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
* first `n_samples` of the output buffer `y`, while using and updating both
@ -142,7 +159,13 @@ static inline void bw_mm1_process(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_stat
*
* #### bw_mm1_process_multi()
* ```>>> */
static inline void bw_mm1_process_multi(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_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_mm1_process_multi(
bw_mm1_coeffs * BW_RESTRICT coeffs,
bw_mm1_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
* fills the first `n_samples` of the `n_channels` output buffers `y`, while
@ -151,15 +174,21 @@ static inline void bw_mm1_process_multi(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm
*
* #### bw_mm1_set_cutoff()
* ```>>> */
static inline void bw_mm1_set_cutoff(bw_mm1_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_mm1_set_cutoff(
bw_mm1_coeffs * BW_RESTRICT coeffs,
float value);
/*! <<<```
* Sets the cutoff frequency `value` (Hz) in `coeffs`.
*
* Valid range: [`1e-6f`, `1e6f`].
*
* Default value: `1e3f`.
*
* #### bw_mm1_set_prewarp_at_cutoff()
* ```>>> */
static inline void bw_mm1_set_prewarp_at_cutoff(bw_mm1_coeffs *BW_RESTRICT coeffs, char value);
static inline void bw_mm1_set_prewarp_at_cutoff(
bw_mm1_coeffs * BW_RESTRICT coeffs,
char value);
/*! <<<```
* Sets whether bilinear transform prewarping frequency should match the
* cutoff frequency (non-`0`) or not (`0`).
@ -168,28 +197,40 @@ static inline void bw_mm1_set_prewarp_at_cutoff(bw_mm1_coeffs *BW_RESTRICT coeff
*
* #### bw_mm1_set_prewarp_freq()
* ```>>> */
static inline void bw_mm1_set_prewarp_freq(bw_mm1_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_mm1_set_prewarp_freq(
bw_mm1_coeffs * BW_RESTRICT coeffs,
float value);
/*! <<<```
* Sets the prewarping frequency `value` (Hz) in `coeffs`.
*
* Only used when the prewarp\_at\_cutoff parameter is off.
*
* Valid range: [`1e-6f`, `1e6f`].
*
* Default value: `1e3f`.
*
* #### bw_mm1_set_coeff_x()
* ```>>> */
static inline void bw_mm1_set_coeff_x(bw_mm1_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_mm1_set_coeff_x(
bw_mm1_coeffs * BW_RESTRICT coeffs,
float value);
/*! <<<```
* Sets the input mode coefficient `value` in `coeffs`.
*
* `value` must be finite.
*
* Default value: `1.f`.
*
* #### bw_mm1_set_coeff_lp()
* ```>>> */
static inline void bw_mm1_set_coeff_lp(bw_mm1_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_mm1_set_coeff_lp(
bw_mm1_coeffs * BW_RESTRICT coeffs,
float value);
/*! <<<```
* Sets the lowpass mode coefficient `value` in `coeffs`.
*
* `value` must be finite.
*
* Default value: `0.f`.
* }}} */
@ -220,7 +261,8 @@ struct bw_mm1_state {
bw_lp1_state lp1_state;
};
static inline void bw_mm1_init(bw_mm1_coeffs *BW_RESTRICT coeffs) {
static inline void bw_mm1_init(
bw_mm1_coeffs * BW_RESTRICT coeffs) {
bw_lp1_init(&coeffs->lp1_coeffs);
bw_gain_init(&coeffs->gain_x_coeffs);
bw_gain_init(&coeffs->gain_lp_coeffs);
@ -230,42 +272,58 @@ static inline void bw_mm1_init(bw_mm1_coeffs *BW_RESTRICT coeffs) {
bw_gain_set_gain_lin(&coeffs->gain_lp_coeffs, 0.f);
}
static inline void bw_mm1_set_sample_rate(bw_mm1_coeffs *BW_RESTRICT coeffs, float sample_rate) {
static inline void bw_mm1_set_sample_rate(
bw_mm1_coeffs * BW_RESTRICT coeffs,
float sample_rate) {
bw_lp1_set_sample_rate(&coeffs->lp1_coeffs, sample_rate);
bw_gain_set_sample_rate(&coeffs->gain_x_coeffs, sample_rate);
bw_gain_set_sample_rate(&coeffs->gain_lp_coeffs, sample_rate);
}
static inline void bw_mm1_reset_coeffs(bw_mm1_coeffs *BW_RESTRICT coeffs) {
static inline void bw_mm1_reset_coeffs(
bw_mm1_coeffs * BW_RESTRICT coeffs) {
bw_lp1_reset_coeffs(&coeffs->lp1_coeffs);
bw_gain_reset_coeffs(&coeffs->gain_x_coeffs);
bw_gain_reset_coeffs(&coeffs->gain_lp_coeffs);
}
static inline void bw_mm1_reset_state(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, float x_0) {
static inline void bw_mm1_reset_state(
const bw_mm1_coeffs * BW_RESTRICT coeffs,
bw_mm1_state * BW_RESTRICT state,
float x_0) {
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
}
static inline void bw_mm1_update_coeffs_ctrl(bw_mm1_coeffs *BW_RESTRICT coeffs) {
static inline void bw_mm1_update_coeffs_ctrl(
bw_mm1_coeffs * BW_RESTRICT coeffs) {
bw_lp1_update_coeffs_ctrl(&coeffs->lp1_coeffs);
bw_gain_update_coeffs_ctrl(&coeffs->gain_x_coeffs);
bw_gain_update_coeffs_ctrl(&coeffs->gain_lp_coeffs);
}
static inline void bw_mm1_update_coeffs_audio(bw_mm1_coeffs *BW_RESTRICT coeffs) {
static inline void bw_mm1_update_coeffs_audio(
bw_mm1_coeffs * BW_RESTRICT coeffs) {
bw_lp1_update_coeffs_audio(&coeffs->lp1_coeffs);
bw_gain_update_coeffs_audio(&coeffs->gain_x_coeffs);
bw_gain_update_coeffs_audio(&coeffs->gain_lp_coeffs);
}
static inline float bw_mm1_process1(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, float x) {
static inline float bw_mm1_process1(
const bw_mm1_coeffs * BW_RESTRICT coeffs,
bw_mm1_state * BW_RESTRICT state,
float x) {
const float lp = bw_lp1_process1(&coeffs->lp1_coeffs, &state->lp1_state, x);
const float vx = bw_gain_process1(&coeffs->gain_x_coeffs, x);
const float vlp = bw_gain_process1(&coeffs->gain_lp_coeffs, lp);
return vx + vlp;
}
static inline void bw_mm1_process(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples) {
static inline void bw_mm1_process(
bw_mm1_coeffs * BW_RESTRICT coeffs,
bw_mm1_state * BW_RESTRICT state,
const float * x,
float * y,
size_t n_samples) {
bw_mm1_update_coeffs_ctrl(coeffs);
for (size_t i = 0; i < n_samples; i++) {
bw_mm1_update_coeffs_audio(coeffs);
@ -273,7 +331,13 @@ static inline void bw_mm1_process(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_stat
}
}
static inline void bw_mm1_process_multi(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_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_mm1_process_multi(
bw_mm1_coeffs * BW_RESTRICT coeffs,
bw_mm1_state * BW_RESTRICT const * BW_RESTRICT state,
const float * const * x,
float * const * y,
size_t n_channels,
size_t n_samples) {
bw_mm1_update_coeffs_ctrl(coeffs);
for (size_t i = 0; i < n_samples; i++) {
bw_mm1_update_coeffs_audio(coeffs);
@ -282,23 +346,33 @@ static inline void bw_mm1_process_multi(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm
}
}
static inline void bw_mm1_set_cutoff(bw_mm1_coeffs *BW_RESTRICT coeffs, float value) {
static inline void bw_mm1_set_cutoff(
bw_mm1_coeffs * BW_RESTRICT coeffs,
float value) {
bw_lp1_set_cutoff(&coeffs->lp1_coeffs, value);
}
static inline void bw_mm1_set_prewarp_at_cutoff(bw_mm1_coeffs *BW_RESTRICT coeffs, char value) {
static inline void bw_mm1_set_prewarp_at_cutoff(
bw_mm1_coeffs * BW_RESTRICT coeffs,
char value) {
bw_lp1_set_prewarp_at_cutoff(&coeffs->lp1_coeffs, value);
}
static inline void bw_mm1_set_prewarp_freq(bw_mm1_coeffs *BW_RESTRICT coeffs, float value) {
static inline void bw_mm1_set_prewarp_freq(
bw_mm1_coeffs * BW_RESTRICT coeffs,
float value) {
bw_lp1_set_prewarp_freq(&coeffs->lp1_coeffs, value);
}
static inline void bw_mm1_set_coeff_x(bw_mm1_coeffs *BW_RESTRICT coeffs, float value) {
static inline void bw_mm1_set_coeff_x(
bw_mm1_coeffs * BW_RESTRICT coeffs,
float value) {
bw_gain_set_gain_lin(&coeffs->gain_x_coeffs, value);
}
static inline void bw_mm1_set_coeff_lp(bw_mm1_coeffs *BW_RESTRICT coeffs, float value) {
static inline void bw_mm1_set_coeff_lp(
bw_mm1_coeffs * BW_RESTRICT coeffs,
float value) {
bw_gain_set_gain_lin(&coeffs->gain_lp_coeffs, value);
}
@ -319,22 +393,36 @@ class MM1 {
public:
MM1();
void setSampleRate(float sampleRate);
void reset(float x_0 = 0.f);
void setSampleRate(
float sampleRate);
void reset(
float x_0 = 0.f);
void process(
const float * const *x,
float * const *y,
size_t nSamples);
const float * const * x,
float * const * y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
size_t nSamples);
std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setCutoff(float value);
void setPrewarpAtCutoff(bool value);
void setPrewarpFreq(float value);
void setCoeffX(float value);
void setCoeffLp(float value);
void setCutoff(
float value);
void setPrewarpAtCutoff(
bool value);
void setPrewarpFreq(
float value);
void setCoeffX(
float value);
void setCoeffLp(
float value);
/*! <<<...
* }
* ```

View File

@ -759,7 +759,7 @@ static inline void bw_one_pole_process(
BW_ASSERT_DEEP(bw_one_pole_state_is_valid(state));
BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
BW_ASSERT(x != NULL);
BW_ASSERT_DEEP(!bw_has_nan(x, n_samples));
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
bw_one_pole_update_coeffs_ctrl(coeffs);
if (y != NULL) {
@ -826,7 +826,7 @@ static inline void bw_one_pole_process(
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);
BW_ASSERT_DEEP(y != NULL ? !bw_has_nan(y, n_samples) : 1);
BW_ASSERT_DEEP(y != NULL ? bw_has_only_finite(y, n_samples) : 1);
}
static inline void bw_one_pole_process_multi(

View File

@ -32,6 +32,7 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Enforced minimum output value `-600.f`.</li>
* <li><code>bw_ppm_process()</code> and
* <code>bw_ppm_process_multi()</code> now use <code>size_t</code>
* to count samples and channels.</li>
@ -128,7 +129,8 @@ static inline void bw_ppm_update_coeffs_audio(bw_ppm_coeffs *BW_RESTRICT coeffs)
static inline float bw_ppm_process1(const bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state *BW_RESTRICT state, float x);
/*! <<<```
* Processes one input sample `x` using `coeffs`, while using and updating
* `state`. Returns the corresponding output sample.
* `state`. Returns the corresponding output sample value in dBSF (minimum
* `-600.f`).
*
* #### bw_ppm_process()
* ```>>> */
@ -138,7 +140,7 @@ static inline void bw_ppm_process(bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_stat
* first `n_samples` of the output buffer `y`, while using and updating both
* `coeffs` and `state` (control and audio rate).
*
* Output sample values are in dBFS.
* Output sample values are in dBFS (minimum `-600.f`).
*
* `y` may be `NULL`.
*
@ -151,7 +153,7 @@ static inline void bw_ppm_process_multi(bw_ppm_coeffs *BW_RESTRICT coeffs, bw_pp
* using and updating both the common `coeffs` and each of the `n_channels`
* `state`s (control and audio rate).
*
* Output sample values are in dBFS.
* Output sample values are in dBFS (minimum `-600.f`).
*
* `y` or any element of `y` may be `NULL`.
*
@ -210,7 +212,7 @@ static inline void bw_ppm_reset_coeffs(bw_ppm_coeffs *BW_RESTRICT coeffs) {
static inline void bw_ppm_reset_state(const bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state *BW_RESTRICT state) {
bw_env_follow_reset_state(&coeffs->env_follow_coeffs, &state->env_follow_state);
state->y_z1 = -INFINITY;
state->y_z1 = -600.f; // minimum, see below
}
static inline void bw_ppm_update_coeffs_ctrl(bw_ppm_coeffs *BW_RESTRICT coeffs) {
@ -223,7 +225,7 @@ static inline void bw_ppm_update_coeffs_audio(bw_ppm_coeffs *BW_RESTRICT coeffs)
static inline float bw_ppm_process1(const bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state *BW_RESTRICT state, float x) {
const float yl = bw_env_follow_process1(&coeffs->env_follow_coeffs, &state->env_follow_state, x);
const float y = yl >= 1e-30f ? bw_lin2dBf(yl) : -INFINITY; // -600 dB is quiet enough
const float y = yl >= 1e-30f ? bw_lin2dBf(yl) : -600.f; // -600 dB is quiet enough
state->y_z1 = y;
return y;
}

View File

@ -555,7 +555,7 @@ static inline void bw_slew_lim_process(
BW_ASSERT_DEEP(bw_slew_lim_state_is_valid(state));
BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
BW_ASSERT(x != NULL);
BW_ASSERT_DEEP(!bw_has_nan(x, n_samples));
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
bw_slew_lim_update_coeffs_ctrl(coeffs);
if (y != NULL) {
@ -597,7 +597,7 @@ static inline void bw_slew_lim_process(
BW_ASSERT_DEEP(coeffs->state >= bw_slew_lim_coeffs_state_reset_coeffs);
BW_ASSERT_DEEP(bw_slew_lim_state_is_valid(state));
BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
BW_ASSERT_DEEP(y != NULL ? !bw_has_nan(y, n_samples) : 1);
BW_ASSERT_DEEP(y != NULL ? bw_has_only_finite(y, n_samples) : 1);
}
static inline void bw_slew_lim_process_multi(
@ -646,7 +646,7 @@ static inline void bw_slew_lim_process_multi(
BW_ASSERT_DEEP(bw_slew_lim_state_is_valid(state[j]));
BW_ASSERT_DEEP(coeffs->reset_id == state[j]->coeffs_reset_id);
BW_ASSERT(x[j] != NULL);
BW_ASSERT_DEEP(!bw_has_nan(x[j], n_samples));
BW_ASSERT_DEEP(bw_has_only_finite(x[j], n_samples));
if (y[j] != NULL)
for (size_t i = 0; i < n_samples; i++)
@ -654,8 +654,8 @@ static inline void bw_slew_lim_process_multi(
state[j]->y_z1 = x[j][n_samples - 1];
BW_ASSERT_DEEP(bw_slew_lim_state_is_valid(state[j]));
BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
BW_ASSERT_DEEP(y[j] != NULL ? !bw_has_nan(y[j], n_samples) : 1);
BW_ASSERT_DEEP(coeffs->reset_id == state[j]->coeffs_reset_id);
BW_ASSERT_DEEP(y[j] != NULL ? bw_has_only_finite(y[j], n_samples) : 1);
}
}
} else {
@ -679,12 +679,12 @@ static inline void bw_slew_lim_process_multi(
BW_ASSERT_DEEP(bw_slew_lim_state_is_valid(state[j]));
BW_ASSERT_DEEP(coeffs->reset_id == state[j]->coeffs_reset_id);
BW_ASSERT(x[j] != NULL);
BW_ASSERT_DEEP(!bw_has_nan(x[j], n_samples));
BW_ASSERT_DEEP(bw_has_only_finite(x[j], n_samples));
state[j]->y_z1 = x[j][n_samples - 1];
BW_ASSERT_DEEP(bw_slew_lim_state_is_valid(state[j]));
BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
BW_ASSERT_DEEP(coeffs->reset_id == state[j]->coeffs_reset_id);
}
}
}