updated mem_req/set in bw_{delay,comb,chorus,reverb} and fxs + more reverb work
This commit is contained in:
parent
1b6cb5a029
commit
8136a09e72
@ -37,7 +37,7 @@ BW_SIZE_T bw_example_fx_chorus_mem_req(bw_example_fx_chorus *instance) {
|
||||
}
|
||||
|
||||
void bw_example_fx_chorus_mem_set(bw_example_fx_chorus *instance, void *mem) {
|
||||
bw_chorus_mem_set(&instance->chorus_state, mem);
|
||||
bw_chorus_mem_set(&instance->chorus_coeffs, &instance->chorus_state, mem);
|
||||
}
|
||||
|
||||
void bw_example_fx_chorus_reset(bw_example_fx_chorus *instance) {
|
||||
|
@ -33,7 +33,7 @@ BW_SIZE_T bw_example_fx_comb_mem_req(bw_example_fx_comb *instance) {
|
||||
}
|
||||
|
||||
void bw_example_fx_comb_mem_set(bw_example_fx_comb *instance, void *mem) {
|
||||
bw_comb_mem_set(&instance->comb_state, mem);
|
||||
bw_comb_mem_set(&instance->comb_coeffs, &instance->comb_state, mem);
|
||||
}
|
||||
|
||||
void bw_example_fx_comb_reset(bw_example_fx_comb *instance) {
|
||||
|
@ -33,7 +33,7 @@ BW_SIZE_T bw_example_fx_delay_mem_req(bw_example_fx_delay *instance) {
|
||||
}
|
||||
|
||||
void bw_example_fx_delay_mem_set(bw_example_fx_delay *instance, void *mem) {
|
||||
bw_delay_mem_set(&instance->delay_state, mem);
|
||||
bw_delay_mem_set(&instance->delay_coeffs, &instance->delay_state, mem);
|
||||
}
|
||||
|
||||
void bw_example_fx_delay_reset(bw_example_fx_delay *instance) {
|
||||
|
@ -37,7 +37,7 @@ BW_SIZE_T bw_example_fx_flanger_mem_req(bw_example_fx_flanger *instance) {
|
||||
}
|
||||
|
||||
void bw_example_fx_flanger_mem_set(bw_example_fx_flanger *instance, void *mem) {
|
||||
bw_chorus_mem_set(&instance->chorus_state, mem);
|
||||
bw_chorus_mem_set(&instance->chorus_coeffs, &instance->chorus_state, mem);
|
||||
}
|
||||
|
||||
void bw_example_fx_flanger_reset(bw_example_fx_flanger *instance) {
|
||||
|
@ -33,7 +33,7 @@ BW_SIZE_T bw_example_fx_reverb_mem_req(bw_example_fx_reverb *instance) {
|
||||
}
|
||||
|
||||
void bw_example_fx_reverb_mem_set(bw_example_fx_reverb *instance, void *mem) {
|
||||
bw_reverb_mem_set(&instance->reverb_state, mem);
|
||||
bw_reverb_mem_set(&instance->reverb_coeffs, &instance->reverb_state, mem);
|
||||
}
|
||||
|
||||
void bw_example_fx_reverb_reset(bw_example_fx_reverb *instance) {
|
||||
|
@ -38,6 +38,7 @@
|
||||
* <ul>
|
||||
* <li>Version <strong>0.5.0</strong>:
|
||||
* <ul>
|
||||
* <li>Updated mem_req/set API.</li>
|
||||
* <li>Now properly setting feedforward delay on reset.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
@ -87,14 +88,14 @@ static inline void bw_chorus_set_sample_rate(bw_chorus_coeffs *BW_RESTRICT coeff
|
||||
*
|
||||
* #### bw_chorus_mem_req()
|
||||
* ```>>> */
|
||||
static inline BW_SIZE_T bw_chorus_mem_req(bw_chorus_coeffs *BW_RESTRICT coeffs);
|
||||
static inline BW_SIZE_T bw_chorus_mem_req(const bw_chorus_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Returns the size, in bytes, of contiguous memory to be supplied to
|
||||
* `bw_chorus_mem_set()` using `coeffs`.
|
||||
*
|
||||
* #### bw_chorus_mem_set()
|
||||
* ```>>> */
|
||||
static inline void bw_chorus_mem_set(bw_chorus_state *BW_RESTRICT state, void *mem);
|
||||
static inline void bw_chorus_mem_set(const bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state *BW_RESTRICT state, void *mem);
|
||||
/*! <<<```
|
||||
* Associates the contiguous memory block `mem` to the given `state`.
|
||||
*
|
||||
@ -223,12 +224,13 @@ static inline void bw_chorus_set_sample_rate(bw_chorus_coeffs *BW_RESTRICT coeff
|
||||
bw_comb_set_sample_rate(&coeffs->comb_coeffs, sample_rate);
|
||||
}
|
||||
|
||||
static inline BW_SIZE_T bw_chorus_mem_req(bw_chorus_coeffs *BW_RESTRICT coeffs) {
|
||||
static inline BW_SIZE_T bw_chorus_mem_req(const bw_chorus_coeffs *BW_RESTRICT coeffs) {
|
||||
return bw_comb_mem_req(&coeffs->comb_coeffs);
|
||||
}
|
||||
|
||||
static inline void bw_chorus_mem_set(bw_chorus_state *BW_RESTRICT state, void *mem) {
|
||||
bw_comb_mem_set(&state->comb_state, mem);
|
||||
static inline void bw_chorus_mem_set(const bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state *BW_RESTRICT state, void *mem) {
|
||||
(void)coeffs;
|
||||
bw_comb_mem_set(&coeffs->comb_coeffs, &state->comb_state, mem);
|
||||
}
|
||||
|
||||
static inline void bw_chorus_reset_coeffs(bw_chorus_coeffs *BW_RESTRICT coeffs) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 2023 Orastron Srl unipersonale
|
||||
* Copyright (C) 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.4.0 }}}
|
||||
* version {{{ 0.5.0 }}}
|
||||
* requires {{{
|
||||
* bw_buf bw_common bw_config bw_delay bw_gain bw_math bw_one_pole
|
||||
* }}}
|
||||
@ -37,7 +37,14 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>0.5.0</strong>:
|
||||
* <ul>
|
||||
* <li>Updated mem_req/set API.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* </ul>
|
||||
* <li>Version <strong>0.4.0</strong>:
|
||||
* <ul>
|
||||
* <li>First release.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
@ -82,14 +89,14 @@ static inline void bw_comb_set_sample_rate(bw_comb_coeffs *BW_RESTRICT coeffs, f
|
||||
*
|
||||
* #### bw_comb_mem_req()
|
||||
* ```>>> */
|
||||
static inline BW_SIZE_T bw_comb_mem_req(bw_comb_coeffs *BW_RESTRICT coeffs);
|
||||
static inline BW_SIZE_T bw_comb_mem_req(const bw_comb_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Returns the size, in bytes, of contiguous memory to be supplied to
|
||||
* `bw_comb_mem_set()` using `coeffs`.
|
||||
*
|
||||
* #### bw_comb_mem_set()
|
||||
* ```>>> */
|
||||
static inline void bw_comb_mem_set(bw_comb_state *BW_RESTRICT state, void *mem);
|
||||
static inline void bw_comb_mem_set(const bw_comb_coeffs *BW_RESTRICT coeffs, bw_comb_state *BW_RESTRICT state, void *mem);
|
||||
/*! <<<```
|
||||
* Associates the contiguous memory block `mem` to the given `state`.
|
||||
*
|
||||
@ -235,12 +242,13 @@ static inline void bw_comb_set_sample_rate(bw_comb_coeffs *BW_RESTRICT coeffs, f
|
||||
coeffs->fs = sample_rate;
|
||||
}
|
||||
|
||||
static inline BW_SIZE_T bw_comb_mem_req(bw_comb_coeffs *BW_RESTRICT coeffs) {
|
||||
static inline BW_SIZE_T bw_comb_mem_req(const bw_comb_coeffs *BW_RESTRICT coeffs) {
|
||||
return bw_delay_mem_req(&coeffs->delay_coeffs);
|
||||
}
|
||||
|
||||
static inline void bw_comb_mem_set(bw_comb_state *BW_RESTRICT state, void *mem) {
|
||||
bw_delay_mem_set(&state->delay_state, mem);
|
||||
static inline void bw_comb_mem_set(const bw_comb_coeffs *BW_RESTRICT coeffs, bw_comb_state *BW_RESTRICT state, void *mem) {
|
||||
(void)coeffs;
|
||||
bw_delay_mem_set(&coeffs->delay_coeffs, &state->delay_state, mem);
|
||||
}
|
||||
|
||||
static inline void _bw_comb_do_update_coeffs(bw_comb_coeffs *BW_RESTRICT coeffs, char force) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 0.4.0 }}}
|
||||
* version {{{ 0.5.0 }}}
|
||||
* requires {{{ bw_buf bw_common bw_config bw_math }}}
|
||||
* description {{{
|
||||
* Interpolated delay line, not smoothed.
|
||||
@ -31,6 +31,11 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>0.5.0</strong>:
|
||||
* <ul>
|
||||
* <li>Updated mem_req/set API.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>0.4.0</strong>:
|
||||
* <ul>
|
||||
* <li>First release.</li>
|
||||
@ -77,14 +82,14 @@ static inline void bw_delay_set_sample_rate(bw_delay_coeffs *BW_RESTRICT coeffs,
|
||||
*
|
||||
* #### bw_delay_mem_req()
|
||||
* ```>>> */
|
||||
static inline BW_SIZE_T bw_delay_mem_req(bw_delay_coeffs *BW_RESTRICT coeffs);
|
||||
static inline BW_SIZE_T bw_delay_mem_req(const bw_delay_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Returns the size, in bytes, of contiguous memory to be supplied to
|
||||
* `bw_delay_mem_set()` using `coeffs`.
|
||||
*
|
||||
* #### bw_delay_mem_set()
|
||||
* ```>>> */
|
||||
static inline void bw_delay_mem_set(bw_delay_state *BW_RESTRICT state, void *mem);
|
||||
static inline void bw_delay_mem_set(const bw_delay_coeffs *BW_RESTRICT coeffs, bw_delay_state *BW_RESTRICT state, void *mem);
|
||||
/*! <<<```
|
||||
* Associates the contiguous memory block `mem` to the given `state`.
|
||||
*
|
||||
@ -195,11 +200,12 @@ static inline void bw_delay_set_sample_rate(bw_delay_coeffs *BW_RESTRICT coeffs,
|
||||
coeffs->len = (BW_SIZE_T)bw_ceilf(coeffs->fs * coeffs->max_delay) + 1;
|
||||
}
|
||||
|
||||
static inline BW_SIZE_T bw_delay_mem_req(bw_delay_coeffs *BW_RESTRICT coeffs) {
|
||||
static inline BW_SIZE_T bw_delay_mem_req(const bw_delay_coeffs *BW_RESTRICT coeffs) {
|
||||
return coeffs->len * sizeof(float);
|
||||
}
|
||||
|
||||
static inline void bw_delay_mem_set(bw_delay_state *BW_RESTRICT state, void *mem) {
|
||||
static inline void bw_delay_mem_set(const bw_delay_coeffs *BW_RESTRICT coeffs, bw_delay_state *BW_RESTRICT state, void *mem) {
|
||||
(void)coeffs;
|
||||
state->buf = (float *)mem;
|
||||
}
|
||||
|
||||
|
@ -80,14 +80,14 @@ static inline void bw_reverb_set_sample_rate(bw_reverb_coeffs *BW_RESTRICT coeff
|
||||
*
|
||||
* #### bw_reverb_mem_req()
|
||||
* ```>>> */
|
||||
static inline BW_SIZE_T bw_reverb_mem_req(bw_reverb_coeffs *BW_RESTRICT coeffs);
|
||||
static inline BW_SIZE_T bw_reverb_mem_req(const bw_reverb_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Returns the size, in bytes, of contiguous memory to be supplied to
|
||||
* `bw_reverb_mem_set()` using `coeffs`.
|
||||
*
|
||||
* #### bw_reverb_mem_set()
|
||||
* ```>>> */
|
||||
static inline void bw_reverb_mem_set(bw_reverb_state *BW_RESTRICT state, void *mem);
|
||||
static inline void bw_reverb_mem_set(const bw_reverb_coeffs *BW_RESTRICT coeffs, bw_reverb_state *BW_RESTRICT state, void *mem);
|
||||
/*! <<<```
|
||||
* Associates the contiguous memory block `mem` to the given `state`.
|
||||
*
|
||||
@ -227,6 +227,18 @@ struct _bw_reverb_coeffs {
|
||||
struct _bw_reverb_state {
|
||||
bw_delay_state predelay_state;
|
||||
bw_lp1_state bandwidth_state;
|
||||
bw_delay_state delay_id1_state;
|
||||
bw_delay_state delay_id2_state;
|
||||
bw_delay_state delay_id3_state;
|
||||
bw_delay_state delay_id4_state;
|
||||
bw_delay_state delay_dd1_state;
|
||||
bw_delay_state delay_dd2_state;
|
||||
bw_delay_state delay_dd3_state;
|
||||
bw_delay_state delay_dd4_state;
|
||||
bw_delay_state delay_d1_state;
|
||||
bw_delay_state delay_d2_state;
|
||||
bw_delay_state delay_d3_state;
|
||||
bw_delay_state delay_d4_state;
|
||||
};
|
||||
|
||||
static inline void bw_reverb_init(bw_reverb_coeffs *BW_RESTRICT coeffs) {
|
||||
@ -285,10 +297,9 @@ static inline void bw_reverb_set_sample_rate(bw_reverb_coeffs *BW_RESTRICT coeff
|
||||
coeffs->d2 = (BW_SIZE_T)bw_roundf(coeffs->fs * (3720.f / 29761.f));
|
||||
coeffs->d3 = (BW_SIZE_T)bw_roundf(coeffs->fs * (4217.f / 29761.f));
|
||||
coeffs->d4 = (BW_SIZE_T)bw_roundf(coeffs->fs * (3163.f / 29761.f));
|
||||
//set delay...
|
||||
}
|
||||
|
||||
static inline BW_SIZE_T bw_reverb_mem_req(bw_reverb_coeffs *BW_RESTRICT coeffs) {
|
||||
static inline BW_SIZE_T bw_reverb_mem_req(const bw_reverb_coeffs *BW_RESTRICT coeffs) {
|
||||
return bw_delay_mem_req(&coeffs->predelay_coeffs)
|
||||
+ bw_delay_mem_req(&coeffs->delay_id1_coeffs)
|
||||
+ bw_delay_mem_req(&coeffs->delay_id2_coeffs)
|
||||
@ -304,32 +315,33 @@ static inline BW_SIZE_T bw_reverb_mem_req(bw_reverb_coeffs *BW_RESTRICT coeffs)
|
||||
+ bw_delay_mem_req(&coeffs->delay_d4_coeffs);
|
||||
}
|
||||
|
||||
static inline void bw_reverb_mem_set(bw_reverb_state *BW_RESTRICT state, void *mem) {
|
||||
bw_delay_mem_set(&state->predelay_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->predelay_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_id1_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->delay_id1_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_id2_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->delay_id2_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_id3_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->delay_id3_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_id4_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->delay_id4_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_dd1_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->delay_dd1_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_dd2_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->delay_dd2_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_dd3_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->delay_dd3_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_dd4_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->delay_dd4_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_d1_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->delay_d1_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_d2_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->delay_d2_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_d3_state, mem);
|
||||
mem += bw_delay_mem_req(&coeffs->delay_d3_coeffs) * sizeof(float);
|
||||
bw_delay_mem_set(&state->delay_d4_state, mem);
|
||||
static inline void bw_reverb_mem_set(const bw_reverb_coeffs *BW_RESTRICT coeffs, bw_reverb_state *BW_RESTRICT state, void *mem) {
|
||||
float *m = (float *)mem;
|
||||
bw_delay_mem_set(&coeffs->predelay_coeffs, &state->predelay_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->predelay_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_id1_coeffs, &state->delay_id1_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->delay_id1_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_id2_coeffs, &state->delay_id2_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->delay_id2_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_id3_coeffs, &state->delay_id3_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->delay_id3_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_id4_coeffs, &state->delay_id4_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->delay_id4_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_dd1_coeffs, &state->delay_dd1_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->delay_dd1_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_dd2_coeffs, &state->delay_dd2_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->delay_dd2_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_dd3_coeffs, &state->delay_dd3_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->delay_dd3_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_dd4_coeffs, &state->delay_dd4_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->delay_dd4_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_d1_coeffs, &state->delay_d1_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->delay_d1_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_d2_coeffs, &state->delay_d2_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->delay_d2_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_d3_coeffs, &state->delay_d3_state, m);
|
||||
m += bw_delay_mem_req(&coeffs->delay_d3_coeffs);
|
||||
bw_delay_mem_set(&coeffs->delay_d4_coeffs, &state->delay_d4_state, m);
|
||||
}
|
||||
|
||||
static inline void bw_reverb_reset_coeffs(bw_reverb_coeffs *BW_RESTRICT coeffs) {
|
||||
@ -382,16 +394,19 @@ static inline void bw_reverb_update_coeffs_audio(bw_reverb_coeffs *BW_RESTRICT c
|
||||
bw_delay_set_delay(&coeffs->predelay_coeffs, pd);
|
||||
bw_delay_update_coeffs_ctrl(&coeffs->predelay_coeffs);
|
||||
bw_delay_update_coeffs_audio(&coeffs->predelay_coeffs);
|
||||
//...
|
||||
}
|
||||
|
||||
static inline void bw_reverb_process1(const bw_reverb_coeffs *BW_RESTRICT coeffs, bw_reverb_state *BW_RESTRICT state, float xl, float xr, float *yl, float *yr) {
|
||||
const float i = 0.5f * (xl + xr);
|
||||
const float pd = bw_delay_process1(&coeffs->predelay_coeffs, &state->predelay_state, i);
|
||||
const float bw = bw_lp1_process1(&coeffs->bandwidth_coeffs, &state->bandwidth_state, pd);
|
||||
const float n14 = bw_delay_read(&coeffs->delay_id1_coeffs, &state->delay_id1_state, coeffs->id1, 0.f);
|
||||
const float n13 = bw - 0.75f * n14;
|
||||
const float id1 = 0.75f * n13 + n14;
|
||||
bw_delay_write(&coeffs->delay_id1_coeffs, &state->delay_id1_state, n13);
|
||||
//...
|
||||
*yl = bw_drywet_process1(&coeffs->drywet_coeffs, xl, bw);
|
||||
*yr = bw_drywet_process1(&coeffs->drywet_coeffs, xr, bw);
|
||||
*yl = bw_drywet_process1(&coeffs->drywet_coeffs, xl, id1);
|
||||
*yr = bw_drywet_process1(&coeffs->drywet_coeffs, xr, id1);
|
||||
}
|
||||
|
||||
static inline void bw_reverb_process(bw_reverb_coeffs *BW_RESTRICT coeffs, bw_reverb_state *BW_RESTRICT state, const float *xl, const float *xr, float *yl, float *yr, int n_samples) {
|
||||
|
Loading…
Reference in New Issue
Block a user