added x0 to reset_state in bw_{lp1,ap1,hp1,hs1,ls1,mm1}, adjusted bw_phaser and examples

This commit is contained in:
Stefano D'Angelo 2023-04-19 08:33:18 +02:00
parent b741611b26
commit b91a0f8e54
12 changed files with 74 additions and 42 deletions

View File

@ -30,7 +30,7 @@ void bw_example_fx_ap1_set_sample_rate(bw_example_fx_ap1 *instance, float sample
void bw_example_fx_ap1_reset(bw_example_fx_ap1 *instance) {
bw_ap1_reset_coeffs(&instance->ap1_coeffs);
bw_ap1_reset_state(&instance->ap1_coeffs, &instance->ap1_state);
bw_ap1_reset_state(&instance->ap1_coeffs, &instance->ap1_state, 0.f);
}
void bw_example_fx_ap1_process(bw_example_fx_ap1 *instance, const float** x, float** y, int n_samples) {

View File

@ -30,7 +30,7 @@ void bw_example_fx_hp1_set_sample_rate(bw_example_fx_hp1 *instance, float sample
void bw_example_fx_hp1_reset(bw_example_fx_hp1 *instance) {
bw_hp1_reset_coeffs(&instance->hp1_coeffs);
bw_hp1_reset_state(&instance->hp1_coeffs, &instance->hp1_state);
bw_hp1_reset_state(&instance->hp1_coeffs, &instance->hp1_state, 0.f);
}
void bw_example_fx_hp1_process(bw_example_fx_hp1 *instance, const float** x, float** y, int n_samples) {

View File

@ -30,7 +30,7 @@ void bw_example_fx_hs1_set_sample_rate(bw_example_fx_hs1 *instance, float sample
void bw_example_fx_hs1_reset(bw_example_fx_hs1 *instance) {
bw_hs1_reset_coeffs(&instance->hs1_coeffs);
bw_hs1_reset_state(&instance->hs1_coeffs, &instance->hs1_state);
bw_hs1_reset_state(&instance->hs1_coeffs, &instance->hs1_state, 0.f);
}
void bw_example_fx_hs1_process(bw_example_fx_hs1 *instance, const float** x, float** y, int n_samples) {

View File

@ -30,7 +30,7 @@ void bw_example_fx_ls1_set_sample_rate(bw_example_fx_ls1 *instance, float sample
void bw_example_fx_ls1_reset(bw_example_fx_ls1 *instance) {
bw_ls1_reset_coeffs(&instance->ls1_coeffs);
bw_ls1_reset_state(&instance->ls1_coeffs, &instance->ls1_state);
bw_ls1_reset_state(&instance->ls1_coeffs, &instance->ls1_state, 0.f);
}
void bw_example_fx_ls1_process(bw_example_fx_ls1 *instance, const float** x, float** y, int n_samples) {

View File

@ -30,7 +30,7 @@ void bw_example_fx_mm1_set_sample_rate(bw_example_fx_mm1 *instance, float sample
void bw_example_fx_mm1_reset(bw_example_fx_mm1 *instance) {
bw_mm1_reset_coeffs(&instance->mm1_coeffs);
bw_mm1_reset_state(&instance->mm1_coeffs, &instance->mm1_state);
bw_mm1_reset_state(&instance->mm1_coeffs, &instance->mm1_state, 0.f);
}
void bw_example_fx_mm1_process(bw_example_fx_mm1 *instance, const float** x, float** y, int n_samples) {

View File

@ -1,7 +1,7 @@
/*
* Brickworks
*
* Copyright (C) 2022 Orastron Srl unipersonale
* Copyright (C) 2022, 2023 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 {{{ 0.3.0 }}}
* version {{{ 0.4.0 }}}
* requires {{{ bw_config 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>0.4.0</strong>:
* <ul>
* <li>Added initial input value to `bw_ap1_reset_state()`.</li>
* </ul>
* </li>
* <li>Version <strong>0.3.0</strong>:
* <ul>
* <li>First release.</li>
@ -79,9 +84,10 @@ static inline void bw_ap1_reset_coeffs(bw_ap1_coeffs *BW_RESTRICT coeffs);
*
* #### bw_ap1_reset_state()
* ```>>> */
static inline void bw_ap1_reset_state(const bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_state *BW_RESTRICT state);
static inline void bw_ap1_reset_state(const bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_state *BW_RESTRICT state, float x0);
/*! <<<```
* Resets the given `state` to its initial values using the given `coeffs`.
* Resets the given `state` to its initial values using the given `coeffs`
* and the quiescent/initial input value `x0`.
*
* #### bw_ap1_update_coeffs_ctrl()
* ```>>> */
@ -147,8 +153,8 @@ static inline void bw_ap1_reset_coeffs(bw_ap1_coeffs *BW_RESTRICT coeffs) {
bw_lp1_reset_coeffs(&coeffs->lp1_coeffs);
}
static inline void bw_ap1_reset_state(const bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_state *BW_RESTRICT state) {
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state);
static inline void bw_ap1_reset_state(const bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_state *BW_RESTRICT state, float x0) {
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x0);
}
static inline void bw_ap1_update_coeffs_ctrl(bw_ap1_coeffs *BW_RESTRICT coeffs) {

View File

@ -1,7 +1,7 @@
/*
* Brickworks
*
* Copyright (C) 2022 Orastron Srl unipersonale
* Copyright (C) 2022, 2023 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 {{{ 0.3.0 }}}
* version {{{ 0.4.0 }}}
* requires {{{ bw_config 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>0.4.0</strong>:
* <ul>
* <li>Added initial input value to `bw_hp1_reset_state()`.</li>
* </ul>
* </li>
* <li>Version <strong>0.3.0</strong>:
* <ul>
* <li>First release.</li>
@ -79,9 +84,10 @@ static inline void bw_hp1_reset_coeffs(bw_hp1_coeffs *BW_RESTRICT coeffs);
*
* #### bw_hp1_reset_state()
* ```>>> */
static inline void bw_hp1_reset_state(const bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_state *BW_RESTRICT state);
static inline void bw_hp1_reset_state(const bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_state *BW_RESTRICT state, float x0);
/*! <<<```
* Resets the given `state` to its initial values using the given `coeffs`.
* Resets the given `state` to its initial values using the given `coeffs`
* and the quiescent/initial input value `x0`.
*
* #### bw_hp1_update_coeffs_ctrl()
* ```>>> */
@ -147,8 +153,8 @@ static inline void bw_hp1_reset_coeffs(bw_hp1_coeffs *BW_RESTRICT coeffs) {
bw_lp1_reset_coeffs(&coeffs->lp1_coeffs);
}
static inline void bw_hp1_reset_state(const bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_state *BW_RESTRICT state) {
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state);
static inline void bw_hp1_reset_state(const bw_hp1_coeffs *BW_RESTRICT coeffs, bw_hp1_state *BW_RESTRICT state, float x0) {
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x0);
}
static inline void bw_hp1_update_coeffs_ctrl(bw_hp1_coeffs *BW_RESTRICT coeffs) {

View File

@ -1,7 +1,7 @@
/*
* Brickworks
*
* Copyright (C) 2022 Orastron Srl unipersonale
* Copyright (C) 2022, 2023 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 {{{ 0.3.0 }}}
* version {{{ 0.4.0 }}}
* requires {{{
* bw_config bw_common bw_gain bw_lp1 bw_math bw_mm1 bw_one_pole
* }}}
@ -29,6 +29,11 @@
* }}}
* changelog {{{
* <ul>
* <li>Version <strong>0.4.0</strong>:
* <ul>
* <li>Added initial input value to `bw_hs1_reset_state()`.</li>
* </ul>
* </li>
* <li>Version <strong>0.3.0</strong>:
* <ul>
* <li>First release.</li>
@ -80,9 +85,10 @@ static inline void bw_hs1_reset_coeffs(bw_hs1_coeffs *BW_RESTRICT coeffs);
*
* #### bw_hs1_reset_state()
* ```>>> */
static inline void bw_hs1_reset_state(const bw_hs1_coeffs *BW_RESTRICT coeffs, bw_hs1_state *BW_RESTRICT state);
static inline void bw_hs1_reset_state(const bw_hs1_coeffs *BW_RESTRICT coeffs, bw_hs1_state *BW_RESTRICT state, float x0);
/*! <<<```
* Resets the given `state` to its initial values using the given `coeffs`.
* Resets the given `state` to its initial values using the given `coeffs`
* and the quiescent/initial input value `x0`.
*
* #### bw_hs1_update_coeffs_ctrl()
* ```>>> */
@ -190,8 +196,8 @@ static inline void bw_hs1_reset_coeffs(bw_hs1_coeffs *BW_RESTRICT coeffs) {
bw_mm1_reset_coeffs(&coeffs->mm1_coeffs);
}
static inline void bw_hs1_reset_state(const bw_hs1_coeffs *BW_RESTRICT coeffs, bw_hs1_state *BW_RESTRICT state) {
bw_mm1_reset_state(&coeffs->mm1_coeffs, &state->mm1_state);
static inline void bw_hs1_reset_state(const bw_hs1_coeffs *BW_RESTRICT coeffs, bw_hs1_state *BW_RESTRICT state, float x0) {
bw_mm1_reset_state(&coeffs->mm1_coeffs, &state->mm1_state, x0);
}
static inline void bw_hs1_update_coeffs_ctrl(bw_hs1_coeffs *BW_RESTRICT coeffs) {

View File

@ -32,6 +32,7 @@
* <ul>
* <li>Version <strong>0.4.0</strong>:
* <ul>
* <li>Added initial input value to `bw_lp1_reset_state()`.</li>
* <li>Fixed unused parameter warnings.</li>
* </ul>
* </li>
@ -86,9 +87,10 @@ static inline void bw_lp1_reset_coeffs(bw_lp1_coeffs *BW_RESTRICT coeffs);
*
* #### bw_lp1_reset_state()
* ```>>> */
static inline void bw_lp1_reset_state(const bw_lp1_coeffs *BW_RESTRICT coeffs, bw_lp1_state *BW_RESTRICT state);
static inline void bw_lp1_reset_state(const bw_lp1_coeffs *BW_RESTRICT coeffs, bw_lp1_state *BW_RESTRICT state, float x0);
/*! <<<```
* Resets the given `state` to its initial values using the given `coeffs`.
* Resets the given `state` to its initial values using the given `coeffs`
* and the quiescent/initial input value `x0`.
*
* #### bw_lp1_update_coeffs_ctrl()
* ```>>> */
@ -220,9 +222,9 @@ static inline void bw_lp1_reset_coeffs(bw_lp1_coeffs *BW_RESTRICT coeffs) {
_bw_lp1_do_update_coeffs(coeffs, 1);
}
static inline void bw_lp1_reset_state(const bw_lp1_coeffs *BW_RESTRICT coeffs, bw_lp1_state *BW_RESTRICT state) {
static inline void bw_lp1_reset_state(const bw_lp1_coeffs *BW_RESTRICT coeffs, bw_lp1_state *BW_RESTRICT state, float x0) {
(void)coeffs;
state->y_z1 = 0.f;
state->y_z1 = x0;
state->X_z1 = 0.f;
}

View File

@ -1,7 +1,7 @@
/*
* Brickworks
*
* Copyright (C) 2022 Orastron Srl unipersonale
* Copyright (C) 2022, 2023 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 {{{ 0.3.0 }}}
* version {{{ 0.4.0 }}}
* requires {{{
* bw_config bw_common bw_gain bw_lp1 bw_math bw_mm1 bw_one_pole
* }}}
@ -30,6 +30,11 @@
* }}}
* changelog {{{
* <ul>
* <li>Version <strong>0.4.0</strong>:
* <ul>
* <li>Added initial input value to `bw_ls1_reset_state()`.</li>
* </ul>
* </li>
* <li>Version <strong>0.3.0</strong>:
* <ul>
* <li>First release.</li>
@ -81,9 +86,10 @@ static inline void bw_ls1_reset_coeffs(bw_ls1_coeffs *BW_RESTRICT coeffs);
*
* #### bw_ls1_reset_state()
* ```>>> */
static inline void bw_ls1_reset_state(const bw_ls1_coeffs *BW_RESTRICT coeffs, bw_ls1_state *BW_RESTRICT state);
static inline void bw_ls1_reset_state(const bw_ls1_coeffs *BW_RESTRICT coeffs, bw_ls1_state *BW_RESTRICT state, float x0);
/*! <<<```
* Resets the given `state` to its initial values using the given `coeffs`.
* Resets the given `state` to its initial values using the given `coeffs`
* and the quiescent/initial input value `x0`.
*
* #### bw_ls1_update_coeffs_ctrl()
* ```>>> */
@ -187,8 +193,8 @@ static inline void bw_ls1_reset_coeffs(bw_ls1_coeffs *BW_RESTRICT coeffs) {
bw_mm1_reset_coeffs(&coeffs->mm1_coeffs);
}
static inline void bw_ls1_reset_state(const bw_ls1_coeffs *BW_RESTRICT coeffs, bw_ls1_state *BW_RESTRICT state) {
bw_mm1_reset_state(&coeffs->mm1_coeffs, &state->mm1_state);
static inline void bw_ls1_reset_state(const bw_ls1_coeffs *BW_RESTRICT coeffs, bw_ls1_state *BW_RESTRICT state, float x0) {
bw_mm1_reset_state(&coeffs->mm1_coeffs, &state->mm1_state, x0);
}
static inline void bw_ls1_update_coeffs_ctrl(bw_ls1_coeffs *BW_RESTRICT coeffs) {

View File

@ -20,13 +20,18 @@
/*!
* module_type {{{ dsp }}}
* version {{{ 0.3.0 }}}
* version {{{ 0.4.0 }}}
* requires {{{ bw_config bw_common bw_gain bw_lp1 bw_math bw_one_pole }}}
* description {{{
* First-order multimode filter.
* }}}
* changelog {{{
* <ul>
* <li>Version <strong>0.4.0</strong>:
* <ul>
* <li>Added initial input value to `bw_mm1_reset_state()`.</li>
* </ul>
* </li>
* <li>Version <strong>0.3.0</strong>:
* <ul>
* <li>First release.</li>
@ -78,9 +83,10 @@ static inline void bw_mm1_reset_coeffs(bw_mm1_coeffs *BW_RESTRICT coeffs);
*
* #### bw_mm1_reset_state()
* ```>>> */
static inline void bw_mm1_reset_state(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state);
static inline void bw_mm1_reset_state(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, float x0);
/*! <<<```
* Resets the given `state` to its initial values using the given `coeffs`.
* Resets the given `state` to its initial values using the given `coeffs`
* and the quiescent/initial input value `x0`.
*
* #### bw_mm1_update_coeffs_ctrl()
* ```>>> */
@ -194,8 +200,8 @@ static inline void bw_mm1_reset_coeffs(bw_mm1_coeffs *BW_RESTRICT coeffs) {
bw_gain_reset_coeffs(&coeffs->gain_lp_coeffs);
}
static inline void bw_mm1_reset_state(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state) {
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state);
static inline void bw_mm1_reset_state(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, float x0) {
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x0);
}
static inline void bw_mm1_update_coeffs_ctrl(bw_mm1_coeffs *BW_RESTRICT coeffs) {

View File

@ -186,10 +186,10 @@ static inline void bw_phaser_reset_coeffs(bw_phaser_coeffs *BW_RESTRICT coeffs)
}
static inline void bw_phaser_reset_state(const bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state *BW_RESTRICT state) {
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[0]);
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[1]);
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[2]);
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[3]);
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[0], 0.f);
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[1], 0.f);
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[2], 0.f);
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[3], 0.f);
}
static inline void bw_phaser_update_coeffs_ctrl(bw_phaser_coeffs *BW_RESTRICT coeffs) {