introduced BW_NULL
This commit is contained in:
parent
4ee0c0d0cc
commit
2ba9b443c1
@ -11,7 +11,7 @@ You can find information and documentation [on the official web page](https://ww
|
||||
|
||||
## Legal
|
||||
|
||||
Copyright (C) 2021-2023 Orastron Srl unipersonale.
|
||||
Copyright (C) 2021-2024 Orastron Srl unipersonale.
|
||||
|
||||
Authors: Stefano D'Angelo, Paolo Marrone.
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
We wish to thank and give credit to:
|
||||
- the adopters of this software, of which at the moment we can only publicly mention our friends at [Elk Audio](https://www.elk.audio/);
|
||||
- the adopters of this software, of which at the moment we can publicly mention, in alphabetical order:
|
||||
- [Elk Audio](https://www.elk.audio/);
|
||||
- [Faselunare](http://faselunare.com/);
|
||||
- Kevin Molcard for finding compilation warnings that needed fixing in Brickworks 1.0.0;
|
||||
- users participating to [this thread on the KVR Audio forum](https://www.kvraudio.com/forum/viewtopic.php?f=33&t=589519) for providing useful feedback;
|
||||
- [Mads Kjeldgaard](https://madskjeldgaard.dk/) for publishing [instructions to build for the Daisy Seed and uploading the firmware](https://madskjeldgaard.dk/posts/daisy-setup/);
|
||||
- [Hereket](https://hereket.github.io/) for providing instructions on [how to build an Android app without Android Studio or Gradle](https://hereket.github.io/posts/android_from_command_line/);
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_lp1 bw_math bw_one_pole }}}
|
||||
* description {{{
|
||||
* First-order allpass filter (90° shift at cutoff, approaching 180° shift
|
||||
@ -28,6 +28,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added <code>bw_ap1_reset_state_multi()</code> and updated C++
|
||||
@ -149,7 +154,7 @@ static inline void bw_ap1_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_ap1_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -263,8 +268,8 @@ static inline char bw_ap1_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_ap1_state`.
|
||||
@ -317,7 +322,7 @@ struct bw_ap1_state {
|
||||
|
||||
static inline void bw_ap1_init(
|
||||
bw_ap1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_lp1_init(&coeffs->lp1_coeffs);
|
||||
|
||||
@ -333,7 +338,7 @@ static inline void bw_ap1_init(
|
||||
static inline void bw_ap1_set_sample_rate(
|
||||
bw_ap1_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -349,7 +354,7 @@ static inline void bw_ap1_set_sample_rate(
|
||||
|
||||
static inline void bw_ap1_reset_coeffs(
|
||||
bw_ap1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -367,10 +372,10 @@ static inline float bw_ap1_reset_state(
|
||||
const bw_ap1_coeffs * BW_RESTRICT coeffs,
|
||||
bw_ap1_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
const float lp = bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
|
||||
@ -394,18 +399,18 @@ static inline void bw_ap1_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_ap1_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -414,12 +419,12 @@ static inline void bw_ap1_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_ap1_update_coeffs_ctrl(
|
||||
bw_ap1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -431,7 +436,7 @@ static inline void bw_ap1_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_ap1_update_coeffs_audio(
|
||||
bw_ap1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -445,10 +450,10 @@ static inline float bw_ap1_process1(
|
||||
const bw_ap1_coeffs * BW_RESTRICT coeffs,
|
||||
bw_ap1_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -469,14 +474,14 @@ static inline void bw_ap1_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_ap1_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -497,17 +502,17 @@ static inline void bw_ap1_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -528,7 +533,7 @@ static inline void bw_ap1_process_multi(
|
||||
static inline void bw_ap1_set_cutoff(
|
||||
bw_ap1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -543,7 +548,7 @@ static inline void bw_ap1_set_cutoff(
|
||||
static inline void bw_ap1_set_prewarp_at_cutoff(
|
||||
bw_ap1_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_init);
|
||||
|
||||
@ -556,7 +561,7 @@ static inline void bw_ap1_set_prewarp_at_cutoff(
|
||||
static inline void bw_ap1_set_prewarp_freq(
|
||||
bw_ap1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -570,7 +575,7 @@ static inline void bw_ap1_set_prewarp_freq(
|
||||
|
||||
static inline char bw_ap1_coeffs_is_valid(
|
||||
const bw_ap1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_ap1_coeffs"))
|
||||
@ -585,17 +590,17 @@ static inline char bw_ap1_coeffs_is_valid(
|
||||
static inline char bw_ap1_state_is_valid(
|
||||
const bw_ap1_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_ap1_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_ap1_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_lp1_state_is_valid(coeffs ? &coeffs->lp1_coeffs : NULL, &state->lp1_state);
|
||||
return bw_lp1_state_is_valid(coeffs ? &coeffs->lp1_coeffs : BW_NULL, &state->lp1_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_math bw_one_pole bw_svf }}}
|
||||
* description {{{
|
||||
* Second-order allpass filter (180° shift at cutoff, approaching 360° shift
|
||||
@ -28,6 +28,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added <code>bw_ap2_reset_state_multi()</code> and updated C++
|
||||
@ -146,7 +151,7 @@ static inline void bw_ap2_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_ap2_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -272,8 +277,8 @@ static inline char bw_ap2_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_ap2_state`.
|
||||
@ -326,7 +331,7 @@ struct bw_ap2_state {
|
||||
|
||||
static inline void bw_ap2_init(
|
||||
bw_ap2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_svf_init(&coeffs->svf_coeffs);
|
||||
|
||||
@ -342,7 +347,7 @@ static inline void bw_ap2_init(
|
||||
static inline void bw_ap2_set_sample_rate(
|
||||
bw_ap2_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -358,7 +363,7 @@ static inline void bw_ap2_set_sample_rate(
|
||||
|
||||
static inline void bw_ap2_reset_coeffs(
|
||||
bw_ap2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -376,10 +381,10 @@ static inline float bw_ap2_reset_state(
|
||||
const bw_ap2_coeffs * BW_RESTRICT coeffs,
|
||||
bw_ap2_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
float lp, bp, hp;
|
||||
@ -405,18 +410,18 @@ static inline void bw_ap2_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_ap2_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -425,12 +430,12 @@ static inline void bw_ap2_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_ap2_update_coeffs_ctrl(
|
||||
bw_ap2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -442,7 +447,7 @@ static inline void bw_ap2_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_ap2_update_coeffs_audio(
|
||||
bw_ap2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -456,10 +461,10 @@ static inline float bw_ap2_process1(
|
||||
const bw_ap2_coeffs * BW_RESTRICT coeffs,
|
||||
bw_ap2_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -482,14 +487,14 @@ static inline void bw_ap2_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_ap2_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -510,17 +515,17 @@ static inline void bw_ap2_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -541,7 +546,7 @@ static inline void bw_ap2_process_multi(
|
||||
static inline void bw_ap2_set_cutoff(
|
||||
bw_ap2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -556,7 +561,7 @@ static inline void bw_ap2_set_cutoff(
|
||||
static inline void bw_ap2_set_Q(
|
||||
bw_ap2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -571,7 +576,7 @@ static inline void bw_ap2_set_Q(
|
||||
static inline void bw_ap2_set_prewarp_at_cutoff(
|
||||
bw_ap2_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_init);
|
||||
|
||||
@ -584,7 +589,7 @@ static inline void bw_ap2_set_prewarp_at_cutoff(
|
||||
static inline void bw_ap2_set_prewarp_freq(
|
||||
bw_ap2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ap2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ap2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -598,7 +603,7 @@ static inline void bw_ap2_set_prewarp_freq(
|
||||
|
||||
static inline char bw_ap2_coeffs_is_valid(
|
||||
const bw_ap2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_ap2_coeffs"))
|
||||
@ -613,17 +618,17 @@ static inline char bw_ap2_coeffs_is_valid(
|
||||
static inline char bw_ap2_state_is_valid(
|
||||
const bw_ap2_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_ap2_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_ap2_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_svf_state_is_valid(coeffs ? &coeffs->svf_coeffs : NULL, &state->svf_state);
|
||||
return bw_svf_state_is_valid(coeffs ? &coeffs->svf_coeffs : BW_NULL, &state->svf_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,13 +20,18 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_gain bw_math bw_one_pole }}}
|
||||
* description {{{
|
||||
* Stereo balance.
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li><code>bw_balance_process()</code> and
|
||||
@ -229,7 +234,7 @@ struct bw_balance_coeffs {
|
||||
|
||||
static inline void bw_balance_init(
|
||||
bw_balance_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_gain_init(&coeffs->l_coeffs);
|
||||
bw_gain_init(&coeffs->r_coeffs);
|
||||
@ -246,7 +251,7 @@ static inline void bw_balance_init(
|
||||
static inline void bw_balance_set_sample_rate(
|
||||
bw_balance_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_balance_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_balance_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -273,7 +278,7 @@ static inline void bw_balance_do_update_coeffs(
|
||||
|
||||
static inline void bw_balance_reset_coeffs(
|
||||
bw_balance_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_balance_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_balance_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -290,7 +295,7 @@ static inline void bw_balance_reset_coeffs(
|
||||
|
||||
static inline void bw_balance_update_coeffs_ctrl(
|
||||
bw_balance_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_balance_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_balance_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -304,7 +309,7 @@ static inline void bw_balance_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_balance_update_coeffs_audio(
|
||||
bw_balance_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_balance_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_balance_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -321,7 +326,7 @@ static inline void bw_balance_process1(
|
||||
float x_r,
|
||||
float * BW_RESTRICT y_l,
|
||||
float * BW_RESTRICT y_r) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_balance_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_balance_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(bw_is_finite(x_l));
|
||||
@ -344,15 +349,15 @@ static inline void bw_balance_process(
|
||||
float * y_l,
|
||||
float * y_r,
|
||||
size_t n_samples){
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_balance_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_balance_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(x_l != NULL);
|
||||
BW_ASSERT(x_l != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x_l, n_samples));
|
||||
BW_ASSERT(x_r != NULL);
|
||||
BW_ASSERT(x_r != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x_r, n_samples));
|
||||
BW_ASSERT(y_l != NULL);
|
||||
BW_ASSERT(y_r != NULL);
|
||||
BW_ASSERT(y_l != BW_NULL);
|
||||
BW_ASSERT(y_r != BW_NULL);
|
||||
BW_ASSERT(y_l != y_r);
|
||||
|
||||
bw_balance_update_coeffs_ctrl(coeffs);
|
||||
@ -375,13 +380,13 @@ static inline void bw_balance_process_multi(
|
||||
float * const * y_r,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_balance_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_balance_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(x_l != NULL);
|
||||
BW_ASSERT(x_r != NULL);
|
||||
BW_ASSERT(y_l != NULL);
|
||||
BW_ASSERT(y_r != NULL);
|
||||
BW_ASSERT(x_l != BW_NULL);
|
||||
BW_ASSERT(x_r != BW_NULL);
|
||||
BW_ASSERT(y_l != BW_NULL);
|
||||
BW_ASSERT(y_r != BW_NULL);
|
||||
BW_ASSERT(y_l != y_r);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
@ -408,7 +413,7 @@ static inline void bw_balance_process_multi(
|
||||
static inline void bw_balance_set_balance(
|
||||
bw_balance_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_balance_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_balance_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -422,7 +427,7 @@ static inline void bw_balance_set_balance(
|
||||
|
||||
static inline char bw_balance_coeffs_is_valid(
|
||||
const bw_balance_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_balance_coeffs"))
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_math }}}
|
||||
* description {{{
|
||||
* Bit depth reducer.
|
||||
@ -31,6 +31,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added <code>bw_bd_reduce_set_sample_rate()</code>.</li>
|
||||
@ -225,7 +230,7 @@ struct bw_bd_reduce_coeffs {
|
||||
|
||||
static inline void bw_bd_reduce_init(
|
||||
bw_bd_reduce_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
coeffs->bit_depth = 16;
|
||||
|
||||
@ -240,7 +245,7 @@ static inline void bw_bd_reduce_init(
|
||||
static inline void bw_bd_reduce_set_sample_rate(
|
||||
bw_bd_reduce_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -267,7 +272,7 @@ static inline void bw_bd_reduce_do_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_bd_reduce_reset_coeffs(
|
||||
bw_bd_reduce_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -283,7 +288,7 @@ static inline void bw_bd_reduce_reset_coeffs(
|
||||
|
||||
static inline void bw_bd_reduce_update_coeffs_ctrl(
|
||||
bw_bd_reduce_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -295,7 +300,7 @@ static inline void bw_bd_reduce_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_bd_reduce_update_coeffs_audio(
|
||||
bw_bd_reduce_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -305,7 +310,7 @@ static inline void bw_bd_reduce_update_coeffs_audio(
|
||||
static inline float bw_bd_reduce_process1(
|
||||
const bw_bd_reduce_coeffs * BW_RESTRICT coeffs,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
@ -324,12 +329,12 @@ static inline void bw_bd_reduce_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_bd_reduce_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++)
|
||||
@ -346,11 +351,11 @@ static inline void bw_bd_reduce_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -369,7 +374,7 @@ static inline void bw_bd_reduce_process_multi(
|
||||
static inline void bw_bd_reduce_set_bit_depth(
|
||||
bw_bd_reduce_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_bd_reduce_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_bd_reduce_coeffs_state_init);
|
||||
BW_ASSERT(value >= 1 && value <= 64);
|
||||
@ -382,7 +387,7 @@ static inline void bw_bd_reduce_set_bit_depth(
|
||||
|
||||
static inline char bw_bd_reduce_coeffs_is_valid(
|
||||
const bw_bd_reduce_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_bd_reduce_coeffs"))
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,13 +20,18 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ utility }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common }}}
|
||||
* description {{{
|
||||
* Common operations on buffers.
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>size_t</code> instead of
|
||||
@ -240,7 +245,7 @@ static inline void bw_buf_fill(
|
||||
float * BW_RESTRICT dest,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(!bw_is_nan(k));
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
|
||||
for (size_t i = 0; i < n_elems; i++)
|
||||
dest[i] = k;
|
||||
@ -252,9 +257,9 @@ static inline void bw_buf_neg(
|
||||
const float * src,
|
||||
float * dest,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(src != NULL);
|
||||
BW_ASSERT(src != BW_NULL);
|
||||
BW_ASSERT_DEEP(!bw_has_nan(src, n_elems));
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
|
||||
for (size_t i = 0; i < n_elems; i++)
|
||||
dest[i] = -src[i];
|
||||
@ -267,10 +272,10 @@ static inline void bw_buf_add(
|
||||
float k,
|
||||
float * dest,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(src != NULL);
|
||||
BW_ASSERT(src != BW_NULL);
|
||||
BW_ASSERT_DEEP(!bw_has_nan(src, n_elems));
|
||||
BW_ASSERT(!bw_is_nan(k));
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
|
||||
for (size_t i = 0; i < n_elems; i++)
|
||||
dest[i] = k + src[i];
|
||||
@ -283,10 +288,10 @@ static inline void bw_buf_scale(
|
||||
float k,
|
||||
float * dest,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(src != NULL);
|
||||
BW_ASSERT(src != BW_NULL);
|
||||
BW_ASSERT_DEEP(!bw_has_nan(src, n_elems));
|
||||
BW_ASSERT(!bw_is_nan(k));
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
|
||||
for (size_t i = 0; i < n_elems; i++)
|
||||
dest[i] = k * src[i];
|
||||
@ -299,11 +304,11 @@ static inline void bw_buf_mix(
|
||||
const float * src2,
|
||||
float * dest,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(src1 != NULL);
|
||||
BW_ASSERT(src1 != BW_NULL);
|
||||
BW_ASSERT_DEEP(!bw_has_nan(src1, n_elems));
|
||||
BW_ASSERT(src2 != NULL);
|
||||
BW_ASSERT(src2 != BW_NULL);
|
||||
BW_ASSERT_DEEP(!bw_has_nan(src2, n_elems));
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
|
||||
for (size_t i = 0; i < n_elems; i++)
|
||||
dest[i] = src1[i] + src2[i];
|
||||
@ -316,11 +321,11 @@ static inline void bw_buf_mul(
|
||||
const float * src2,
|
||||
float * dest,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(src1 != NULL);
|
||||
BW_ASSERT(src1 != BW_NULL);
|
||||
BW_ASSERT_DEEP(!bw_has_nan(src1, n_elems));
|
||||
BW_ASSERT(src2 != NULL);
|
||||
BW_ASSERT(src2 != BW_NULL);
|
||||
BW_ASSERT_DEEP(!bw_has_nan(src2, n_elems));
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
|
||||
for (size_t i = 0; i < n_elems; i++)
|
||||
dest[i] = src1[i] * src2[i];
|
||||
@ -334,7 +339,7 @@ static inline void bw_buf_fill_multi(
|
||||
size_t n_channels,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(!bw_is_nan(k));
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -350,8 +355,8 @@ static inline void bw_buf_neg_multi(
|
||||
float * const * dest,
|
||||
size_t n_channels,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(src != NULL);
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(src != BW_NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -368,9 +373,9 @@ static inline void bw_buf_add_multi(
|
||||
float * const * dest,
|
||||
size_t n_channels,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(src != NULL);
|
||||
BW_ASSERT(src != BW_NULL);
|
||||
BW_ASSERT(!bw_is_nan(k));
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -387,9 +392,9 @@ static inline void bw_buf_scale_multi(
|
||||
float * const * dest,
|
||||
size_t n_channels,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(src != NULL);
|
||||
BW_ASSERT(src != BW_NULL);
|
||||
BW_ASSERT(!bw_is_nan(k));
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -406,9 +411,9 @@ static inline void bw_buf_mix_multi(
|
||||
float * const * dest,
|
||||
size_t n_channels,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(src1 != NULL);
|
||||
BW_ASSERT(src2 != NULL);
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(src1 != BW_NULL);
|
||||
BW_ASSERT(src2 != BW_NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -425,9 +430,9 @@ static inline void bw_buf_mul_multi(
|
||||
float * const * dest,
|
||||
size_t n_channels,
|
||||
size_t n_elems) {
|
||||
BW_ASSERT(src1 != NULL);
|
||||
BW_ASSERT(src2 != NULL);
|
||||
BW_ASSERT(dest != NULL);
|
||||
BW_ASSERT(src1 != BW_NULL);
|
||||
BW_ASSERT(src2 != BW_NULL);
|
||||
BW_ASSERT(dest != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -109,7 +109,7 @@ static inline void bw_cab_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_cab_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -222,7 +222,7 @@ static inline char bw_cab_state_is_valid(
|
||||
* 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`
|
||||
* If `coeffs` is not `BW_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
|
||||
@ -285,7 +285,7 @@ struct bw_cab_state {
|
||||
|
||||
static inline void bw_cab_init(
|
||||
bw_cab_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_svf_init(&coeffs->lp_coeffs);
|
||||
bw_svf_init(&coeffs->hp_coeffs);
|
||||
@ -313,7 +313,7 @@ static inline void bw_cab_init(
|
||||
static inline void bw_cab_set_sample_rate(
|
||||
bw_cab_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -334,7 +334,7 @@ static inline void bw_cab_set_sample_rate(
|
||||
|
||||
static inline void bw_cab_reset_coeffs(
|
||||
bw_cab_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -357,10 +357,10 @@ static inline float bw_cab_reset_state(
|
||||
const bw_cab_coeffs * BW_RESTRICT coeffs,
|
||||
bw_cab_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
float v_lp, v_hp, v_bp;
|
||||
@ -392,18 +392,18 @@ static inline void bw_cab_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_cab_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -412,12 +412,12 @@ static inline void bw_cab_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_cab_update_coeffs_ctrl(
|
||||
bw_cab_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -434,7 +434,7 @@ static inline void bw_cab_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_cab_update_coeffs_audio(
|
||||
bw_cab_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -453,10 +453,10 @@ static inline float bw_cab_process1(
|
||||
const bw_cab_coeffs * BW_RESTRICT coeffs,
|
||||
bw_cab_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -485,14 +485,14 @@ static inline void bw_cab_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_cab_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -513,17 +513,17 @@ static inline void bw_cab_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -544,7 +544,7 @@ static inline void bw_cab_process_multi(
|
||||
static inline void bw_cab_set_cutoff_low(
|
||||
bw_cab_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -561,7 +561,7 @@ static inline void bw_cab_set_cutoff_low(
|
||||
static inline void bw_cab_set_cutoff_high(
|
||||
bw_cab_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -578,7 +578,7 @@ static inline void bw_cab_set_cutoff_high(
|
||||
static inline void bw_cab_set_tone(
|
||||
bw_cab_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_cab_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_cab_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -593,7 +593,7 @@ static inline void bw_cab_set_tone(
|
||||
|
||||
static inline char bw_cab_coeffs_is_valid(
|
||||
const bw_cab_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_cab_coeffs"))
|
||||
@ -613,20 +613,20 @@ static inline char bw_cab_coeffs_is_valid(
|
||||
static inline char bw_cab_state_is_valid(
|
||||
const bw_cab_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_cab_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_cab_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_svf_state_is_valid(coeffs ? &coeffs->lp_coeffs : NULL, &state->lp_state)
|
||||
&& bw_svf_state_is_valid(coeffs ? &coeffs->hp_coeffs : NULL, &state->hp_state)
|
||||
&& bw_svf_state_is_valid(coeffs ? &coeffs->bpl_coeffs : NULL, &state->bpl_state)
|
||||
&& bw_svf_state_is_valid(coeffs ? &coeffs->bph_coeffs : NULL, &state->bph_state);
|
||||
return bw_svf_state_is_valid(coeffs ? &coeffs->lp_coeffs : BW_NULL, &state->lp_state)
|
||||
&& bw_svf_state_is_valid(coeffs ? &coeffs->hp_coeffs : BW_NULL, &state->hp_state)
|
||||
&& bw_svf_state_is_valid(coeffs ? &coeffs->bpl_coeffs : BW_NULL, &state->bpl_state)
|
||||
&& bw_svf_state_is_valid(coeffs ? &coeffs->bph_coeffs : BW_NULL, &state->bph_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{
|
||||
* bw_buf bw_comb bw_common bw_delay bw_gain bw_math bw_one_pole bw_osc_sin
|
||||
* bw_phase_gen
|
||||
@ -36,6 +36,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added initial value argument in
|
||||
@ -178,7 +183,7 @@ static inline void bw_chorus_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* If parameter `coeff_fb` has value `-1.f` or `1.f`, then `x_0` must only
|
||||
* contain `0.f`.
|
||||
@ -335,8 +340,8 @@ static inline char bw_chorus_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_chorus_state`.
|
||||
@ -407,7 +412,7 @@ struct bw_chorus_state {
|
||||
static inline void bw_chorus_init(
|
||||
bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
float max_delay) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(max_delay));
|
||||
BW_ASSERT(max_delay >= 0.f);
|
||||
|
||||
@ -428,7 +433,7 @@ static inline void bw_chorus_init(
|
||||
static inline void bw_chorus_set_sample_rate(
|
||||
bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -445,7 +450,7 @@ static inline void bw_chorus_set_sample_rate(
|
||||
|
||||
static inline size_t bw_chorus_mem_req(
|
||||
const bw_chorus_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -456,11 +461,11 @@ static inline void bw_chorus_mem_set(
|
||||
const bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
bw_chorus_state * BW_RESTRICT state,
|
||||
void * BW_RESTRICT mem) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_set_sample_rate);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(mem != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(mem != BW_NULL);
|
||||
|
||||
bw_comb_mem_set(&coeffs->comb_coeffs, &state->comb_state, mem);
|
||||
|
||||
@ -476,7 +481,7 @@ static inline void bw_chorus_mem_set(
|
||||
|
||||
static inline void bw_chorus_reset_coeffs(
|
||||
bw_chorus_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -499,10 +504,10 @@ static inline float bw_chorus_reset_state(
|
||||
const bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
bw_chorus_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(state->state >= bw_chorus_state_state_mem_set);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
@ -528,18 +533,18 @@ static inline void bw_chorus_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_chorus_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -548,12 +553,12 @@ static inline void bw_chorus_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_chorus_update_coeffs_ctrl(
|
||||
bw_chorus_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -566,7 +571,7 @@ static inline void bw_chorus_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_chorus_update_coeffs_audio(
|
||||
bw_chorus_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -586,10 +591,10 @@ static inline float bw_chorus_process1(
|
||||
const bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
bw_chorus_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(state->state >= bw_chorus_state_state_reset_state);
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
@ -611,15 +616,15 @@ static inline void bw_chorus_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(state->state >= bw_chorus_state_state_reset_state);
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_chorus_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -641,17 +646,17 @@ static inline void bw_chorus_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -672,7 +677,7 @@ static inline void bw_chorus_process_multi(
|
||||
static inline void bw_chorus_set_rate(
|
||||
bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -686,7 +691,7 @@ static inline void bw_chorus_set_rate(
|
||||
static inline void bw_chorus_set_delay(
|
||||
bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -701,7 +706,7 @@ static inline void bw_chorus_set_delay(
|
||||
static inline void bw_chorus_set_amount(
|
||||
bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -712,7 +717,7 @@ static inline void bw_chorus_set_amount(
|
||||
static inline void bw_chorus_set_coeff_x(
|
||||
bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -726,7 +731,7 @@ static inline void bw_chorus_set_coeff_x(
|
||||
static inline void bw_chorus_set_coeff_mod(
|
||||
bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -740,7 +745,7 @@ static inline void bw_chorus_set_coeff_mod(
|
||||
static inline void bw_chorus_set_coeff_fb(
|
||||
bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_chorus_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_chorus_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -754,7 +759,7 @@ static inline void bw_chorus_set_coeff_fb(
|
||||
|
||||
static inline char bw_chorus_coeffs_is_valid(
|
||||
const bw_chorus_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_chorus_coeffs"))
|
||||
@ -782,7 +787,7 @@ static inline char bw_chorus_coeffs_is_valid(
|
||||
static inline char bw_chorus_state_is_valid(
|
||||
const bw_chorus_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_chorus_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_chorus_state"))
|
||||
@ -790,11 +795,11 @@ static inline char bw_chorus_state_is_valid(
|
||||
if (state->state < bw_chorus_state_state_mem_set || state->state > bw_chorus_state_state_reset_state)
|
||||
return 0;
|
||||
|
||||
if (state->state >= bw_chorus_state_state_reset_state && coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (state->state >= bw_chorus_state_state_reset_state && coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_comb_state_is_valid(coeffs ? &coeffs->comb_coeffs : NULL, &state->comb_state);
|
||||
return bw_comb_state_is_valid(coeffs ? &coeffs->comb_coeffs : BW_NULL, &state->comb_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_math bw_one_pole }}}
|
||||
* description {{{
|
||||
* Antialiased hard clipper with parametric bias and gain
|
||||
@ -45,6 +45,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Changed default value for gain compensation to off.</li>
|
||||
@ -153,7 +158,7 @@ static inline void bw_clip_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_clip_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -275,8 +280,8 @@ static inline char bw_clip_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_clip_state`.
|
||||
@ -342,7 +347,7 @@ struct bw_clip_state {
|
||||
|
||||
static inline void bw_clip_init(
|
||||
bw_clip_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_one_pole_init(&coeffs->smooth_coeffs);
|
||||
bw_one_pole_set_tau(&coeffs->smooth_coeffs, 0.005f);
|
||||
@ -363,7 +368,7 @@ static inline void bw_clip_init(
|
||||
static inline void bw_clip_set_sample_rate(
|
||||
bw_clip_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -395,7 +400,7 @@ static inline void bw_clip_do_update_coeffs(
|
||||
|
||||
static inline void bw_clip_reset_coeffs(
|
||||
bw_clip_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -415,10 +420,10 @@ static inline float bw_clip_reset_state(
|
||||
const bw_clip_coeffs * BW_RESTRICT coeffs,
|
||||
bw_clip_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
const float x = bw_one_pole_get_y_z1(&coeffs->smooth_gain_state) * x_0 + bw_one_pole_get_y_z1(&coeffs->smooth_bias_state);
|
||||
@ -447,18 +452,18 @@ static inline void bw_clip_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_clip_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -467,12 +472,12 @@ static inline void bw_clip_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_clip_update_coeffs_ctrl(
|
||||
bw_clip_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -481,7 +486,7 @@ static inline void bw_clip_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_clip_update_coeffs_audio(
|
||||
bw_clip_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -495,10 +500,10 @@ static inline float bw_clip_process1(
|
||||
const bw_clip_coeffs * BW_RESTRICT coeffs,
|
||||
bw_clip_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -523,10 +528,10 @@ static inline float bw_clip_process1_comp(
|
||||
const bw_clip_coeffs * BW_RESTRICT coeffs,
|
||||
bw_clip_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -546,14 +551,14 @@ static inline void bw_clip_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
if (coeffs->gain_compensation)
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -579,17 +584,17 @@ static inline void bw_clip_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -616,7 +621,7 @@ static inline void bw_clip_process_multi(
|
||||
static inline void bw_clip_set_bias(
|
||||
bw_clip_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -631,7 +636,7 @@ static inline void bw_clip_set_bias(
|
||||
static inline void bw_clip_set_gain(
|
||||
bw_clip_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -646,7 +651,7 @@ static inline void bw_clip_set_gain(
|
||||
static inline void bw_clip_set_gain_compensation(
|
||||
bw_clip_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_clip_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_clip_coeffs_state_init);
|
||||
|
||||
@ -658,7 +663,7 @@ static inline void bw_clip_set_gain_compensation(
|
||||
|
||||
static inline char bw_clip_coeffs_is_valid(
|
||||
const bw_clip_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_clip_coeffs"))
|
||||
@ -695,13 +700,13 @@ static inline char bw_clip_coeffs_is_valid(
|
||||
static inline char bw_clip_state_is_valid(
|
||||
const bw_clip_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_clip_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_clip_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{
|
||||
* bw_buf bw_common bw_delay bw_gain bw_math bw_one_pole
|
||||
* }}}
|
||||
@ -37,6 +37,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added initial value argument in
|
||||
@ -179,7 +184,7 @@ static inline void bw_comb_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* If parameter `coeff_fb` has value `-1.f` or `1.f`, then `x_0` must only
|
||||
* contain `0.f`.
|
||||
@ -322,8 +327,8 @@ static inline char bw_comb_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_comb_state`.
|
||||
@ -407,7 +412,7 @@ struct bw_comb_state {
|
||||
static inline void bw_comb_init(
|
||||
bw_comb_coeffs * BW_RESTRICT coeffs,
|
||||
float max_delay) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(max_delay));
|
||||
BW_ASSERT(max_delay >= 0.f);
|
||||
|
||||
@ -435,7 +440,7 @@ static inline void bw_comb_init(
|
||||
static inline void bw_comb_set_sample_rate(
|
||||
bw_comb_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -457,7 +462,7 @@ static inline void bw_comb_set_sample_rate(
|
||||
|
||||
static inline size_t bw_comb_mem_req(
|
||||
const bw_comb_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -468,11 +473,11 @@ static inline void bw_comb_mem_set(
|
||||
const bw_comb_coeffs * BW_RESTRICT coeffs,
|
||||
bw_comb_state * BW_RESTRICT state,
|
||||
void * BW_RESTRICT mem) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_set_sample_rate);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(mem != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(mem != BW_NULL);
|
||||
|
||||
bw_delay_mem_set(&coeffs->delay_coeffs, &state->delay_state, mem);
|
||||
|
||||
@ -519,7 +524,7 @@ static inline void bw_comb_do_update_coeffs(
|
||||
|
||||
static inline void bw_comb_reset_coeffs(
|
||||
bw_comb_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -543,10 +548,10 @@ static inline float bw_comb_reset_state(
|
||||
const bw_comb_coeffs * BW_RESTRICT coeffs,
|
||||
bw_comb_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(state->state >= bw_comb_state_state_mem_set);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
@ -582,18 +587,18 @@ static inline void bw_comb_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_comb_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -602,12 +607,12 @@ static inline void bw_comb_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_comb_update_coeffs_ctrl(
|
||||
bw_comb_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -621,7 +626,7 @@ static inline void bw_comb_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_comb_update_coeffs_audio(
|
||||
bw_comb_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -638,10 +643,10 @@ static inline float bw_comb_process1(
|
||||
const bw_comb_coeffs * BW_RESTRICT coeffs,
|
||||
bw_comb_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(state->state >= bw_comb_state_state_reset_state);
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
@ -667,15 +672,15 @@ static inline void bw_comb_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(state->state >= bw_comb_state_state_reset_state);
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_comb_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -697,17 +702,17 @@ static inline void bw_comb_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -728,7 +733,7 @@ static inline void bw_comb_process_multi(
|
||||
static inline void bw_comb_set_delay_ff(
|
||||
bw_comb_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -742,7 +747,7 @@ static inline void bw_comb_set_delay_ff(
|
||||
static inline void bw_comb_set_delay_fb(
|
||||
bw_comb_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -756,7 +761,7 @@ static inline void bw_comb_set_delay_fb(
|
||||
static inline void bw_comb_set_coeff_blend(
|
||||
bw_comb_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -770,7 +775,7 @@ static inline void bw_comb_set_coeff_blend(
|
||||
static inline void bw_comb_set_coeff_ff(
|
||||
bw_comb_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -784,7 +789,7 @@ static inline void bw_comb_set_coeff_ff(
|
||||
static inline void bw_comb_set_coeff_fb(
|
||||
bw_comb_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comb_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comb_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -798,7 +803,7 @@ static inline void bw_comb_set_coeff_fb(
|
||||
|
||||
static inline char bw_comb_coeffs_is_valid(
|
||||
const bw_comb_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_comb_coeffs"))
|
||||
@ -849,7 +854,7 @@ static inline char bw_comb_coeffs_is_valid(
|
||||
static inline char bw_comb_state_is_valid(
|
||||
const bw_comb_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_comb_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_comb_state"))
|
||||
@ -857,11 +862,11 @@ static inline char bw_comb_state_is_valid(
|
||||
if (state->state < bw_comb_state_state_mem_set || state->state > bw_comb_state_state_reset_state)
|
||||
return 0;
|
||||
|
||||
if (state->state >= bw_comb_state_state_reset_state && coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (state->state >= bw_comb_state_state_reset_state && coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_delay_state_is_valid(coeffs ? &coeffs->delay_coeffs : NULL, &state->delay_state);
|
||||
return bw_delay_state_is_valid(coeffs ? &coeffs->delay_coeffs : BW_NULL, &state->delay_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,13 +20,19 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ foundation }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.1.0 }}}
|
||||
* description {{{
|
||||
* A common header to make sure that a bunch of basic definitions are
|
||||
* available and consistent for all Brickworks modules.
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.1.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added <code>BW_NULL</code> and relaxed <code>NULL</code> definition
|
||||
* requirement in C++.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Removed <code>BW_SIZE_T</code> and went for <code>size_t</code>
|
||||
@ -91,7 +97,7 @@
|
||||
*
|
||||
* Brickworks requires definitions of:
|
||||
*
|
||||
* * `NULL` and `size_t`, normally supplied by `stddef.h`;
|
||||
* * `NULL` (C only) and `size_t`, normally supplied by `stddef.h`;
|
||||
* * `(u)int{8,16,32,64}_t`, `INT{8,16,32,64}_{MIN,MAX}`, and
|
||||
* `UINT{8,16,32,64}_MAX`, normally supplied by `stdint.h`;
|
||||
* * `INFINITY`, normally supplied by `math.h`.
|
||||
@ -106,13 +112,20 @@
|
||||
* * if `BW_NO_STDLIB` or `BW_NO_MATH_H` is defined, then `math.h` is not
|
||||
* `#include`d.
|
||||
*
|
||||
* A `BW_NULL` macro is defined whose value is either `NULL` (C) or `nullptr`
|
||||
* (C++).
|
||||
* >>> */
|
||||
#if !defined(BW_NO_STDLIB) && !defined(BW_NO_STDDEF_H)
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
# error NULL not defined
|
||||
#ifdef __cplusplus
|
||||
# define BW_NULL nullptr
|
||||
#else
|
||||
# ifndef NULL
|
||||
# error NULL not defined
|
||||
# endif
|
||||
# define BW_NULL NULL
|
||||
#endif
|
||||
|
||||
#if !defined(BW_NO_STDLIB) && !defined(BW_NO_STDINT_H)
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{
|
||||
* bw_common bw_env_follow bw_gain bw_math bw_one_pole
|
||||
* }}}
|
||||
@ -29,6 +29,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added initial input values to
|
||||
@ -150,7 +155,7 @@ static inline void bw_comp_reset_state_multi(
|
||||
* 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`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_comp_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -319,8 +324,8 @@ static inline char bw_comp_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_comp_state`.
|
||||
@ -388,7 +393,7 @@ struct bw_comp_state {
|
||||
|
||||
static inline void bw_comp_init(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_env_follow_init(&coeffs->env_follow_coeffs);
|
||||
bw_gain_init(&coeffs->gain_coeffs);
|
||||
@ -409,7 +414,7 @@ static inline void bw_comp_init(
|
||||
static inline void bw_comp_set_sample_rate(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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);
|
||||
@ -437,7 +442,7 @@ static inline void bw_comp_do_update_coeffs_audio(
|
||||
|
||||
static inline void bw_comp_reset_coeffs(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -460,10 +465,10 @@ static inline float bw_comp_reset_state(
|
||||
bw_comp_state * BW_RESTRICT state,
|
||||
float x_0,
|
||||
float x_sc_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
BW_ASSERT(bw_is_finite(x_sc_0));
|
||||
|
||||
@ -490,19 +495,19 @@ static inline void bw_comp_reset_state_multi(
|
||||
const float * x_sc_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_sc_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
BW_ASSERT(x_sc_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_comp_reset_state(coeffs, state[i], x_0[i], x_sc_0[i]);
|
||||
else
|
||||
@ -512,12 +517,12 @@ static inline void bw_comp_reset_state_multi(
|
||||
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(y_0, n_channels));
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_comp_update_coeffs_ctrl(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -530,7 +535,7 @@ static inline void bw_comp_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_comp_update_coeffs_audio(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -549,10 +554,10 @@ static inline float bw_comp_process1(
|
||||
bw_comp_state * BW_RESTRICT state,
|
||||
float x,
|
||||
float x_sc) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comp_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
BW_ASSERT(bw_is_finite(x_sc));
|
||||
@ -576,16 +581,16 @@ static inline void bw_comp_process(
|
||||
const float * x_sc,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comp_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(x_sc != NULL);
|
||||
BW_ASSERT(x_sc != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x_sc, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_comp_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -607,18 +612,18 @@ static inline void bw_comp_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x_sc != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(x_sc != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -639,7 +644,7 @@ static inline void bw_comp_process_multi(
|
||||
static inline void bw_comp_set_thresh_lin(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(value));
|
||||
@ -654,7 +659,7 @@ static inline void bw_comp_set_thresh_lin(
|
||||
static inline void bw_comp_set_thresh_dBFS(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(value));
|
||||
@ -669,7 +674,7 @@ static inline void bw_comp_set_thresh_dBFS(
|
||||
static inline void bw_comp_set_ratio(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(value));
|
||||
@ -684,7 +689,7 @@ static inline void bw_comp_set_ratio(
|
||||
static inline void bw_comp_set_attack_tau(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(value));
|
||||
@ -699,7 +704,7 @@ static inline void bw_comp_set_attack_tau(
|
||||
static inline void bw_comp_set_release_tau(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(value));
|
||||
@ -714,7 +719,7 @@ static inline void bw_comp_set_release_tau(
|
||||
static inline void bw_comp_set_gain_lin(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(value));
|
||||
@ -728,7 +733,7 @@ static inline void bw_comp_set_gain_lin(
|
||||
static inline void bw_comp_set_gain_dB(
|
||||
bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_comp_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_comp_coeffs_state_init);
|
||||
BW_ASSERT(!bw_is_nan(value));
|
||||
@ -742,7 +747,7 @@ static inline void bw_comp_set_gain_dB(
|
||||
|
||||
static inline char bw_comp_coeffs_is_valid(
|
||||
const bw_comp_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_comp_coeffs"))
|
||||
@ -780,17 +785,17 @@ static inline char bw_comp_coeffs_is_valid(
|
||||
static inline char bw_comp_state_is_valid(
|
||||
const bw_comp_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_comp_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_comp_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_env_follow_state_is_valid(coeffs ? &coeffs->env_follow_coeffs : NULL, &state->env_follow_state);
|
||||
return bw_env_follow_state_is_valid(coeffs ? &coeffs->env_follow_coeffs : BW_NULL, &state->env_follow_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_buf bw_common bw_math }}}
|
||||
* description {{{
|
||||
* Interpolated delay line, not smoothed.
|
||||
@ -31,6 +31,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Removed <code>read()</code> and <code>write()</code> from C++
|
||||
@ -171,7 +176,7 @@ static inline void bw_delay_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_delay_read()
|
||||
* ```>>> */
|
||||
@ -292,8 +297,8 @@ static inline char bw_delay_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_delay_state`.
|
||||
@ -367,7 +372,7 @@ struct bw_delay_state {
|
||||
static inline void bw_delay_init(
|
||||
bw_delay_coeffs * BW_RESTRICT coeffs,
|
||||
float max_delay) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(max_delay));
|
||||
BW_ASSERT(max_delay >= 0.f);
|
||||
|
||||
@ -386,7 +391,7 @@ static inline void bw_delay_init(
|
||||
static inline void bw_delay_set_sample_rate(
|
||||
bw_delay_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -403,7 +408,7 @@ static inline void bw_delay_set_sample_rate(
|
||||
|
||||
static inline size_t bw_delay_mem_req(
|
||||
const bw_delay_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -414,11 +419,11 @@ static inline void bw_delay_mem_set(
|
||||
const bw_delay_coeffs * BW_RESTRICT coeffs,
|
||||
bw_delay_state * BW_RESTRICT state,
|
||||
void * BW_RESTRICT mem) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_set_sample_rate);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(mem != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(mem != BW_NULL);
|
||||
|
||||
(void)coeffs;
|
||||
state->buf = (float *)mem;
|
||||
@ -444,7 +449,7 @@ static inline void bw_delay_do_update_coeffs_ctrl(bw_delay_coeffs *BW_RESTRICT c
|
||||
|
||||
static inline void bw_delay_reset_coeffs(
|
||||
bw_delay_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -463,10 +468,10 @@ static inline float bw_delay_reset_state(
|
||||
const bw_delay_coeffs * BW_RESTRICT coeffs,
|
||||
bw_delay_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(state->state >= bw_delay_state_state_mem_set);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
@ -494,18 +499,18 @@ static inline void bw_delay_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_delay_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -514,7 +519,7 @@ static inline void bw_delay_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static float bw_delay_read(
|
||||
@ -522,10 +527,10 @@ static float bw_delay_read(
|
||||
const bw_delay_state * BW_RESTRICT state,
|
||||
size_t di,
|
||||
float df) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(state->state >= bw_delay_state_state_reset_state);
|
||||
BW_ASSERT(bw_is_finite(df));
|
||||
@ -549,10 +554,10 @@ static void bw_delay_write(
|
||||
const bw_delay_coeffs * BW_RESTRICT coeffs,
|
||||
bw_delay_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(state->state >= bw_delay_state_state_reset_state);
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
@ -569,7 +574,7 @@ static void bw_delay_write(
|
||||
|
||||
static inline void bw_delay_update_coeffs_ctrl(
|
||||
bw_delay_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -581,7 +586,7 @@ static inline void bw_delay_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_delay_update_coeffs_audio(
|
||||
bw_delay_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -592,10 +597,10 @@ static inline float bw_delay_process1(
|
||||
const bw_delay_coeffs * BW_RESTRICT coeffs,
|
||||
bw_delay_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(state->state >= bw_delay_state_state_reset_state);
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
@ -618,15 +623,15 @@ static inline void bw_delay_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(state->state >= bw_delay_state_state_reset_state);
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_delay_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++)
|
||||
@ -646,17 +651,17 @@ static inline void bw_delay_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -675,7 +680,7 @@ static inline void bw_delay_process_multi(
|
||||
static inline void bw_delay_set_delay(
|
||||
bw_delay_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -691,7 +696,7 @@ static inline void bw_delay_set_delay(
|
||||
|
||||
static inline size_t bw_delay_get_length(
|
||||
const bw_delay_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_delay_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_delay_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -700,7 +705,7 @@ static inline size_t bw_delay_get_length(
|
||||
|
||||
static inline char bw_delay_coeffs_is_valid(
|
||||
const bw_delay_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_delay_coeffs"))
|
||||
@ -736,7 +741,7 @@ static inline char bw_delay_coeffs_is_valid(
|
||||
static inline char bw_delay_state_is_valid(
|
||||
const bw_delay_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_delay_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_delay_state"))
|
||||
@ -747,11 +752,11 @@ static inline char bw_delay_state_is_valid(
|
||||
|
||||
(void)coeffs;
|
||||
|
||||
if (state->buf == NULL)
|
||||
if (state->buf == BW_NULL)
|
||||
return 0;
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->state >= bw_delay_state_state_reset_state && coeffs != NULL) {
|
||||
if (state->state >= bw_delay_state_state_reset_state && coeffs != BW_NULL) {
|
||||
if (coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{
|
||||
* bw_clip bw_common bw_gain bw_hp1 bw_lp1 bw_math bw_mm2 bw_one_pole bw_peak
|
||||
* bw_satur bw_svf
|
||||
@ -32,6 +32,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Adjusted internal peak cutoff to more sensible value.</li>
|
||||
@ -140,7 +145,7 @@ static inline void bw_dist_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_dist_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -253,8 +258,8 @@ static inline char bw_dist_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_dist_state`.
|
||||
@ -321,7 +326,7 @@ struct bw_dist_state {
|
||||
|
||||
static inline void bw_dist_init(
|
||||
bw_dist_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_hp1_init(&coeffs->hp1_coeffs);
|
||||
bw_peak_init(&coeffs->peak_coeffs);
|
||||
@ -351,7 +356,7 @@ static inline void bw_dist_init(
|
||||
static inline void bw_dist_set_sample_rate(
|
||||
bw_dist_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -375,7 +380,7 @@ static inline void bw_dist_set_sample_rate(
|
||||
|
||||
static inline void bw_dist_reset_coeffs(
|
||||
bw_dist_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -395,10 +400,10 @@ static inline float bw_dist_reset_state(
|
||||
const bw_dist_coeffs * BW_RESTRICT coeffs,
|
||||
bw_dist_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
float y = bw_hp1_reset_state(&coeffs->hp1_coeffs, &state->hp1_state, x_0);
|
||||
@ -426,18 +431,18 @@ static inline void bw_dist_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_dist_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -446,12 +451,12 @@ static inline void bw_dist_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_dist_update_coeffs_ctrl(
|
||||
bw_dist_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -465,7 +470,7 @@ static inline void bw_dist_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_dist_update_coeffs_audio(
|
||||
bw_dist_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -481,10 +486,10 @@ static inline float bw_dist_process1(
|
||||
const bw_dist_coeffs * BW_RESTRICT coeffs,
|
||||
bw_dist_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -509,14 +514,14 @@ static inline void bw_dist_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_dist_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -537,17 +542,17 @@ static inline void bw_dist_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -568,7 +573,7 @@ static inline void bw_dist_process_multi(
|
||||
static inline void bw_dist_set_distortion(
|
||||
bw_dist_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -583,7 +588,7 @@ static inline void bw_dist_set_distortion(
|
||||
static inline void bw_dist_set_tone(
|
||||
bw_dist_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -598,7 +603,7 @@ static inline void bw_dist_set_tone(
|
||||
static inline void bw_dist_set_volume(
|
||||
bw_dist_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dist_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dist_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -612,7 +617,7 @@ static inline void bw_dist_set_volume(
|
||||
|
||||
static inline char bw_dist_coeffs_is_valid(
|
||||
const bw_dist_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_dist_coeffs"))
|
||||
@ -632,21 +637,21 @@ static inline char bw_dist_coeffs_is_valid(
|
||||
static inline char bw_dist_state_is_valid(
|
||||
const bw_dist_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_dist_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_dist_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_hp1_state_is_valid(coeffs ? &coeffs->hp1_coeffs : NULL, &state->hp1_state)
|
||||
&& bw_peak_state_is_valid(coeffs ? &coeffs->peak_coeffs : NULL, &state->peak_state)
|
||||
&& bw_clip_state_is_valid(coeffs ? &coeffs->clip_coeffs : NULL, &state->clip_state)
|
||||
&& bw_satur_state_is_valid(coeffs ? &coeffs->satur_coeffs : NULL, &state->satur_state)
|
||||
&& bw_lp1_state_is_valid(coeffs ? &coeffs->lp1_coeffs : NULL, &state->lp1_state);
|
||||
return bw_hp1_state_is_valid(coeffs ? &coeffs->hp1_coeffs : BW_NULL, &state->hp1_state)
|
||||
&& bw_peak_state_is_valid(coeffs ? &coeffs->peak_coeffs : BW_NULL, &state->peak_state)
|
||||
&& bw_clip_state_is_valid(coeffs ? &coeffs->clip_coeffs : BW_NULL, &state->clip_state)
|
||||
&& bw_satur_state_is_valid(coeffs ? &coeffs->satur_coeffs : BW_NULL, &state->satur_state)
|
||||
&& bw_lp1_state_is_valid(coeffs ? &coeffs->lp1_coeffs : BW_NULL, &state->lp1_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{
|
||||
* bw_common bw_gain bw_hs1 bw_lp1 bw_math bw_mm2 bw_one_pole bw_peak
|
||||
* bw_satur bw_svf
|
||||
@ -32,6 +32,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Improved algorithm to be a bit more faithful to the
|
||||
@ -141,7 +146,7 @@ static inline void bw_drive_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_drive_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -254,8 +259,8 @@ static inline char bw_drive_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_drive_state`.
|
||||
@ -322,7 +327,7 @@ struct bw_drive_state {
|
||||
|
||||
static inline void bw_drive_init(
|
||||
bw_drive_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_svf_init(&coeffs->hp2_coeffs);
|
||||
bw_hs1_init(&coeffs->hs1_coeffs);
|
||||
@ -352,7 +357,7 @@ static inline void bw_drive_init(
|
||||
static inline void bw_drive_set_sample_rate(
|
||||
bw_drive_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -376,7 +381,7 @@ static inline void bw_drive_set_sample_rate(
|
||||
|
||||
static inline void bw_drive_reset_coeffs(
|
||||
bw_drive_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -396,10 +401,10 @@ static inline float bw_drive_reset_state(
|
||||
const bw_drive_coeffs * BW_RESTRICT coeffs,
|
||||
bw_drive_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
float v_lp, v_hp, v_bp;
|
||||
@ -428,18 +433,18 @@ static inline void bw_drive_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_drive_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -448,12 +453,12 @@ static inline void bw_drive_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_drive_update_coeffs_ctrl(
|
||||
bw_drive_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -467,7 +472,7 @@ static inline void bw_drive_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_drive_update_coeffs_audio(
|
||||
bw_drive_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -483,10 +488,10 @@ static inline float bw_drive_process1(
|
||||
const bw_drive_coeffs * BW_RESTRICT coeffs,
|
||||
bw_drive_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -512,14 +517,14 @@ static inline void bw_drive_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_drive_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -540,17 +545,17 @@ static inline void bw_drive_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -571,7 +576,7 @@ static inline void bw_drive_process_multi(
|
||||
static inline void bw_drive_set_drive(
|
||||
bw_drive_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -586,7 +591,7 @@ static inline void bw_drive_set_drive(
|
||||
static inline void bw_drive_set_tone(
|
||||
bw_drive_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -601,7 +606,7 @@ static inline void bw_drive_set_tone(
|
||||
static inline void bw_drive_set_volume(
|
||||
bw_drive_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_drive_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_drive_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -615,7 +620,7 @@ static inline void bw_drive_set_volume(
|
||||
|
||||
static inline char bw_drive_coeffs_is_valid(
|
||||
const bw_drive_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_drive_coeffs"))
|
||||
@ -635,21 +640,21 @@ static inline char bw_drive_coeffs_is_valid(
|
||||
static inline char bw_drive_state_is_valid(
|
||||
const bw_drive_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_drive_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_drive_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_svf_state_is_valid(coeffs ? &coeffs->hp2_coeffs : NULL, &state->hp2_state)
|
||||
&& bw_hs1_state_is_valid(coeffs ? &coeffs->hs1_coeffs : NULL, &state->hs1_state)
|
||||
&& bw_peak_state_is_valid(coeffs ? &coeffs->peak_coeffs : NULL, &state->peak_state)
|
||||
&& bw_satur_state_is_valid(coeffs ? &coeffs->satur_coeffs : NULL, &state->satur_state)
|
||||
&& bw_lp1_state_is_valid(coeffs ? &coeffs->lp1_coeffs : NULL, &state->lp1_state);
|
||||
return bw_svf_state_is_valid(coeffs ? &coeffs->hp2_coeffs : BW_NULL, &state->hp2_state)
|
||||
&& bw_hs1_state_is_valid(coeffs ? &coeffs->hs1_coeffs : BW_NULL, &state->hs1_state)
|
||||
&& bw_peak_state_is_valid(coeffs ? &coeffs->peak_coeffs : BW_NULL, &state->peak_state)
|
||||
&& bw_satur_state_is_valid(coeffs ? &coeffs->satur_coeffs : BW_NULL, &state->satur_state)
|
||||
&& bw_lp1_state_is_valid(coeffs ? &coeffs->lp1_coeffs : BW_NULL, &state->lp1_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,13 +20,18 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_gain bw_math bw_one_pole }}}
|
||||
* description {{{
|
||||
* Dry/wet mixer.
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Module renamed as bw_dry_wet.</li>
|
||||
@ -220,7 +225,7 @@ struct bw_dry_wet_coeffs {
|
||||
|
||||
static inline void bw_dry_wet_init(
|
||||
bw_dry_wet_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_gain_init(&coeffs->gain_coeffs);
|
||||
|
||||
@ -235,7 +240,7 @@ static inline void bw_dry_wet_init(
|
||||
static inline void bw_dry_wet_set_sample_rate(
|
||||
bw_dry_wet_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dry_wet_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dry_wet_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -251,7 +256,7 @@ static inline void bw_dry_wet_set_sample_rate(
|
||||
|
||||
static inline void bw_dry_wet_reset_coeffs(
|
||||
bw_dry_wet_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dry_wet_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dry_wet_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -266,7 +271,7 @@ static inline void bw_dry_wet_reset_coeffs(
|
||||
|
||||
static inline void bw_dry_wet_update_coeffs_ctrl(
|
||||
bw_dry_wet_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dry_wet_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dry_wet_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -278,7 +283,7 @@ static inline void bw_dry_wet_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_dry_wet_update_coeffs_audio(
|
||||
bw_dry_wet_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dry_wet_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dry_wet_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -292,7 +297,7 @@ static inline float bw_dry_wet_process1(
|
||||
const bw_dry_wet_coeffs * BW_RESTRICT coeffs,
|
||||
float x_dry,
|
||||
float x_wet) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dry_wet_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dry_wet_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(bw_is_finite(x_dry));
|
||||
@ -313,14 +318,14 @@ static inline void bw_dry_wet_process(
|
||||
const float * x_wet,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dry_wet_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dry_wet_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(x_dry != NULL);
|
||||
BW_ASSERT(x_dry != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x_dry, n_samples));
|
||||
BW_ASSERT(x_wet != NULL);
|
||||
BW_ASSERT(x_wet != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x_wet, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_dry_wet_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -340,12 +345,12 @@ static inline void bw_dry_wet_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dry_wet_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dry_wet_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(x_dry != NULL);
|
||||
BW_ASSERT(x_wet != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x_dry != BW_NULL);
|
||||
BW_ASSERT(x_wet != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -366,7 +371,7 @@ static inline void bw_dry_wet_process_multi(
|
||||
static inline void bw_dry_wet_set_wet(
|
||||
bw_dry_wet_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dry_wet_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dry_wet_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -381,7 +386,7 @@ static inline void bw_dry_wet_set_wet(
|
||||
static inline void bw_dry_wet_set_smooth_tau(
|
||||
bw_dry_wet_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_dry_wet_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_dry_wet_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -395,7 +400,7 @@ static inline void bw_dry_wet_set_smooth_tau(
|
||||
|
||||
static inline char bw_dry_wet_coeffs_is_valid(
|
||||
const bw_dry_wet_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_dry_wet_coeffs"))
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_math bw_one_pole }}}
|
||||
* description {{{
|
||||
* Envelope follower made of a full-wave rectifier followed by
|
||||
@ -28,6 +28,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added initial input value to
|
||||
@ -151,7 +156,7 @@ static inline void bw_env_follow_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_env_follow_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -190,7 +195,7 @@ static inline void bw_env_follow_process(
|
||||
* first `n_samples` of the output buffer `y`, while using and updating both
|
||||
* `coeffs` and `state` (control and audio rate).
|
||||
*
|
||||
* `y` may be `NULL`.
|
||||
* `y` may be `BW_NULL`.
|
||||
*
|
||||
* #### bw_env_follow_process_multi()
|
||||
* ```>>> */
|
||||
@ -207,7 +212,7 @@ static inline void bw_env_follow_process_multi(
|
||||
* using and updating both the common `coeffs` and each of the `n_channels`
|
||||
* `state`s (control and audio rate).
|
||||
*
|
||||
* `y` or any element of `y` may be `NULL`.
|
||||
* `y` or any element of `y` may be `BW_NULL`.
|
||||
*
|
||||
* #### bw_env_follow_set_attack_tau()
|
||||
* ```>>> */
|
||||
@ -264,8 +269,8 @@ static inline char bw_env_follow_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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`.
|
||||
@ -319,7 +324,7 @@ struct bw_env_follow_state {
|
||||
|
||||
static inline void bw_env_follow_init(
|
||||
bw_env_follow_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_one_pole_init(&coeffs->one_pole_coeffs);
|
||||
|
||||
@ -335,7 +340,7 @@ static inline void bw_env_follow_init(
|
||||
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(coeffs != BW_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);
|
||||
@ -351,7 +356,7 @@ static inline void bw_env_follow_set_sample_rate(
|
||||
|
||||
static inline void bw_env_follow_reset_coeffs(
|
||||
bw_env_follow_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -369,10 +374,10 @@ 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) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
const float x = bw_absf(x_0);
|
||||
@ -396,18 +401,18 @@ static inline void bw_env_follow_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_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
|
||||
@ -416,12 +421,12 @@ static inline void bw_env_follow_reset_state_multi(
|
||||
|
||||
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);
|
||||
BW_ASSERT_DEEP(y_0 != BW_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(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -433,7 +438,7 @@ static inline void bw_env_follow_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_env_follow_update_coeffs_audio(
|
||||
bw_env_follow_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_follow_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_follow_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -447,10 +452,10 @@ 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(coeffs != BW_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(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_follow_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -471,16 +476,16 @@ static inline void bw_env_follow_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_follow_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
|
||||
bw_env_follow_update_coeffs_ctrl(coeffs);
|
||||
if (y != NULL)
|
||||
if (y != BW_NULL)
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
bw_env_follow_update_coeffs_audio(coeffs);
|
||||
y[i] = bw_env_follow_process1(coeffs, state, x[i]);
|
||||
@ -494,7 +499,7 @@ static inline void bw_env_follow_process(
|
||||
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);
|
||||
BW_ASSERT_DEEP(y != BW_NULL ? bw_has_only_finite(y, n_samples) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_env_follow_process_multi(
|
||||
@ -504,30 +509,30 @@ static inline void bw_env_follow_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
if (y != NULL)
|
||||
if (y != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(y[i] == NULL || y[j] == NULL || y[i] != y[j]);
|
||||
BW_ASSERT(y[i] == BW_NULL || y[j] == BW_NULL || y[i] != y[j]);
|
||||
#endif
|
||||
|
||||
bw_env_follow_update_coeffs_ctrl(coeffs);
|
||||
if (y != NULL)
|
||||
if (y != BW_NULL)
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
bw_env_follow_update_coeffs_audio(coeffs);
|
||||
for (size_t j = 0; j < n_channels; j++) {
|
||||
const float v = bw_env_follow_process1(coeffs, state[j], x[j][i]);
|
||||
if (y[j] != NULL)
|
||||
if (y[j] != BW_NULL)
|
||||
y[j][i] = v;
|
||||
}
|
||||
}
|
||||
@ -545,7 +550,7 @@ static inline void bw_env_follow_process_multi(
|
||||
static inline void bw_env_follow_set_attack_tau(
|
||||
bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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));
|
||||
@ -560,7 +565,7 @@ static inline void bw_env_follow_set_attack_tau(
|
||||
static inline void bw_env_follow_set_release_tau(
|
||||
bw_env_follow_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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));
|
||||
@ -574,15 +579,15 @@ static inline void bw_env_follow_set_release_tau(
|
||||
|
||||
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));
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_follow_state_is_valid(BW_NULL, 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);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_env_follow_coeffs"))
|
||||
@ -597,17 +602,17 @@ static inline char bw_env_follow_coeffs_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) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_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)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_one_pole_state_is_valid(coeffs ? &coeffs->one_pole_coeffs : NULL, &state->one_pole_state);
|
||||
return bw_one_pole_state_is_valid(coeffs ? &coeffs->one_pole_coeffs : BW_NULL, &state->one_pole_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -43,6 +43,7 @@
|
||||
* <li>Version <strong>1.1.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added skip_sustain and always_reach_sustain parameters.</li>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
@ -200,7 +201,7 @@ static inline void bw_env_gen_reset_state_multi(
|
||||
* non-`0` for on) in the `gate_0` array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_env_gen_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -248,7 +249,7 @@ static inline void bw_env_gen_process(
|
||||
* the given `gate` value (`0` for off, non-`0` for on), while using and
|
||||
* updating both `coeffs` and `state` (control and audio rate).
|
||||
*
|
||||
* `y` may be `NULL`.
|
||||
* `y` may be `BW_NULL`.
|
||||
*
|
||||
* #### bw_env_gen_process_multi()
|
||||
* ```>>> */
|
||||
@ -265,7 +266,7 @@ static inline void bw_env_gen_process_multi(
|
||||
* non-`0` for on), while using and updating both the common `coeffs` and
|
||||
* each of the `n_channels` `state`s (control and audio rate).
|
||||
*
|
||||
* `y` or any element of `y` may be `NULL`.
|
||||
* `y` or any element of `y` may be `BW_NULL`.
|
||||
*
|
||||
* #### bw_env_gen_set_attack()
|
||||
* ```>>> */
|
||||
@ -372,8 +373,8 @@ static inline char bw_env_gen_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_gen_state`.
|
||||
@ -452,7 +453,7 @@ struct bw_env_gen_state {
|
||||
|
||||
static inline void bw_env_gen_init(
|
||||
bw_env_gen_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_one_pole_init(&coeffs->smooth_coeffs);
|
||||
bw_one_pole_set_tau(&coeffs->smooth_coeffs, 0.05f);
|
||||
@ -475,7 +476,7 @@ static inline void bw_env_gen_init(
|
||||
static inline void bw_env_gen_set_sample_rate(
|
||||
bw_env_gen_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -509,7 +510,7 @@ static inline void bw_env_gen_do_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_env_gen_reset_coeffs(
|
||||
bw_env_gen_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -528,10 +529,10 @@ static inline float bw_env_gen_reset_state(
|
||||
const bw_env_gen_coeffs * BW_RESTRICT coeffs,
|
||||
bw_env_gen_state * BW_RESTRICT state,
|
||||
char gate_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
bw_one_pole_reset_state(&coeffs->smooth_coeffs, &state->smooth_state, coeffs->sustain);
|
||||
if (gate_0) {
|
||||
@ -561,18 +562,18 @@ static inline void bw_env_gen_reset_state_multi(
|
||||
const char * BW_RESTRICT gate_0,
|
||||
float * BW_RESTRICT y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(gate_0 != NULL);
|
||||
BW_ASSERT(gate_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_env_gen_reset_state(coeffs, state[i], gate_0[i]);
|
||||
else
|
||||
@ -581,12 +582,12 @@ static inline void bw_env_gen_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_env_gen_update_coeffs_ctrl(
|
||||
bw_env_gen_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -598,7 +599,7 @@ static inline void bw_env_gen_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_env_gen_update_coeffs_audio(
|
||||
bw_env_gen_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -609,10 +610,10 @@ static inline void bw_env_gen_process_ctrl(
|
||||
const bw_env_gen_coeffs * BW_RESTRICT coeffs,
|
||||
bw_env_gen_state * BW_RESTRICT state,
|
||||
char gate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_state_is_valid(coeffs, state));
|
||||
|
||||
if (gate) {
|
||||
@ -631,10 +632,10 @@ static inline void bw_env_gen_process_ctrl(
|
||||
static inline float bw_env_gen_process1(
|
||||
const bw_env_gen_coeffs * BW_RESTRICT coeffs,
|
||||
bw_env_gen_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_state_is_valid(coeffs, state));
|
||||
|
||||
uint32_t v = 0;
|
||||
@ -686,15 +687,15 @@ static inline void bw_env_gen_process(
|
||||
char gate,
|
||||
float * BW_RESTRICT y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_state_is_valid(coeffs, state));
|
||||
|
||||
bw_env_gen_update_coeffs_ctrl(coeffs);
|
||||
bw_env_gen_process_ctrl(coeffs, state, gate);
|
||||
if (y != NULL)
|
||||
if (y != BW_NULL)
|
||||
for (size_t i = 0; i < n_samples; i++)
|
||||
y[i] = bw_env_gen_process1(coeffs, state);
|
||||
else
|
||||
@ -704,7 +705,7 @@ static inline void bw_env_gen_process(
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(bw_env_gen_state_is_valid(coeffs, state));
|
||||
BW_ASSERT_DEEP(y != NULL ? bw_has_only_finite(y, n_samples) : 1);
|
||||
BW_ASSERT_DEEP(y != BW_NULL ? bw_has_only_finite(y, n_samples) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_env_gen_process_multi(
|
||||
@ -714,31 +715,31 @@ static inline void bw_env_gen_process_multi(
|
||||
float * BW_RESTRICT const * BW_RESTRICT y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(gate != NULL);
|
||||
BW_ASSERT(gate != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
if (y != NULL)
|
||||
if (y != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(y[i] == NULL || y[j] == NULL || y[i] != y[j]);
|
||||
BW_ASSERT(y[i] == BW_NULL || y[j] == BW_NULL || y[i] != y[j]);
|
||||
#endif
|
||||
|
||||
bw_env_gen_update_coeffs_ctrl(coeffs);
|
||||
for (size_t j = 0; j < n_channels; j++)
|
||||
bw_env_gen_process_ctrl(coeffs, state[j], gate[j]);
|
||||
if (y != NULL)
|
||||
if (y != BW_NULL)
|
||||
for (size_t i = 0; i < n_samples; i++)
|
||||
for (size_t j = 0; j < n_channels; j++) {
|
||||
const float v = bw_env_gen_process1(coeffs, state[j]);
|
||||
if (y[j] != NULL)
|
||||
if (y[j] != BW_NULL)
|
||||
y[j][i] = v;
|
||||
}
|
||||
else
|
||||
@ -753,7 +754,7 @@ static inline void bw_env_gen_process_multi(
|
||||
static inline void bw_env_gen_set_attack(
|
||||
bw_env_gen_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -774,7 +775,7 @@ static inline void bw_env_gen_set_attack(
|
||||
static inline void bw_env_gen_set_decay(
|
||||
bw_env_gen_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -795,7 +796,7 @@ static inline void bw_env_gen_set_decay(
|
||||
static inline void bw_env_gen_set_sustain(
|
||||
bw_env_gen_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -816,7 +817,7 @@ static inline void bw_env_gen_set_sustain(
|
||||
static inline void bw_env_gen_set_release(
|
||||
bw_env_gen_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -837,7 +838,7 @@ static inline void bw_env_gen_set_release(
|
||||
static inline void bw_env_gen_set_skip_sustain(
|
||||
bw_env_gen_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_init);
|
||||
|
||||
@ -850,7 +851,7 @@ static inline void bw_env_gen_set_skip_sustain(
|
||||
static inline void bw_env_gen_set_always_reach_sustain(
|
||||
bw_env_gen_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_env_gen_coeffs_state_init);
|
||||
|
||||
@ -862,16 +863,16 @@ static inline void bw_env_gen_set_always_reach_sustain(
|
||||
|
||||
static inline bw_env_gen_phase bw_env_gen_get_phase(
|
||||
const bw_env_gen_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_state_is_valid(NULL, state));
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_state_is_valid(BW_NULL, state));
|
||||
|
||||
return state->phase;
|
||||
}
|
||||
|
||||
static inline float bw_env_gen_get_y_z1(
|
||||
const bw_env_gen_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_state_is_valid(NULL, state));
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_env_gen_state_is_valid(BW_NULL, state));
|
||||
|
||||
const float y = (1.f / (float)BW_ENV_V_MAX) * state->v;
|
||||
|
||||
@ -882,7 +883,7 @@ static inline float bw_env_gen_get_y_z1(
|
||||
|
||||
static inline char bw_env_gen_coeffs_is_valid(
|
||||
const bw_env_gen_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_env_gen_coeffs"))
|
||||
@ -911,18 +912,18 @@ static inline char bw_env_gen_coeffs_is_valid(
|
||||
static inline char bw_env_gen_state_is_valid(
|
||||
const bw_env_gen_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_env_gen_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_env_gen_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return state->phase >= bw_env_gen_phase_off && state->phase <= bw_env_gen_phase_release
|
||||
&& bw_one_pole_state_is_valid(coeffs ? &coeffs->smooth_coeffs : NULL, &state->smooth_state);
|
||||
&& bw_one_pole_state_is_valid(coeffs ? &coeffs->smooth_coeffs : BW_NULL, &state->smooth_state);
|
||||
}
|
||||
|
||||
#undef BW_ENV_GEN_PARAM_ATTACK
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2023, 2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{
|
||||
* bw_common bw_gain bw_hp1 bw_lp1 bw_math bw_mm2 bw_one_pole bw_peak
|
||||
* bw_satur bw_svf
|
||||
@ -32,6 +32,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Improved algorithm to be a bit more faithful to the
|
||||
@ -141,7 +146,7 @@ static inline void bw_fuzz_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_fuzz_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -242,8 +247,8 @@ static inline char bw_fuzz_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_fuzz_state`.
|
||||
@ -311,7 +316,7 @@ struct bw_fuzz_state {
|
||||
|
||||
static inline void bw_fuzz_init(
|
||||
bw_fuzz_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_hp1_init(&coeffs->hp1_in_coeffs);
|
||||
bw_svf_init(&coeffs->lp2_coeffs);
|
||||
@ -338,7 +343,7 @@ static inline void bw_fuzz_init(
|
||||
static inline void bw_fuzz_set_sample_rate(
|
||||
bw_fuzz_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -363,7 +368,7 @@ static inline void bw_fuzz_set_sample_rate(
|
||||
|
||||
static inline void bw_fuzz_reset_coeffs(
|
||||
bw_fuzz_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -382,10 +387,10 @@ static inline float bw_fuzz_reset_state(
|
||||
const bw_fuzz_coeffs * BW_RESTRICT coeffs,
|
||||
bw_fuzz_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
float y = bw_hp1_reset_state(&coeffs->hp1_in_coeffs, &state->hp1_in_state, x_0);
|
||||
@ -415,18 +420,18 @@ static inline void bw_fuzz_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_fuzz_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -435,12 +440,12 @@ static inline void bw_fuzz_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_fuzz_update_coeffs_ctrl(
|
||||
bw_fuzz_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -453,7 +458,7 @@ static inline void bw_fuzz_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_fuzz_update_coeffs_audio(
|
||||
bw_fuzz_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -468,10 +473,10 @@ static inline float bw_fuzz_process1(
|
||||
const bw_fuzz_coeffs * BW_RESTRICT coeffs,
|
||||
bw_fuzz_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -498,14 +503,14 @@ static inline void bw_fuzz_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_fuzz_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -526,17 +531,17 @@ static inline void bw_fuzz_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -557,7 +562,7 @@ static inline void bw_fuzz_process_multi(
|
||||
static inline void bw_fuzz_set_fuzz(
|
||||
bw_fuzz_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -572,7 +577,7 @@ static inline void bw_fuzz_set_fuzz(
|
||||
static inline void bw_fuzz_set_volume(
|
||||
bw_fuzz_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_fuzz_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_fuzz_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -586,7 +591,7 @@ static inline void bw_fuzz_set_volume(
|
||||
|
||||
static inline char bw_fuzz_coeffs_is_valid(
|
||||
const bw_fuzz_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_fuzz_coeffs"))
|
||||
@ -606,22 +611,22 @@ static inline char bw_fuzz_coeffs_is_valid(
|
||||
static inline char bw_fuzz_state_is_valid(
|
||||
const bw_fuzz_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_fuzz_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_fuzz_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_hp1_state_is_valid(coeffs ? &coeffs->hp1_in_coeffs : NULL, &state->hp1_in_state)
|
||||
&& bw_svf_state_is_valid(coeffs ? &coeffs->lp2_coeffs : NULL, &state->lp2_1_state)
|
||||
&& bw_svf_state_is_valid(coeffs ? &coeffs->lp2_coeffs : NULL, &state->lp2_2_state)
|
||||
&& bw_peak_state_is_valid(coeffs ? &coeffs->peak_coeffs : NULL, &state->peak_state)
|
||||
&& bw_satur_state_is_valid(coeffs ? &coeffs->satur_coeffs : NULL, &state->satur_state)
|
||||
&& bw_hp1_state_is_valid(coeffs ? &coeffs->hp1_out_coeffs : NULL, &state->hp1_out_state);
|
||||
return bw_hp1_state_is_valid(coeffs ? &coeffs->hp1_in_coeffs : BW_NULL, &state->hp1_in_state)
|
||||
&& bw_svf_state_is_valid(coeffs ? &coeffs->lp2_coeffs : BW_NULL, &state->lp2_1_state)
|
||||
&& bw_svf_state_is_valid(coeffs ? &coeffs->lp2_coeffs : BW_NULL, &state->lp2_2_state)
|
||||
&& bw_peak_state_is_valid(coeffs ? &coeffs->peak_coeffs : BW_NULL, &state->peak_state)
|
||||
&& bw_satur_state_is_valid(coeffs ? &coeffs->satur_coeffs : BW_NULL, &state->satur_state)
|
||||
&& bw_hp1_state_is_valid(coeffs ? &coeffs->hp1_out_coeffs : BW_NULL, &state->hp1_out_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,13 +20,18 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_math bw_one_pole }}}
|
||||
* description {{{
|
||||
* Gain.
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added <code>bw_gain_get_gain_lin()</code>.</li>
|
||||
@ -272,7 +277,7 @@ struct bw_gain_coeffs {
|
||||
|
||||
static inline void bw_gain_init(
|
||||
bw_gain_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_one_pole_init(&coeffs->smooth_coeffs);
|
||||
bw_one_pole_set_tau(&coeffs->smooth_coeffs, 0.05f);
|
||||
@ -289,7 +294,7 @@ static inline void bw_gain_init(
|
||||
static inline void bw_gain_set_sample_rate(
|
||||
bw_gain_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -305,7 +310,7 @@ static inline void bw_gain_set_sample_rate(
|
||||
|
||||
static inline void bw_gain_reset_coeffs(
|
||||
bw_gain_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -321,7 +326,7 @@ static inline void bw_gain_reset_coeffs(
|
||||
|
||||
static inline void bw_gain_update_coeffs_ctrl(
|
||||
bw_gain_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -333,7 +338,7 @@ static inline void bw_gain_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_gain_update_coeffs_audio(
|
||||
bw_gain_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -347,7 +352,7 @@ static inline void bw_gain_update_coeffs_audio(
|
||||
static inline float bw_gain_process1(
|
||||
const bw_gain_coeffs * BW_RESTRICT coeffs,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
@ -366,12 +371,12 @@ static inline void bw_gain_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_gain_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -390,11 +395,11 @@ static inline void bw_gain_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -415,7 +420,7 @@ static inline void bw_gain_process_multi(
|
||||
static inline void bw_gain_set_gain_lin(
|
||||
bw_gain_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -429,7 +434,7 @@ static inline void bw_gain_set_gain_lin(
|
||||
static inline void bw_gain_set_gain_dB(
|
||||
bw_gain_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_init);
|
||||
BW_ASSERT(!bw_is_nan(value));
|
||||
@ -444,7 +449,7 @@ static inline void bw_gain_set_gain_dB(
|
||||
static inline void bw_gain_set_smooth_tau(
|
||||
bw_gain_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_init);
|
||||
BW_ASSERT(!bw_is_nan(value));
|
||||
@ -458,7 +463,7 @@ static inline void bw_gain_set_smooth_tau(
|
||||
|
||||
static inline float bw_gain_get_gain_lin(
|
||||
const bw_gain_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
|
||||
return coeffs->gain;
|
||||
@ -466,7 +471,7 @@ static inline float bw_gain_get_gain_lin(
|
||||
|
||||
static inline float bw_gain_get_gain_cur(
|
||||
const bw_gain_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -475,7 +480,7 @@ static inline float bw_gain_get_gain_cur(
|
||||
|
||||
static inline char bw_gain_coeffs_is_valid(
|
||||
const bw_gain_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_gain_coeffs"))
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_lp1 bw_math bw_one_pole }}}
|
||||
* description {{{
|
||||
* First-order highpass filter (6 dB/oct) with gain asymptotically
|
||||
@ -28,6 +28,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added <code>bw_hp1_reset_state_multi()</code> and updated C++
|
||||
@ -146,7 +151,7 @@ static inline void bw_hp1_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_hp1_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -260,8 +265,8 @@ static inline char bw_hp1_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_hp1_state`.
|
||||
@ -314,7 +319,7 @@ struct bw_hp1_state {
|
||||
|
||||
static inline void bw_hp1_init(
|
||||
bw_hp1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_lp1_init(&coeffs->lp1_coeffs);
|
||||
|
||||
@ -330,7 +335,7 @@ static inline void bw_hp1_init(
|
||||
static inline void bw_hp1_set_sample_rate(
|
||||
bw_hp1_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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);
|
||||
@ -346,7 +351,7 @@ static inline void bw_hp1_set_sample_rate(
|
||||
|
||||
static inline void bw_hp1_reset_coeffs(
|
||||
bw_hp1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -364,10 +369,10 @@ static inline float 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(coeffs != BW_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(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
const float lp = bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
|
||||
@ -391,31 +396,31 @@ static inline void bw_hp1_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
bw_hp1_reset_state(coeffs, state[i], x_0[i]);
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = 0.f;
|
||||
|
||||
BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_hp1_update_coeffs_ctrl(
|
||||
bw_hp1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -427,7 +432,7 @@ static inline void bw_hp1_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_hp1_update_coeffs_audio(
|
||||
bw_hp1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -441,10 +446,10 @@ 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(coeffs != BW_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(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hp1_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -465,14 +470,14 @@ static inline void bw_hp1_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hp1_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_hp1_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -493,17 +498,17 @@ static inline void bw_hp1_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -524,7 +529,7 @@ static inline void bw_hp1_process_multi(
|
||||
static inline void bw_hp1_set_cutoff(
|
||||
bw_hp1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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));
|
||||
@ -539,7 +544,7 @@ static inline void bw_hp1_set_cutoff(
|
||||
static inline void bw_hp1_set_prewarp_at_cutoff(
|
||||
bw_hp1_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hp1_coeffs_state_init);
|
||||
|
||||
@ -552,7 +557,7 @@ static inline void bw_hp1_set_prewarp_at_cutoff(
|
||||
static inline void bw_hp1_set_prewarp_freq(
|
||||
bw_hp1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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));
|
||||
@ -566,7 +571,7 @@ static inline void bw_hp1_set_prewarp_freq(
|
||||
|
||||
static inline char bw_hp1_coeffs_is_valid(
|
||||
const bw_hp1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_hp1_coeffs"))
|
||||
@ -581,17 +586,17 @@ static inline char bw_hp1_coeffs_is_valid(
|
||||
static inline char bw_hp1_state_is_valid(
|
||||
const bw_hp1_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_hp1_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_hp1_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_lp1_state_is_valid(coeffs ? &coeffs->lp1_coeffs : NULL, &state->lp1_state);
|
||||
return bw_lp1_state_is_valid(coeffs ? &coeffs->lp1_coeffs : BW_NULL, &state->lp1_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,13 +20,18 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_gain bw_lp1 bw_math bw_mm1 bw_one_pole }}}
|
||||
* description {{{
|
||||
* First-order high shelf filter (6 dB/oct) with unitary DC gain.
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added <code>bw_hs1_reset_state_multi()</code> and updated C++
|
||||
@ -147,7 +152,7 @@ static inline void bw_hs1_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_hs1_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -302,8 +307,8 @@ static inline char bw_hs1_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_hs1_state`.
|
||||
@ -364,7 +369,7 @@ struct bw_hs1_state {
|
||||
|
||||
static inline void bw_hs1_init(
|
||||
bw_hs1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_mm1_init(&coeffs->mm1_coeffs);
|
||||
bw_mm1_set_prewarp_at_cutoff(&coeffs->mm1_coeffs, 0);
|
||||
@ -387,7 +392,7 @@ static inline void bw_hs1_init(
|
||||
static inline void bw_hs1_set_sample_rate(
|
||||
bw_hs1_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -414,7 +419,7 @@ static inline void bw_hs1_update_mm1_params(
|
||||
|
||||
static inline void bw_hs1_reset_coeffs(
|
||||
bw_hs1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_set_sample_rate);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(coeffs->high_gain) >= 1e-6f && coeffs->cutoff * bw_sqrtf(coeffs->high_gain) <= 1e12f);
|
||||
@ -435,10 +440,10 @@ static inline float bw_hs1_reset_state(
|
||||
const bw_hs1_coeffs * BW_RESTRICT coeffs,
|
||||
bw_hs1_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
const float y = bw_mm1_reset_state(&coeffs->mm1_coeffs, &state->mm1_state, x_0);
|
||||
@ -461,18 +466,18 @@ static inline void bw_hs1_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_hs1_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -481,12 +486,12 @@ static inline void bw_hs1_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_hs1_update_coeffs_ctrl(
|
||||
bw_hs1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(coeffs->high_gain) >= 1e-6f && coeffs->cutoff * bw_sqrtf(coeffs->high_gain) <= 1e12f);
|
||||
@ -500,7 +505,7 @@ static inline void bw_hs1_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_hs1_update_coeffs_audio(
|
||||
bw_hs1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(coeffs->high_gain) >= 1e-6f && coeffs->cutoff * bw_sqrtf(coeffs->high_gain) <= 1e12f);
|
||||
@ -515,11 +520,11 @@ static inline float bw_hs1_process1(
|
||||
const bw_hs1_coeffs * BW_RESTRICT coeffs,
|
||||
bw_hs1_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(coeffs->high_gain) >= 1e-6f && coeffs->cutoff * bw_sqrtf(coeffs->high_gain) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -539,15 +544,15 @@ static inline void bw_hs1_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(coeffs->high_gain) >= 1e-6f && coeffs->cutoff * bw_sqrtf(coeffs->high_gain) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_hs1_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -568,18 +573,18 @@ static inline void bw_hs1_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(coeffs->high_gain) >= 1e-6f && coeffs->cutoff * bw_sqrtf(coeffs->high_gain) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -600,7 +605,7 @@ static inline void bw_hs1_process_multi(
|
||||
static inline void bw_hs1_set_cutoff(
|
||||
bw_hs1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -618,7 +623,7 @@ static inline void bw_hs1_set_cutoff(
|
||||
static inline void bw_hs1_set_prewarp_at_cutoff(
|
||||
bw_hs1_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_init);
|
||||
|
||||
@ -631,7 +636,7 @@ static inline void bw_hs1_set_prewarp_at_cutoff(
|
||||
static inline void bw_hs1_set_prewarp_freq(
|
||||
bw_hs1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -646,7 +651,7 @@ static inline void bw_hs1_set_prewarp_freq(
|
||||
static inline void bw_hs1_set_high_gain_lin(
|
||||
bw_hs1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -664,7 +669,7 @@ static inline void bw_hs1_set_high_gain_lin(
|
||||
static inline void bw_hs1_set_high_gain_dB(
|
||||
bw_hs1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -678,7 +683,7 @@ static inline void bw_hs1_set_high_gain_dB(
|
||||
|
||||
static inline char bw_hs1_coeffs_is_valid(
|
||||
const bw_hs1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_hs1_coeffs"))
|
||||
@ -702,17 +707,17 @@ static inline char bw_hs1_coeffs_is_valid(
|
||||
static inline char bw_hs1_state_is_valid(
|
||||
const bw_hs1_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_hs1_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_hs1_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_mm1_state_is_valid(coeffs ? &coeffs->mm1_coeffs : NULL, &state->mm1_state);
|
||||
return bw_mm1_state_is_valid(coeffs ? &coeffs->mm1_coeffs : BW_NULL, &state->mm1_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,13 +20,18 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_gain bw_math bw_mm2 bw_one_pole bw_svf }}}
|
||||
* description {{{
|
||||
* Second-order high shelf filter (12 dB/oct) with unitary DC gain.
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added <code>bw_hs2_reset_state_multi()</code> and updated C++
|
||||
@ -149,7 +154,7 @@ static inline void bw_hs2_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_hs2_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -316,8 +321,8 @@ static inline char bw_hs2_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_hs2_state`.
|
||||
@ -385,7 +390,7 @@ struct bw_hs2_state {
|
||||
|
||||
static inline void bw_hs2_init(
|
||||
bw_hs2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_mm2_init(&coeffs->mm2_coeffs);
|
||||
bw_mm2_set_prewarp_at_cutoff(&coeffs->mm2_coeffs, 0);
|
||||
@ -406,7 +411,7 @@ static inline void bw_hs2_init(
|
||||
static inline void bw_hs2_set_sample_rate(
|
||||
bw_hs2_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -438,7 +443,7 @@ static inline void bw_hs2_update_mm2_params(
|
||||
|
||||
static inline void bw_hs2_reset_coeffs(
|
||||
bw_hs2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_set_sample_rate);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) >= 1e-6f && coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) <= 1e12f);
|
||||
@ -459,10 +464,10 @@ static inline float bw_hs2_reset_state(
|
||||
const bw_hs2_coeffs * BW_RESTRICT coeffs,
|
||||
bw_hs2_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
const float y = bw_mm2_reset_state(&coeffs->mm2_coeffs, &state->mm2_state, x_0);
|
||||
@ -485,18 +490,18 @@ static inline void bw_hs2_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_hs2_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -505,12 +510,12 @@ static inline void bw_hs2_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_hs2_update_coeffs_ctrl(
|
||||
bw_hs2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) >= 1e-6f && coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) <= 1e12f);
|
||||
@ -524,7 +529,7 @@ static inline void bw_hs2_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_hs2_update_coeffs_audio(
|
||||
bw_hs2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) >= 1e-6f && coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) <= 1e12f);
|
||||
@ -539,11 +544,11 @@ static inline float bw_hs2_process1(
|
||||
const bw_hs2_coeffs * BW_RESTRICT coeffs,
|
||||
bw_hs2_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) >= 1e-6f && coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -563,15 +568,15 @@ static inline void bw_hs2_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) >= 1e-6f && coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_hs2_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -592,18 +597,18 @@ static inline void bw_hs2_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) >= 1e-6f && coeffs->cutoff * bw_sqrtf(bw_sqrtf(coeffs->high_gain)) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -624,7 +629,7 @@ static inline void bw_hs2_process_multi(
|
||||
static inline void bw_hs2_set_cutoff(
|
||||
bw_hs2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -645,7 +650,7 @@ static inline void bw_hs2_set_cutoff(
|
||||
static inline void bw_hs2_set_Q(
|
||||
bw_hs2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -660,7 +665,7 @@ static inline void bw_hs2_set_Q(
|
||||
static inline void bw_hs2_set_prewarp_at_cutoff(
|
||||
bw_hs2_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_init);
|
||||
|
||||
@ -673,7 +678,7 @@ static inline void bw_hs2_set_prewarp_at_cutoff(
|
||||
static inline void bw_hs2_set_prewarp_freq(
|
||||
bw_hs2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -688,7 +693,7 @@ static inline void bw_hs2_set_prewarp_freq(
|
||||
static inline void bw_hs2_set_high_gain_lin(
|
||||
bw_hs2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -709,7 +714,7 @@ static inline void bw_hs2_set_high_gain_lin(
|
||||
static inline void bw_hs2_set_high_gain_dB(
|
||||
bw_hs2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_hs2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_hs2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -723,7 +728,7 @@ static inline void bw_hs2_set_high_gain_dB(
|
||||
|
||||
static inline char bw_hs2_coeffs_is_valid(
|
||||
const bw_hs2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_hs2_coeffs"))
|
||||
@ -756,17 +761,17 @@ static inline char bw_hs2_coeffs_is_valid(
|
||||
static inline char bw_hs2_state_is_valid(
|
||||
const bw_hs2_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_hs2_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_hs2_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_mm2_state_is_valid(coeffs ? &coeffs->mm2_coeffs : NULL, &state->mm2_state);
|
||||
return bw_mm2_state_is_valid(coeffs ? &coeffs->mm2_coeffs : BW_NULL, &state->mm2_state);
|
||||
}
|
||||
|
||||
#undef BW_HS2_PARAM_CUTOFF
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_math bw_one_pole }}}
|
||||
* description {{{
|
||||
* First-order lowpass filter (6 dB/oct) with unitary DC gain.
|
||||
@ -30,6 +30,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Limited actual prewarping frequency to prevent instability.</li>
|
||||
@ -147,7 +152,7 @@ static inline void bw_lp1_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_lp1_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -261,8 +266,8 @@ static inline char bw_lp1_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_lp1_state`.
|
||||
@ -332,7 +337,7 @@ struct bw_lp1_state {
|
||||
|
||||
static inline void bw_lp1_init(
|
||||
bw_lp1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_one_pole_init(&coeffs->smooth_coeffs);
|
||||
bw_one_pole_set_tau(&coeffs->smooth_coeffs, 0.005f);
|
||||
@ -353,7 +358,7 @@ static inline void bw_lp1_init(
|
||||
static inline void bw_lp1_set_sample_rate(
|
||||
bw_lp1_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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(sample_rate) && sample_rate > 0.f);
|
||||
@ -394,7 +399,7 @@ static inline void bw_lp1_do_update_coeffs(
|
||||
|
||||
static inline void bw_lp1_reset_coeffs(
|
||||
bw_lp1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_set_sample_rate);
|
||||
|
||||
@ -414,10 +419,10 @@ static inline float bw_lp1_reset_state(
|
||||
const bw_lp1_coeffs * BW_RESTRICT coeffs,
|
||||
bw_lp1_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
(void)coeffs;
|
||||
@ -443,18 +448,18 @@ static inline void bw_lp1_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_lp1_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -463,12 +468,12 @@ static inline void bw_lp1_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_lp1_update_coeffs_ctrl(
|
||||
bw_lp1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -477,7 +482,7 @@ static inline void bw_lp1_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_lp1_update_coeffs_audio(
|
||||
bw_lp1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_reset_coeffs);
|
||||
|
||||
@ -491,10 +496,10 @@ static inline float bw_lp1_process1(
|
||||
const bw_lp1_coeffs * BW_RESTRICT coeffs,
|
||||
bw_lp1_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_lp1_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -517,14 +522,14 @@ static inline void bw_lp1_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_lp1_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
bw_lp1_update_coeffs_audio(coeffs);
|
||||
@ -544,17 +549,17 @@ static inline void bw_lp1_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -574,7 +579,7 @@ static inline void bw_lp1_process_multi(
|
||||
static inline void bw_lp1_set_cutoff(
|
||||
bw_lp1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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));
|
||||
@ -589,7 +594,7 @@ static inline void bw_lp1_set_cutoff(
|
||||
static inline void bw_lp1_set_prewarp_at_cutoff(
|
||||
bw_lp1_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_lp1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_lp1_coeffs_state_init);
|
||||
|
||||
@ -602,7 +607,7 @@ static inline void bw_lp1_set_prewarp_at_cutoff(
|
||||
static inline void bw_lp1_set_prewarp_freq(
|
||||
bw_lp1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_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));
|
||||
@ -616,7 +621,7 @@ static inline void bw_lp1_set_prewarp_freq(
|
||||
|
||||
static inline char bw_lp1_coeffs_is_valid(
|
||||
const bw_lp1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_lp1_coeffs"))
|
||||
@ -664,13 +669,13 @@ static inline char bw_lp1_coeffs_is_valid(
|
||||
static inline char bw_lp1_state_is_valid(
|
||||
const bw_lp1_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_lp1_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_lp1_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common bw_gain bw_lp1 bw_math bw_mm1 bw_one_pole }}}
|
||||
* description {{{
|
||||
* First-order low shelf filter (6 dB/oct) with gain asymptotically
|
||||
@ -28,6 +28,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>1.0.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added <code>bw_ls1_reset_state_multi()</code> and updated C++
|
||||
@ -148,7 +153,7 @@ static inline void bw_ls1_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_ls1_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -301,8 +306,8 @@ static inline char bw_ls1_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_ls1_state`.
|
||||
@ -363,7 +368,7 @@ struct bw_ls1_state {
|
||||
|
||||
static inline void bw_ls1_init(
|
||||
bw_ls1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_mm1_init(&coeffs->mm1_coeffs);
|
||||
bw_mm1_set_prewarp_at_cutoff(&coeffs->mm1_coeffs, 0);
|
||||
@ -386,7 +391,7 @@ static inline void bw_ls1_init(
|
||||
static inline void bw_ls1_set_sample_rate(
|
||||
bw_ls1_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -412,7 +417,7 @@ static inline void bw_ls1_update_mm1_params(
|
||||
|
||||
static inline void bw_ls1_reset_coeffs(
|
||||
bw_ls1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_set_sample_rate);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) <= 1e12f);
|
||||
@ -433,10 +438,10 @@ static inline float bw_ls1_reset_state(
|
||||
const bw_ls1_coeffs * BW_RESTRICT coeffs,
|
||||
bw_ls1_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
const float y = bw_mm1_reset_state(&coeffs->mm1_coeffs, &state->mm1_state, x_0);
|
||||
@ -459,18 +464,18 @@ static inline void bw_ls1_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_ls1_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -479,12 +484,12 @@ static inline void bw_ls1_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_ls1_update_coeffs_ctrl(
|
||||
bw_ls1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) <= 1e12f);
|
||||
@ -498,7 +503,7 @@ static inline void bw_ls1_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_ls1_update_coeffs_audio(
|
||||
bw_ls1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) <= 1e12f);
|
||||
@ -513,11 +518,11 @@ static inline float bw_ls1_process1(
|
||||
const bw_ls1_coeffs * BW_RESTRICT coeffs,
|
||||
bw_ls1_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -537,15 +542,15 @@ static inline void bw_ls1_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_ls1_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -566,18 +571,18 @@ static inline void bw_ls1_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain)) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -598,7 +603,7 @@ static inline void bw_ls1_process_multi(
|
||||
static inline void bw_ls1_set_cutoff(
|
||||
bw_ls1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -616,7 +621,7 @@ static inline void bw_ls1_set_cutoff(
|
||||
static inline void bw_ls1_set_prewarp_at_cutoff(
|
||||
bw_ls1_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_init);
|
||||
|
||||
@ -629,7 +634,7 @@ static inline void bw_ls1_set_prewarp_at_cutoff(
|
||||
static inline void bw_ls1_set_prewarp_freq(
|
||||
bw_ls1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -644,7 +649,7 @@ static inline void bw_ls1_set_prewarp_freq(
|
||||
static inline void bw_ls1_set_dc_gain_lin(
|
||||
bw_ls1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -662,7 +667,7 @@ static inline void bw_ls1_set_dc_gain_lin(
|
||||
static inline void bw_ls1_set_dc_gain_dB(
|
||||
bw_ls1_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls1_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls1_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -676,7 +681,7 @@ static inline void bw_ls1_set_dc_gain_dB(
|
||||
|
||||
static inline char bw_ls1_coeffs_is_valid(
|
||||
const bw_ls1_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_ls1_coeffs"))
|
||||
@ -700,17 +705,17 @@ static inline char bw_ls1_coeffs_is_valid(
|
||||
static inline char bw_ls1_state_is_valid(
|
||||
const bw_ls1_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_ls1_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_ls1_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_mm1_state_is_valid(coeffs ? &coeffs->mm1_coeffs : NULL, &state->mm1_state);
|
||||
return bw_mm1_state_is_valid(coeffs ? &coeffs->mm1_coeffs : BW_NULL, &state->mm1_state);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2022-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -30,6 +30,7 @@
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* <li>Fixed typos in documentation of
|
||||
* <code>bw_ls2_set_cutoff()</code>,
|
||||
* <code>bw_ls2_set_dc_gain_lin()</code>, and
|
||||
@ -158,7 +159,7 @@ static inline void bw_ls2_reset_state_multi(
|
||||
* array.
|
||||
*
|
||||
* The corresponding initial output values are written into the `y_0` array,
|
||||
* if not `NULL`.
|
||||
* if not `BW_NULL`.
|
||||
*
|
||||
* #### bw_ls2_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
@ -326,8 +327,8 @@ static inline char bw_ls2_state_is_valid(
|
||||
* 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`).
|
||||
* If `coeffs` is not `BW_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_ls2_state`.
|
||||
@ -395,7 +396,7 @@ struct bw_ls2_state {
|
||||
|
||||
static inline void bw_ls2_init(
|
||||
bw_ls2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
bw_mm2_init(&coeffs->mm2_coeffs);
|
||||
bw_mm2_set_prewarp_at_cutoff(&coeffs->mm2_coeffs, 0);
|
||||
@ -416,7 +417,7 @@ static inline void bw_ls2_init(
|
||||
static inline void bw_ls2_set_sample_rate(
|
||||
bw_ls2_coeffs * BW_RESTRICT coeffs,
|
||||
float sample_rate) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(sample_rate) && sample_rate > 0.f);
|
||||
@ -448,7 +449,7 @@ static inline void bw_ls2_update_mm2_params(
|
||||
|
||||
static inline void bw_ls2_reset_coeffs(
|
||||
bw_ls2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_set_sample_rate);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) <= 1e12f);
|
||||
@ -469,10 +470,10 @@ static inline float bw_ls2_reset_state(
|
||||
const bw_ls2_coeffs * BW_RESTRICT coeffs,
|
||||
bw_ls2_state * BW_RESTRICT state,
|
||||
float x_0) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT(bw_is_finite(x_0));
|
||||
|
||||
const float y = bw_mm2_reset_state(&coeffs->mm2_coeffs, &state->mm2_state, x_0);
|
||||
@ -495,18 +496,18 @@ static inline void bw_ls2_reset_state_multi(
|
||||
const float * x_0,
|
||||
float * y_0,
|
||||
size_t n_channels) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x_0 != NULL);
|
||||
BW_ASSERT(x_0 != BW_NULL);
|
||||
|
||||
if (y_0 != NULL)
|
||||
if (y_0 != BW_NULL)
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
y_0[i] = bw_ls2_reset_state(coeffs, state[i], x_0[i]);
|
||||
else
|
||||
@ -515,12 +516,12 @@ static inline void bw_ls2_reset_state_multi(
|
||||
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(y_0 != NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
BW_ASSERT_DEEP(y_0 != BW_NULL ? bw_has_only_finite(y_0, n_channels) : 1);
|
||||
}
|
||||
|
||||
static inline void bw_ls2_update_coeffs_ctrl(
|
||||
bw_ls2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) <= 1e12f);
|
||||
@ -534,7 +535,7 @@ static inline void bw_ls2_update_coeffs_ctrl(
|
||||
|
||||
static inline void bw_ls2_update_coeffs_audio(
|
||||
bw_ls2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) <= 1e12f);
|
||||
@ -549,11 +550,11 @@ static inline float bw_ls2_process1(
|
||||
const bw_ls2_coeffs * BW_RESTRICT coeffs,
|
||||
bw_ls2_state * BW_RESTRICT state,
|
||||
float x) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(bw_is_finite(x));
|
||||
|
||||
@ -573,15 +574,15 @@ static inline void bw_ls2_process(
|
||||
const float * x,
|
||||
float * y,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_state_is_valid(coeffs, state));
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_has_only_finite(x, n_samples));
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
|
||||
bw_ls2_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
@ -602,18 +603,18 @@ static inline void bw_ls2_process_multi(
|
||||
float * const * y,
|
||||
size_t n_channels,
|
||||
size_t n_samples) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_reset_coeffs);
|
||||
BW_ASSERT_DEEP(coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) >= 1e-6f && coeffs->cutoff * bw_rcpf(bw_sqrtf(bw_sqrtf(coeffs->dc_gain))) <= 1e12f);
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
BW_ASSERT(state[i] != state[j]);
|
||||
#endif
|
||||
BW_ASSERT(x != NULL);
|
||||
BW_ASSERT(y != NULL);
|
||||
BW_ASSERT(x != BW_NULL);
|
||||
BW_ASSERT(y != BW_NULL);
|
||||
#ifndef BW_NO_DEBUG
|
||||
for (size_t i = 0; i < n_channels; i++)
|
||||
for (size_t j = i + 1; j < n_channels; j++)
|
||||
@ -634,7 +635,7 @@ static inline void bw_ls2_process_multi(
|
||||
static inline void bw_ls2_set_cutoff(
|
||||
bw_ls2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -655,7 +656,7 @@ static inline void bw_ls2_set_cutoff(
|
||||
static inline void bw_ls2_set_Q(
|
||||
bw_ls2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -670,7 +671,7 @@ static inline void bw_ls2_set_Q(
|
||||
static inline void bw_ls2_set_prewarp_at_cutoff(
|
||||
bw_ls2_coeffs * BW_RESTRICT coeffs,
|
||||
char value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_init);
|
||||
|
||||
@ -683,7 +684,7 @@ static inline void bw_ls2_set_prewarp_at_cutoff(
|
||||
static inline void bw_ls2_set_prewarp_freq(
|
||||
bw_ls2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -698,7 +699,7 @@ static inline void bw_ls2_set_prewarp_freq(
|
||||
static inline void bw_ls2_set_dc_gain_lin(
|
||||
bw_ls2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -719,7 +720,7 @@ static inline void bw_ls2_set_dc_gain_lin(
|
||||
static inline void bw_ls2_set_dc_gain_dB(
|
||||
bw_ls2_coeffs * BW_RESTRICT coeffs,
|
||||
float value) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
BW_ASSERT_DEEP(bw_ls2_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_ls2_coeffs_state_init);
|
||||
BW_ASSERT(bw_is_finite(value));
|
||||
@ -733,7 +734,7 @@ static inline void bw_ls2_set_dc_gain_dB(
|
||||
|
||||
static inline char bw_ls2_coeffs_is_valid(
|
||||
const bw_ls2_coeffs * BW_RESTRICT coeffs) {
|
||||
BW_ASSERT(coeffs != NULL);
|
||||
BW_ASSERT(coeffs != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (coeffs->hash != bw_hash_sdbm("bw_ls2_coeffs"))
|
||||
@ -766,17 +767,17 @@ static inline char bw_ls2_coeffs_is_valid(
|
||||
static inline char bw_ls2_state_is_valid(
|
||||
const bw_ls2_coeffs * BW_RESTRICT coeffs,
|
||||
const bw_ls2_state * BW_RESTRICT state) {
|
||||
BW_ASSERT(state != NULL);
|
||||
BW_ASSERT(state != BW_NULL);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
if (state->hash != bw_hash_sdbm("bw_ls2_state"))
|
||||
return 0;
|
||||
|
||||
if (coeffs != NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
if (coeffs != BW_NULL && coeffs->reset_id != state->coeffs_reset_id)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return bw_mm2_state_is_valid(coeffs ? &coeffs->mm2_coeffs : NULL, &state->mm2_state);
|
||||
return bw_mm2_state_is_valid(coeffs ? &coeffs->mm2_coeffs : BW_NULL, &state->mm2_state);
|
||||
}
|
||||
|
||||
#undef BW_LS2_PARAM_CUTOFF
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2021-2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 2021-2024 Orastron Srl unipersonale
|
||||
*
|
||||
* Brickworks is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ utility }}}
|
||||
* version {{{ 1.0.0 }}}
|
||||
* version {{{ 1.0.1 }}}
|
||||
* requires {{{ bw_common }}}
|
||||
* description {{{
|
||||
* A collection of mathematical routines that strive to be better suited to
|
||||
@ -44,6 +44,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>1.0.1</strong>:
|
||||
* <ul>
|
||||
* <li>Now using <code>BW_NULL</code>.</li>
|
||||
* </ul>
|
||||