diff --git a/examples/fx_hp1/vst3/Makefile b/examples/fx_hp1/vst3/Makefile
index 3244755..aab2bdd 100644
--- a/examples/fx_hp1/vst3/Makefile
+++ b/examples/fx_hp1/vst3/Makefile
@@ -4,3 +4,6 @@ NAME := bw_example_fx_hp1
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_hp1.c
include ${ROOT_DIR}/../../common/vst3/vst3.mk
+
+CXXFLAGS += -DRELEASE=1 -DNDEBUG -DBW_NO_DEBUG
+#CXXFLAGS += -DDEVELOPMENT=1 -DBW_DEBUG_DEEP
diff --git a/examples/fxpp_hp1/vst3/Makefile b/examples/fxpp_hp1/vst3/Makefile
index cc744da..d68eb95 100644
--- a/examples/fxpp_hp1/vst3/Makefile
+++ b/examples/fxpp_hp1/vst3/Makefile
@@ -4,3 +4,6 @@ NAME := bw_example_fxpp_hp1
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fxpp_hp1.cpp
include ${ROOT_DIR}/../../common/vst3/vst3.mk
+
+CXXFLAGS += -DRELEASE=1 -DNDEBUG -DBW_NO_DEBUG
+#CXXFLAGS += -DDEVELOPMENT=1 -DBW_DEBUG_DEEP
diff --git a/include/bw_hp1.h b/include/bw_hp1.h
index c97f68f..1da24f2 100644
--- a/include/bw_hp1.h
+++ b/include/bw_hp1.h
@@ -30,6 +30,7 @@
*
* - Version 1.0.0:
*
+ * - Added prewarp_at_cutoff and prewarp_freq parameters.
* bw_hp1_process()
and
* bw_hp1_process_multi()
now use size_t
* to count samples and channels.
@@ -39,6 +40,8 @@
* - Added overladed C++
process()
function taking
* C-style arrays as arguments.
* - Removed usage of reserved identifiers.
+ * - Clearly specificed parameter validity ranges.
+ * - Added debugging code.
*
*
* - Version 0.6.0:
@@ -91,51 +94,68 @@ typedef struct bw_hp1_state bw_hp1_state;
*
* #### bw_hp1_init()
* ```>>> */
-static inline void bw_hp1_init(bw_hp1_coeffs *BW_RESTRICT coeffs);
+static inline void bw_hp1_init(
+ bw_hp1_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Initializes input parameter values in `coeffs`.
*
* #### bw_hp1_set_sample_rate()
* ```>>> */
-static inline void bw_hp1_set_sample_rate(bw_hp1_coeffs *BW_RESTRICT coeffs, float sample_rate);
+static inline void bw_hp1_set_sample_rate(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ float sample_rate);
/*! <<<```
* Sets the `sample_rate` (Hz) value in `coeffs`.
*
* #### bw_hp1_reset_coeffs()
* ```>>> */
-static inline void bw_hp1_reset_coeffs(bw_hp1_coeffs *BW_RESTRICT coeffs);
+static inline void bw_hp1_reset_coeffs(
+ bw_hp1_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Resets coefficients in `coeffs` to assume their target values.
*
* #### bw_hp1_reset_state()
* ```>>> */
-static inline void bw_hp1_reset_state(const bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_state *BW_RESTRICT state, float x_0);
+static inline void bw_hp1_reset_state(
+ const bw_hp1_coeffs * BW_RESTRICT coeffs,
+ bw_hp1_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_hp1_update_coeffs_ctrl()
* ```>>> */
-static inline void bw_hp1_update_coeffs_ctrl(bw_hp1_coeffs *BW_RESTRICT coeffs);
+static inline void bw_hp1_update_coeffs_ctrl(
+ bw_hp1_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Triggers control-rate update of coefficients in `coeffs`.
*
* #### bw_hp1_update_coeffs_audio()
* ```>>> */
-static inline void bw_hp1_update_coeffs_audio(bw_hp1_coeffs *BW_RESTRICT coeffs);
+static inline void bw_hp1_update_coeffs_audio(
+ bw_hp1_coeffs * BW_RESTRICT coeffs);
/*! <<<```
* Triggers audio-rate update of coefficients in `coeffs`.
*
* #### bw_hp1_process1()
* ```>>> */
-static inline float bw_hp1_process1(const bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_state *BW_RESTRICT state, float x);
+static inline float bw_hp1_process1(
+ const bw_hp1_coeffs * BW_RESTRICT coeffs,
+ bw_hp1_state * BW_RESTRICT state,
+ float x);
/*! <<<```
* Processes one input sample `x` using `coeffs`, while using and updating
* `state`. Returns the corresponding output sample.
*
* #### bw_hp1_process()
* ```>>> */
-static inline void bw_hp1_process(bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples);
+static inline void bw_hp1_process(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ bw_hp1_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
@@ -143,7 +163,13 @@ static inline void bw_hp1_process(bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_stat
*
* #### bw_hp1_process_multi()
* ```>>> */
-static inline void bw_hp1_process_multi(bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_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_hp1_process_multi(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ bw_hp1_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
@@ -152,11 +178,65 @@ static inline void bw_hp1_process_multi(bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp
*
* #### bw_hp1_set_cutoff()
* ```>>> */
-static inline void bw_hp1_set_cutoff(bw_hp1_coeffs *BW_RESTRICT coeffs, float value);
+static inline void bw_hp1_set_cutoff(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ float value);
/*! <<<```
* Sets the cutoff frequency `value` (Hz) in `coeffs`.
*
+ * Valid range: [`1e-6f`, `1e6f`].
+ *
* Default value: `1e3f`.
+ *
+ * #### bw_hp1_set_prewarp_at_cutoff()
+ * ```>>> */
+static inline void bw_hp1_set_prewarp_at_cutoff(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ char value);
+/*! <<<```
+ * Sets whether bilinear transform prewarping frequency should match the
+ * cutoff frequency (non-`0`) or not (`0`).
+ *
+ * Default value: non-`0` (on).
+ *
+ * #### bw_hp1_set_prewarp_freq()
+ * ```>>> */
+static inline void bw_hp1_set_prewarp_freq(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ float value);
+/*! <<<```
+ * Sets the prewarping frequency `value` (Hz) in `coeffs`.
+ *
+ * Only used when the prewarp\_at\_cutoff parameter is off and however
+ * internally limited to avoid instability.
+ *
+ * Valid range: [`1e-6f`, `1e6f`].
+ *
+ * Default value: `1e3f`.
+ *
+ * #### bw_hp1_coeffs_is_valid()
+ * ```>>> */
+static inline char bw_hp1_coeffs_is_valid(
+ const bw_hp1_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_hp1_coeffs`.
+ *
+ * #### bw_hp1_state_is_valid()
+ * ```>>> */
+static inline char bw_hp1_state_is_valid(
+ const bw_hp1_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.
+ *
+ * `state` must at least point to a readable memory block of size greater
+ * than or equal to that of `bw_hp1_state`.
* }}} */
#ifdef __cplusplus
@@ -174,63 +254,273 @@ static inline void bw_hp1_set_cutoff(bw_hp1_coeffs *BW_RESTRICT coeffs, float va
extern "C" {
#endif
+#ifdef BW_DEBUG_DEEP
+enum bw_hp1_coeffs_state {
+ bw_hp1_coeffs_state_invalid,
+ bw_hp1_coeffs_state_init,
+ bw_hp1_coeffs_state_set_sample_rate,
+ bw_hp1_coeffs_state_reset_coeffs
+};
+#endif
+
struct bw_hp1_coeffs {
+#ifdef BW_DEBUG_DEEP
+ uint32_t hash;
+ enum bw_hp1_coeffs_state state;
+ uint32_t reset_id;
+#endif
+
// Sub-components
bw_lp1_coeffs lp1_coeffs;
};
struct bw_hp1_state {
+#ifdef BW_DEBUG_DEEP
+ uint32_t hash;
+ uint32_t coeffs_reset_id;
+#endif
+
bw_lp1_state lp1_state;
};
-static inline void bw_hp1_init(bw_hp1_coeffs *BW_RESTRICT coeffs) {
+static inline void bw_hp1_init(
+ bw_hp1_coeffs * BW_RESTRICT coeffs) {
+ BW_ASSERT(coeffs != NULL);
+
bw_lp1_init(&coeffs->lp1_coeffs);
+
+#ifdef BW_DEBUG_DEEP
+ coeffs->hash = bw_hash_sdbm("bw_hp1_coeffs");
+ coeffs->state = bw_hp1_coeffs_state_init;
+ coeffs->reset_id = coeffs->hash + 1;
+#endif
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state == bw_hp1_coeffs_state_init);
}
-static inline void bw_hp1_set_sample_rate(bw_hp1_coeffs *BW_RESTRICT coeffs, float sample_rate) {
+static inline void bw_hp1_set_sample_rate(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ float sample_rate) {
+ 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(sample_rate) && sample_rate > 0.f);
+
bw_lp1_set_sample_rate(&coeffs->lp1_coeffs, sample_rate);
+
+#ifdef BW_DEBUG_DEEP
+ coeffs->state = bw_hp1_coeffs_state_set_sample_rate;
+#endif
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state == bw_hp1_coeffs_state_set_sample_rate);
}
-static inline void bw_hp1_reset_coeffs(bw_hp1_coeffs *BW_RESTRICT coeffs) {
+static inline void bw_hp1_reset_coeffs(
+ bw_hp1_coeffs * BW_RESTRICT coeffs) {
+ BW_ASSERT(coeffs != NULL);
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_set_sample_rate);
+
bw_lp1_reset_coeffs(&coeffs->lp1_coeffs);
+
+#ifdef BW_DEBUG_DEEP
+ coeffs->state = bw_hp1_coeffs_state_reset_coeffs;
+ coeffs->reset_id++;
+#endif
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state == bw_hp1_coeffs_state_reset_coeffs);
}
-static inline void bw_hp1_reset_state(const bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_state *BW_RESTRICT state, float x_0) {
+static inline void bw_hp1_reset_state(
+ const bw_hp1_coeffs * BW_RESTRICT coeffs,
+ bw_hp1_state * BW_RESTRICT state,
+ float x_0) {
+ BW_ASSERT(coeffs != NULL);
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
+ BW_ASSERT(state != NULL);
+ BW_ASSERT(bw_is_finite(x_0));
+
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
+
+#ifdef BW_DEBUG_DEEP
+ state->hash = bw_hash_sdbm("bw_hp1_state");
+ state->coeffs_reset_id = coeffs->reset_id;
+#endif
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
+ BW_ASSERT_DEEP(bw_hp1_state_is_valid(state));
+ BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
}
-static inline void bw_hp1_update_coeffs_ctrl(bw_hp1_coeffs *BW_RESTRICT coeffs) {
+static inline void bw_hp1_update_coeffs_ctrl(
+ bw_hp1_coeffs * BW_RESTRICT coeffs) {
+ BW_ASSERT(coeffs != NULL);
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
+
bw_lp1_update_coeffs_ctrl(&coeffs->lp1_coeffs);
+
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
}
-static inline void bw_hp1_update_coeffs_audio(bw_hp1_coeffs *BW_RESTRICT coeffs) {
+static inline void bw_hp1_update_coeffs_audio(
+ bw_hp1_coeffs * BW_RESTRICT coeffs) {
+ BW_ASSERT(coeffs != NULL);
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
+
bw_lp1_update_coeffs_audio(&coeffs->lp1_coeffs);
+
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
}
-static inline float bw_hp1_process1(const bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_state *BW_RESTRICT state, float x) {
+static inline float bw_hp1_process1(
+ const bw_hp1_coeffs * BW_RESTRICT coeffs,
+ bw_hp1_state * BW_RESTRICT state,
+ float x) {
+ BW_ASSERT(coeffs != NULL);
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
+ BW_ASSERT(state != NULL);
+ BW_ASSERT_DEEP(bw_hp1_state_is_valid(state));
+ BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
+ BW_ASSERT(bw_is_finite(x));
+
const float lp = bw_lp1_process1(&coeffs->lp1_coeffs, &state->lp1_state, x);
- return x - lp;
+ const float y = x - lp;
+
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
+ BW_ASSERT_DEEP(bw_hp1_state_is_valid(state));
+ BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
+ BW_ASSERT(bw_is_finite(y));
+
+ return y;
}
-static inline void bw_hp1_process(bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples) {
+static inline void bw_hp1_process(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ bw_hp1_state * BW_RESTRICT state,
+ const float * x,
+ float * y,
+ size_t n_samples) {
+ BW_ASSERT(coeffs != NULL);
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
+ BW_ASSERT(state != NULL);
+ 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(y != NULL);
+
bw_hp1_update_coeffs_ctrl(coeffs);
for (size_t i = 0; i < n_samples; i++) {
bw_hp1_update_coeffs_audio(coeffs);
y[i] = bw_hp1_process1(coeffs, state, x[i]);
}
+
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
+ BW_ASSERT_DEEP(bw_hp1_state_is_valid(state));
+ BW_ASSERT_DEEP(coeffs->reset_id == state->coeffs_reset_id);
+ BW_ASSERT_DEEP(!bw_has_nan(y, n_samples));
}
-static inline void bw_hp1_process_multi(bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_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_hp1_process_multi(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ bw_hp1_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_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
+ BW_ASSERT(state != NULL);
+ BW_ASSERT(x != NULL);
+ BW_ASSERT(y != NULL);
+
bw_hp1_update_coeffs_ctrl(coeffs);
for (size_t i = 0; i < n_samples; i++) {
bw_hp1_update_coeffs_audio(coeffs);
for (size_t j = 0; j < n_channels; j++)
y[j][i] = bw_hp1_process1(coeffs, state[j], x[j][i]);
}
+
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
}
-static inline void bw_hp1_set_cutoff(bw_hp1_coeffs *BW_RESTRICT coeffs, float value) {
+static inline void bw_hp1_set_cutoff(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ float value) {
+ 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(value >= 1e-6f && value <= 1e6f);
+
bw_lp1_set_cutoff(&coeffs->lp1_coeffs, value);
+
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_init);
+}
+
+static inline void bw_hp1_set_prewarp_at_cutoff(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ char value) {
+ BW_ASSERT(coeffs != NULL);
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_init);
+
+ bw_lp1_set_prewarp_at_cutoff(&coeffs->lp1_coeffs, value);
+
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_init);
+}
+
+static inline void bw_hp1_set_prewarp_freq(
+ bw_hp1_coeffs * BW_RESTRICT coeffs,
+ float value) {
+ 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(value >= 1e-6f && value <= 1e6f);
+
+ bw_lp1_set_prewarp_freq(&coeffs->lp1_coeffs, value);
+
+ BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
+ BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_init);
+}
+
+static inline char bw_hp1_coeffs_is_valid(
+ const bw_hp1_coeffs * BW_RESTRICT coeffs) {
+ BW_ASSERT(coeffs != NULL);
+
+#ifdef BW_DEBUG_DEEP
+ if (coeffs->hash != bw_hash_sdbm("bw_hp1_coeffs"))
+ return 0;
+ if (coeffs->state < bw_hp1_coeffs_state_init || coeffs->state > bw_hp1_coeffs_state_reset_coeffs)
+ return 0;
+#endif
+
+ return bw_lp1_coeffs_is_valid(&coeffs->lp1_coeffs);
+}
+
+static inline char bw_hp1_state_is_valid(
+ const bw_hp1_state * BW_RESTRICT state) {
+ BW_ASSERT(state != NULL);
+
+#ifdef BW_DEBUG_DEEP
+ if (state->hash != bw_hash_sdbm("bw_hp1_state"))
+ return 0;
+#endif
+
+ return bw_lp1_state_is_valid(&state->lp1_state);
}
#ifdef __cplusplus
@@ -250,18 +540,30 @@ class HP1 {
public:
HP1();
- void setSampleRate(float sampleRate);
- void reset(float x_0 = 0.f);
+ void setSampleRate(
+ float sampleRate);
+
+ void reset(
+ float x0 = 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 x,
- std::array y,
- size_t nSamples);
+ std::array y,
+ size_t nSamples);
- void setCutoff(float value);
+ void setCutoff(
+ float value);
+
+ void setPrewarpAtCutoff(
+ bool value);
+
+ void setPrewarpFreq(
+ float value);
/*! <<<...
* }
* ```
@@ -286,38 +588,53 @@ inline HP1::HP1() {
}
template
-inline void HP1::setSampleRate(float sampleRate) {
+inline void HP1::setSampleRate(
+ float sampleRate) {
bw_hp1_set_sample_rate(&coeffs, sampleRate);
}
template
-inline void HP1::reset(float x_0) {
+inline void HP1::reset(
+ float x0) {
bw_hp1_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
- bw_hp1_reset_state(&coeffs, states + i, x_0);
+ bw_hp1_reset_state(&coeffs, states + i, x0);
}
template
inline void HP1::process(
- const float * const *x,
- float * const *y,
- size_t nSamples) {
+ const float * const * x,
+ float * const * y,
+ size_t nSamples) {
bw_hp1_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples);
}
template
inline void HP1::process(
std::array x,
- std::array y,
- size_t nSamples) {
+ std::array y,
+ size_t nSamples) {
process(x.data(), y.data(), nSamples);
}
template
-inline void HP1::setCutoff(float value) {
+inline void HP1::setCutoff(
+ float value) {
bw_hp1_set_cutoff(&coeffs, value);
}
+template
+inline void HP1::setPrewarpAtCutoff(
+ bool value) {
+ bw_hp1_set_prewarp_at_cutoff(&coeffs, value);
+}
+
+template
+inline void HP1::setPrewarpFreq(
+ float value) {
+ bw_hp1_set_prewarp_freq(&coeffs, value);
+}
+
}
#endif
diff --git a/include/bw_lp1.h b/include/bw_lp1.h
index a5ebc3a..1fedfc8 100644
--- a/include/bw_lp1.h
+++ b/include/bw_lp1.h
@@ -42,6 +42,7 @@
* C-style arrays as arguments.
* - Removed usage of reserved identifiers.
* - Fixed theoretical bug in
bw_lp1_init()
.
+ * - Clearly specificed parameter validity ranges.
* - Added debugging code.
*
*
@@ -549,7 +550,7 @@ static inline void bw_lp1_set_prewarp_freq(
}
static inline char bw_lp1_coeffs_is_valid(
- const bw_lp1_coeffs * BW_RESTRICT coeffs) {
+ const bw_lp1_coeffs * BW_RESTRICT coeffs) {
BW_ASSERT(coeffs != NULL);
#ifdef BW_DEBUG_DEEP
@@ -588,7 +589,7 @@ static inline char bw_lp1_coeffs_is_valid(
}
static inline char bw_lp1_state_is_valid(
- const bw_lp1_state * BW_RESTRICT state) {
+ const bw_lp1_state * BW_RESTRICT state) {
BW_ASSERT(state != NULL);
#ifdef BW_DEBUG_DEEP
@@ -596,8 +597,7 @@ static inline char bw_lp1_state_is_valid(
return 0;
#endif
- return bw_is_finite(state->y_z1);
- return bw_is_finite(state->X_z1);
+ return bw_is_finite(state->y_z1) && bw_is_finite(state->X_z1);
}
#ifdef __cplusplus
diff --git a/include/bw_one_pole.h b/include/bw_one_pole.h
index dcfd2b7..efce7e2 100644
--- a/include/bw_one_pole.h
+++ b/include/bw_one_pole.h
@@ -42,6 +42,7 @@
* Removed usage of reserved identifiers.
* Now using backward Euler rather than impulse invariant
* method.
+ * Clearly specificed parameter validity ranges.
* Added more debugging code.
* Added pragmas to silence bogus GCC uninitialized variable
* warnings.
diff --git a/include/bw_slew_lim.h b/include/bw_slew_lim.h
index 2548174..bde6cb4 100644
--- a/include/bw_slew_lim.h
+++ b/include/bw_slew_lim.h
@@ -43,6 +43,7 @@
* bw_slew_lim_init()
.
* Fixed documentation of
* bw_slew_lim_update_coeffs_audio()
.
+ * Clearly specificed parameter validity ranges.
* Added debugging code.
*
*
@@ -747,7 +748,7 @@ static inline float bw_slew_lim_get_y_z1(
}
static inline char bw_slew_lim_coeffs_is_valid(
- const bw_slew_lim_coeffs * BW_RESTRICT coeffs) {
+ const bw_slew_lim_coeffs * BW_RESTRICT coeffs) {
BW_ASSERT(coeffs != NULL);
#ifdef BW_DEBUG_DEEP
@@ -780,7 +781,7 @@ static inline char bw_slew_lim_coeffs_is_valid(
}
static inline char bw_slew_lim_state_is_valid(
- const bw_slew_lim_state * BW_RESTRICT state) {
+ const bw_slew_lim_state * BW_RESTRICT state) {
BW_ASSERT(state != NULL);
#ifdef BW_DEBUG_DEEP