wip on many modules, all is broken, all is good

This commit is contained in:
Stefano D'Angelo 2023-08-20 15:49:04 +02:00
parent fe02a79329
commit 6c29b1f0cd
13 changed files with 435 additions and 198 deletions

33
TODO
View File

@ -1,33 +1,34 @@
1.0.0
-----
in progress:
* add initial state (x0) to reset state of all modules
* check assumptions w.r.t. usage of math functions
* empty functions etc. to keep consistency and forward compatibility?
* format declarations in a more readable way
code:
* debugging - also check outputs different (incl bw_buf)
* check all examples again
general:
* mem req -> return value of set sample rate? or sample rate argument of mem req?
* c++ get coeffs/state? or public? src nIn/OutSamples case (array vs single value), delay read/write, process1? process single?
* common smoothing policy (as control rate as possible?) - smoothing control?
* check unititialized warnings (check fxpp_comp in particular vs fxpp_satur)
semi-specific:
* osc post filter (and one pole init, slew rate, etc.) val from input? set state instead?
* audio rate optional pulse width/slope inputs?
* empty functions etc. to keep consistency and forward compatibility?
* common smoothing policy (as control rate as possible?) - smoothing control?
* max_delay -> set sample rate? see reverb
specific:
* svf bandpass out polarity too confusing (inverted in mm2)?
* get_y_z1, common strategy?
* add initial state (x0) to reset state of all modules?
* bw_comb: should also modulate feedback?
* bw_comb: integer target delay values?
* bw_svf/lp1 automatically limited (max) prewarp frequency to avoid instability?
* prewarp control in all derived filtering modules
* src inside distortions? w/ control from outside?
* max_delay -> set sample rate? see reverb
* mem req -> return value of set sample rate?
* peak gain + Q ???
* sr_reduce reset_coeffs? update_coeffs? process_multi?
* better src filter
* c++ get coeffs/state? or public? src nIn/OutSamples case (array vs single value), delay read/write, process1? process single?
* check unititialized warnings (check fxpp_comp in particular vs fxpp_satur)
finally:
* debugging - also check outputs different (incl bw_buf)
* check all examples again
* clearly specify that state is tied to a particular set of coeffs (1:N)
* modulation vs process (multi) no update (post 1.0.0)???
* check assumptions w.r.t. usage of math functions
* sample rate-constant coeffs? (pan case)
* sr-dependent vs cr-dependent coeffs? see synth poly example
* thank scientific paper authors
build system:
@ -67,6 +68,8 @@ code:
* float in [0,1] or [-1,1] for velocity, pitch bend, mod wheel in examples
* bw_satur gain compensation, divide by actual gain (derivative) mode? what about around flat line? bw_clip?
* gain compensation in distortions?
* sr-dependent vs cr-dependent coeffs? see synth poly example and pan case
* modulation vs process (multi) no update (post 1.0.0)???
build system:
* make makefiles handle paths with spaces etc

View File

@ -38,7 +38,7 @@ void bw_example_fx_delay_mem_set(bw_example_fx_delay *instance, void *mem) {
void bw_example_fx_delay_reset(bw_example_fx_delay *instance) {
bw_delay_reset_coeffs(&instance->delay_coeffs);
bw_delay_reset_state(&instance->delay_coeffs, &instance->delay_state);
bw_delay_reset_state(&instance->delay_coeffs, &instance->delay_state, 0.f);
}
void bw_example_fx_delay_process(bw_example_fx_delay *instance, const float** x, float** y, int n_samples) {

View File

@ -30,6 +30,8 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Added overladed C++ <code>reset()</code> functions taking arrays
* as arguments.</li>
* <li><code>bw_ap1_process()</code> and
* <code>bw_ap1_process_multi()</code> now use <code>size_t</code>
* to count samples and channels.</li>
@ -93,51 +95,69 @@ typedef struct bw_ap1_state bw_ap1_state;
*
* #### bw_ap1_init()
* ```>>> */
static inline void bw_ap1_init(bw_ap1_coeffs *BW_RESTRICT coeffs);
static inline void bw_ap1_init(
bw_ap1_coeffs *BW_RESTRICT coeffs);
/*! <<<```
* Initializes input parameter values in `coeffs`.
*
* #### bw_ap1_set_sample_rate()
* ```>>> */
static inline void bw_ap1_set_sample_rate(bw_ap1_coeffs *BW_RESTRICT coeffs, float sample_rate);
static inline void bw_ap1_set_sample_rate(
bw_ap1_coeffs *BW_RESTRICT coeffs,
float sample_rate);
/*! <<<```
* Sets the `sample_rate` (Hz) value in `coeffs`.
*
* #### bw_ap1_reset_coeffs()
* ```>>> */
static inline void bw_ap1_reset_coeffs(bw_ap1_coeffs *BW_RESTRICT coeffs);
static inline void bw_ap1_reset_coeffs(
bw_ap1_coeffs *BW_RESTRICT coeffs);
/*! <<<```
* Resets coefficients in `coeffs` to assume their target values.
*
* #### bw_ap1_reset_state()
* ```>>> */
static inline void bw_ap1_reset_state(const bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_state *BW_RESTRICT state, float x_0);
static inline float bw_ap1_reset_state(
const bw_ap1_coeffs *BW_RESTRICT coeffs,
bw_ap1_state *BW_RESTRICT state,
float x_0);
/*! <<<```
* Resets the given `state` to its initial values using the given `coeffs`
* and the quiescent/initial input value `x_0`.
* and the quiescent/initial input value `x_0`. Returns the corresponding
* quiescent/initial output value.
*
* #### bw_ap1_update_coeffs_ctrl()
* ```>>> */
static inline void bw_ap1_update_coeffs_ctrl(bw_ap1_coeffs *BW_RESTRICT coeffs);
static inline void bw_ap1_update_coeffs_ctrl(
bw_ap1_coeffs *BW_RESTRICT coeffs);
/*! <<<```
* Triggers control-rate update of coefficients in `coeffs`.
*
* #### bw_ap1_update_coeffs_audio()
* ```>>> */
static inline void bw_ap1_update_coeffs_audio(bw_ap1_coeffs *BW_RESTRICT coeffs);
static inline void bw_ap1_update_coeffs_audio(
bw_ap1_coeffs *BW_RESTRICT coeffs);
/*! <<<```
* Triggers audio-rate update of coefficients in `coeffs`.
*
* #### bw_ap1_process1()
* ```>>> */
static inline float bw_ap1_process1(const bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_state *BW_RESTRICT state, float x);
static inline float bw_ap1_process1(
const bw_ap1_coeffs *BW_RESTRICT coeffs,
bw_ap1_state *BW_RESTRICT state,
float x);
/*! <<<```
* Processes one input sample `x` using `coeffs`, while using and updating
* `state`. Returns the corresponding output sample.
*
* #### bw_ap1_process()
* ```>>> */
static inline void bw_ap1_process(bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples);
static inline void bw_ap1_process(
bw_ap1_coeffs *BW_RESTRICT coeffs,
bw_ap1_state *BW_RESTRICT state,
const float * x,
float * y,
size_t n_samples);
/*! <<<```
* Processes the first `n_samples` of the input buffer `x` and fills the
* first `n_samples` of the output buffer `y`, while using and updating both
@ -145,7 +165,13 @@ static inline void bw_ap1_process(bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_stat
*
* #### bw_ap1_process_multi()
* ```>>> */
static inline void bw_ap1_process_multi(bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t n_channels, size_t n_samples);
static inline void bw_ap1_process_multi(
bw_ap1_coeffs *BW_RESTRICT coeffs,
bw_ap1_state *BW_RESTRICT const *BW_RESTRICT state,
const float * const * x,
float * const * y,
size_t n_channels,
size_t n_samples);
/*! <<<```
* Processes the first `n_samples` of the `n_channels` input buffers `x` and
* fills the first `n_samples` of the `n_channels` output buffers `y`, while
@ -154,7 +180,9 @@ static inline void bw_ap1_process_multi(bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap
*
* #### bw_ap1_set_cutoff()
* ```>>> */
static inline void bw_ap1_set_cutoff(bw_ap1_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_ap1_set_cutoff(
bw_ap1_coeffs *BW_RESTRICT coeffs,
float value);
/*! <<<```
* Sets the cutoff frequency `value` (Hz) in `coeffs`.
*
@ -185,36 +213,54 @@ struct bw_ap1_state {
bw_lp1_state lp1_state;
};
static inline void bw_ap1_init(bw_ap1_coeffs *BW_RESTRICT coeffs) {
static inline void bw_ap1_init(
bw_ap1_coeffs *BW_RESTRICT coeffs) {
bw_lp1_init(&coeffs->lp1_coeffs);
}
static inline void bw_ap1_set_sample_rate(bw_ap1_coeffs *BW_RESTRICT coeffs, float sample_rate) {
static inline void bw_ap1_set_sample_rate(
bw_ap1_coeffs *BW_RESTRICT coeffs,
float sample_rate) {
bw_lp1_set_sample_rate(&coeffs->lp1_coeffs, sample_rate);
}
static inline void bw_ap1_reset_coeffs(bw_ap1_coeffs *BW_RESTRICT coeffs) {
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, float x_0) {
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
static inline float bw_ap1_reset_state(
const bw_ap1_coeffs *BW_RESTRICT coeffs,
bw_ap1_state *BW_RESTRICT state,
float x_0) {
const float lp = bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
return x_0 - lp - lp;
}
static inline void bw_ap1_update_coeffs_ctrl(bw_ap1_coeffs *BW_RESTRICT coeffs) {
static inline void bw_ap1_update_coeffs_ctrl(
bw_ap1_coeffs *BW_RESTRICT coeffs) {
bw_lp1_update_coeffs_ctrl(&coeffs->lp1_coeffs);
}
static inline void bw_ap1_update_coeffs_audio(bw_ap1_coeffs *BW_RESTRICT coeffs) {
static inline void bw_ap1_update_coeffs_audio(
bw_ap1_coeffs *BW_RESTRICT coeffs) {
bw_lp1_update_coeffs_audio(&coeffs->lp1_coeffs);
}
static inline float bw_ap1_process1(const bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_state *BW_RESTRICT state, float x) {
static inline float bw_ap1_process1(
const bw_ap1_coeffs *BW_RESTRICT coeffs,
bw_ap1_state *BW_RESTRICT state,
float x) {
const float lp = bw_lp1_process1(&coeffs->lp1_coeffs, &state->lp1_state, x);
return x - lp - lp;
}
static inline void bw_ap1_process(bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples) {
static inline void bw_ap1_process(
bw_ap1_coeffs *BW_RESTRICT coeffs,
bw_ap1_state *BW_RESTRICT state,
const float * x,
float * y,
size_t n_samples) {
bw_ap1_update_coeffs_ctrl(coeffs);
for (size_t i = 0; i < n_samples; i++) {
bw_ap1_update_coeffs_audio(coeffs);
@ -222,7 +268,13 @@ static inline void bw_ap1_process(bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_stat
}
}
static inline void bw_ap1_process_multi(bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap1_state *BW_RESTRICT const *BW_RESTRICT state, const float * const *x, float * const *y, size_t n_channels, size_t n_samples) {
static inline void bw_ap1_process_multi(
bw_ap1_coeffs *BW_RESTRICT coeffs,
bw_ap1_state *BW_RESTRICT const *BW_RESTRICT state,
const float * const * x,
float * const * y,
size_t n_channels,
size_t n_samples) {
bw_ap1_update_coeffs_ctrl(coeffs);
for (size_t i = 0; i < n_samples; i++) {
bw_ap1_update_coeffs_audio(coeffs);
@ -231,7 +283,9 @@ static inline void bw_ap1_process_multi(bw_ap1_coeffs *BW_RESTRICT coeffs, bw_ap
}
}
static inline void bw_ap1_set_cutoff(bw_ap1_coeffs *BW_RESTRICT coeffs, float value) {
static inline void bw_ap1_set_cutoff(
bw_ap1_coeffs *BW_RESTRICT coeffs,
float value) {
bw_lp1_set_cutoff(&coeffs->lp1_coeffs, value);
}
@ -252,18 +306,30 @@ class AP1 {
public:
AP1();
void setSampleRate(float sampleRate);
void reset(float x_0 = 0.f);
void setSampleRate(
float sampleRate);
void reset(
float x_0 = 0.f,
float *BW_RESTRICT y_0 = nullptr);
void reset(
const float * x_0,
float * y_0);
void reset(
const std::array<float, N_CHANNELS> x_0
const std::array<float, N_CHANNELS> y_0);
void process(
const float * const *x,
float * const *y,
size_t nSamples);
const float * const * x,
float * const * y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
size_t nSamples);
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setCutoff(float value);
void setCutoff(
float value);
/*! <<<...
* }
* ```
@ -288,35 +354,52 @@ inline AP1<N_CHANNELS>::AP1() {
}
template<size_t N_CHANNELS>
inline void AP1<N_CHANNELS>::setSampleRate(float sampleRate) {
inline void AP1<N_CHANNELS>::setSampleRate(
float sampleRate) {
bw_ap1_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void AP1<N_CHANNELS>::reset(float x_0) {
inline void AP1<N_CHANNELS>::reset(
float x_0) {
bw_ap1_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_ap1_reset_state(&coeffs, states + i, x_0);
}
template<size_t N_CHANNELS>
inline void AP1<N_CHANNELS>::reset(
const float *BW_RESTRICT x_0) {
bw_ap1_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_ap1_reset_state(&coeffs, states + i, x_0[i]);
}
template<size_t N_CHANNELS>
inline void AP1<N_CHANNELS>::reset(
const std::array<float, N_CHANNELS> x_0) {
reset(x_0.data());
}
template<size_t N_CHANNELS>
inline void AP1<N_CHANNELS>::process(
const float * const *x,
float * const *y,
const float * const * x,
float * const * y,
size_t nSamples) {
bw_ap1_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void AP1<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), y.data(), nSamples);
}
template<size_t N_CHANNELS>
inline void AP1<N_CHANNELS>::setCutoff(float value) {
inline void AP1<N_CHANNELS>::setCutoff(
float value) {
bw_ap1_set_cutoff(&coeffs, value);
}

View File

@ -30,6 +30,8 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Added overladed C++ <code>reset()</code> functions taking arrays
* as arguments.</li>
* <li><code>bw_ap2_process()</code> and
* <code>bw_ap2_process_multi()</code> now use <code>size_t</code>
* to count samples and channels.</li>
@ -91,25 +93,32 @@ typedef struct bw_ap2_state bw_ap2_state;
*
* #### bw_ap2_init()
* ```>>> */
static inline void bw_ap2_init(bw_ap2_coeffs *BW_RESTRICT coeffs);
static inline void bw_ap2_init(
bw_ap2_coeffs *BW_RESTRICT coeffs);
/*! <<<```
* Initializes input parameter values in `coeffs`.
*
* #### bw_ap2_set_sample_rate()
* ```>>> */
static inline void bw_ap2_set_sample_rate(bw_ap2_coeffs *BW_RESTRICT coeffs, float sample_rate);
static inline void bw_ap2_set_sample_rate(
bw_ap2_coeffs *BW_RESTRICT coeffs,
float sample_rate);
/*! <<<```
* Sets the `sample_rate` (Hz) value in `coeffs`.
*
* #### bw_ap2_reset_coeffs()
* ```>>> */
static inline void bw_ap2_reset_coeffs(bw_ap2_coeffs *BW_RESTRICT coeffs);
static inline void bw_ap2_reset_coeffs(
bw_ap2_coeffs *BW_RESTRICT coeffs);
/*! <<<```
* Resets coefficients in `coeffs` to assume their target values.
*
* #### bw_ap2_reset_state()
* ```>>> */
static inline void bw_ap2_reset_state(const bw_ap2_coeffs *BW_RESTRICT coeffs, bw_ap2_state *BW_RESTRICT state, float x_0);
static inline void bw_ap2_reset_state(
const bw_ap2_coeffs *BW_RESTRICT coeffs,
bw_ap2_state *BW_RESTRICT state,
float x_0);
/*! <<<```
* Resets the given `state` to its initial values using the given `coeffs`
* and the quiescent/initial input value `x_0`.
@ -268,13 +277,15 @@ public:
void setSampleRate(float sampleRate);
void reset(float x_0 = 0.f);
void reset(const float *BW_RESTRICT x_0);
void reset(const std::array<float, N_CHANNELS> x_0);
void process(
const float * const *x,
float * const *y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setCutoff(float value);
@ -314,6 +325,18 @@ inline void AP2<N_CHANNELS>::reset(float x_0) {
bw_ap2_reset_state(&coeffs, states + i, x_0);
}
template<size_t N_CHANNELS>
inline void AP2<N_CHANNELS>::reset(const float *BW_RESTRICT x_0) {
bw_ap2_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_ap2_reset_state(&coeffs, states + i, x_0[i]);
}
template<size_t N_CHANNELS>
inline void AP2<N_CHANNELS>::reset(const std::array<float, N_CHANNELS> x_0) {
reset(x_0.data());
}
template<size_t N_CHANNELS>
inline void AP2<N_CHANNELS>::process(
const float * const *x,
@ -324,8 +347,8 @@ inline void AP2<N_CHANNELS>::process(
template<size_t N_CHANNELS>
inline void AP2<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), y.data(), nSamples);
}

View File

@ -259,10 +259,10 @@ public:
float * const *y_r,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x_l,
std::array<const float *, N_CHANNELS> x_r,
std::array<float *, N_CHANNELS> y_l,
std::array<float *, N_CHANNELS> y_r,
const std::array<const float *, N_CHANNELS> x_l,
const std::array<const float *, N_CHANNELS> x_r,
const std::array<float *, N_CHANNELS> y_l,
const std::array<float *, N_CHANNELS> y_r,
size_t nSamples);
void setBalance(float value);
@ -307,10 +307,10 @@ inline void Balance<N_CHANNELS>::process(
template<size_t N_CHANNELS>
inline void Balance<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x_l,
std::array<const float *, N_CHANNELS> x_r,
std::array<float *, N_CHANNELS> y_l,
std::array<float *, N_CHANNELS> y_r,
const std::array<const float *, N_CHANNELS> x_l,
const std::array<const float *, N_CHANNELS> x_r,
const std::array<float *, N_CHANNELS> y_l,
const std::array<float *, N_CHANNELS> y_r,
size_t nSamples) {
process(x_l.data(), x_r.data(), y_l.data(), y_r.data(), nSamples);
}

View File

@ -233,8 +233,8 @@ public:
float * const *y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setBitDepth(char value);
@ -272,8 +272,8 @@ inline void BDReduce<N_CHANNELS>::process(
template<size_t N_CHANNELS>
inline void BDReduce<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), y.data(), nSamples);
}

View File

@ -31,6 +31,7 @@
* <ul>
* <li>Now using <code>size_t</code> instead of
* <code>BW_SIZE_T</code>.</li>
* <li>C++ API now uses <code>size_t</code> to count samples.</li>
* <li>Changed order of arguments to improve consistency.</li>
* <li>Added more <code>const</code> and <code>BW_RESTRICT</code>
* specifiers to input arguments.</li>
@ -323,13 +324,13 @@ template<size_t N_CHANNELS>
inline void bufFill(
float k,
float *BW_RESTRICT const *BW_RESTRICT dest,
int nSamples);
size_t nSamples);
template<size_t N_CHANNELS>
inline void bufFill(
float k,
std::array<float *BW_RESTRICT, N_CHANNELS> dest,
int nSamples);
size_t nSamples);
/*! <<<```
*
* ##### Brickworks::bufNeg
@ -338,13 +339,13 @@ template<size_t N_CHANNELS>
inline void bufNeg(
const float * const *src,
float * const *dest,
int nSamples);
size_t nSamples);
template<size_t N_CHANNELS>
inline void bufNeg(
std::array<const float *, N_CHANNELS> src,
std::array<float *, N_CHANNELS> dest,
int nSamples);
const std::array<const float *, N_CHANNELS> src,
const std::array<float *, N_CHANNELS> dest,
size_t nSamples);
/*! <<<```
*
* ##### Brickworks::bufAdd
@ -352,16 +353,16 @@ inline void bufNeg(
template<size_t N_CHANNELS>
inline void bufAdd(
const float * const *src,
float * const *dest,
float k,
int nSamples);
float * const *dest,
size_t nSamples);
template<size_t N_CHANNELS>
inline void bufAdd(
std::array<const float *, N_CHANNELS> src,
std::array<float *, N_CHANNELS> dest,
const std::array<const float *, N_CHANNELS> src,
float k,
int nSamples);
const std::array<float *, N_CHANNELS> dest,
size_t nSamples);
/*! <<<```
*
* ##### Brickworks::bufScale
@ -371,14 +372,14 @@ inline void bufScale(
const float * const *src,
float k,
float * const *dest,
int nSamples);
size_t nSamples);
template<size_t N_CHANNELS>
inline void bufScale(
std::array<const float *, N_CHANNELS> src,
std::array<float *, N_CHANNELS> dest,
const std::array<const float *, N_CHANNELS> src,
float k,
int nSamples);
const std::array<float *, N_CHANNELS> dest,
size_t nSamples);
/*! <<<```
*
* ##### Brickworks::bufMix
@ -388,14 +389,14 @@ inline void bufMix(
const float * const *src1,
const float * const *src2,
float * const *dest,
int nSamples);
size_t nSamples);
template<size_t N_CHANNELS>
inline void bufMix(
std::array<const float *, N_CHANNELS> src1,
std::array<const float *, N_CHANNELS> src2,
std::array<float *, N_CHANNELS> dest,
int nSamples);
const std::array<const float *, N_CHANNELS> src1,
const std::array<const float *, N_CHANNELS> src2,
const std::array<float *, N_CHANNELS> dest,
size_t nSamples);
/*! <<<```
*
* ##### Brickworks::bufMul
@ -405,14 +406,14 @@ inline void bufMul(
const float * const *src1,
const float * const *src2,
float * const *dest,
int nSamples);
size_t nSamples);
template<size_t N_CHANNELS>
inline void bufMul(
std::array<const float *, N_CHANNELS> src1,
std::array<const float *, N_CHANNELS> src2,
std::array<float *, N_CHANNELS> dest,
int nSamples);
const std::array<const float *, N_CHANNELS> src1,
const std::array<const float *, N_CHANNELS> src2,
const std::array<float *, N_CHANNELS> dest,
size_t nSamples);
/*! <<<```
* }}} */
@ -425,15 +426,15 @@ template<size_t N_CHANNELS>
inline void bufFill(
float k,
float *BW_RESTRICT const *BW_RESTRICT dest,
int nSamples) {
size_t nSamples) {
bw_buf_fill_multi(k, dest, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void bufFill(
float k,
std::array<float *BW_RESTRICT, N_CHANNELS> dest,
int nSamples) {
const std::array<float *BW_RESTRICT, N_CHANNELS> dest,
size_t nSamples) {
bufFill<N_CHANNELS>(k, dest.data(), nSamples);
}
@ -441,33 +442,33 @@ template<size_t N_CHANNELS>
inline void bufNeg(
const float * const *src,
float * const *dest,
int nSamples) {
size_t nSamples) {
bw_buf_neg_multi(src, dest, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void bufNeg(
std::array<const float *, N_CHANNELS> src,
std::array<float *, N_CHANNELS> dest,
int nSamples) {
const std::array<const float *, N_CHANNELS> src,
const std::array<float *, N_CHANNELS> dest,
size_t nSamples) {
bufNeg<N_CHANNELS>(src.data(), dest.data(), nSamples);
}
template<size_t N_CHANNELS>
inline void bufAdd(
const float * const *src,
float * const *dest,
float k,
int nSamples) {
float * const *dest,
size_t nSamples) {
bw_buf_add_multi(src, k, dest, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void bufAdd(
std::array<const float *, N_CHANNELS> src,
const std::array<const float *, N_CHANNELS> src,
float k,
std::array<float *, N_CHANNELS> dest,
int nSamples) {
const std::array<float *, N_CHANNELS> dest,
size_t nSamples) {
bufAdd<N_CHANNELS>(src.data(), k, dest.data(), nSamples);
}
@ -476,16 +477,16 @@ inline void bufScale(
const float * const *src,
float k,
float * const *dest,
int nSamples) {
size_t nSamples) {
bw_buf_scale_multi(src, k, dest, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void bufScale(
std::array<const float *, N_CHANNELS> src,
const std::array<const float *, N_CHANNELS> src,
float k,
std::array<float *, N_CHANNELS> dest,
int nSamples) {
const std::array<float *, N_CHANNELS> dest,
size_t nSamples) {
bufScale<N_CHANNELS>(src.data(), k, dest.data(), nSamples);
}
@ -494,16 +495,16 @@ inline void bufMix(
const float * const *src1,
const float * const *src2,
float * const *dest,
int nSamples) {
size_t nSamples) {
bw_buf_mix_multi(src1, src2, dest, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void bufMix(
std::array<const float *, N_CHANNELS> src1,
std::array<const float *, N_CHANNELS> src2,
std::array<float *, N_CHANNELS> dest,
int nSamples) {
const std::array<const float *, N_CHANNELS> src1,
const std::array<const float *, N_CHANNELS> src2,
const std::array<float *, N_CHANNELS> dest,
size_t nSamples) {
bufMix<N_CHANNELS>(src1.data(), src2.data(), dest.data(), nSamples);
}
@ -512,16 +513,16 @@ inline void bufMul(
const float * const *src1,
const float * const *src2,
float * const *dest,
int nSamples) {
size_t nSamples) {
bw_buf_mul_multi(src1, src2, dest, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void bufMul(
std::array<const float *, N_CHANNELS> src1,
std::array<const float *, N_CHANNELS> src2,
std::array<float *, N_CHANNELS> dest,
int nSamples) {
const std::array<const float *, N_CHANNELS> src1,
const std::array<const float *, N_CHANNELS> src2,
const std::array<float *, N_CHANNELS> dest,
size_t nSamples) {
bufMul<N_CHANNELS>(src1.data(), src2.data(), dest.data(), nSamples);
}

View File

@ -38,6 +38,10 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Added initial value argument in
* <code>bw_chorus_reset_state()</code>.</li>
* <li>Added overladed C++ <code>reset()</code> functions taking arrays
* as arguments.</li>
* <li>Now using <code>size_t</code> instead of
* <code>BW_SIZE_T</code>.</li>
* <li><code>bw_chorus_process()</code> and
@ -129,9 +133,10 @@ static inline void bw_chorus_reset_coeffs(bw_chorus_coeffs *BW_RESTRICT coeffs);
*
* #### bw_chorus_reset_state()
* ```>>> */
static inline void bw_chorus_reset_state(const bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state *BW_RESTRICT state);
static inline void bw_chorus_reset_state(const bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state *BW_RESTRICT state, float x_0);
/*! <<<```
* 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 `x_0`.
*
* #### bw_chorus_update_coeffs_ctrl()
* ```>>> */
@ -278,8 +283,8 @@ static inline void bw_chorus_reset_coeffs(bw_chorus_coeffs *BW_RESTRICT coeffs)
bw_comb_reset_coeffs(&coeffs->comb_coeffs);
}
static inline void bw_chorus_reset_state(const bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state *BW_RESTRICT state) {
bw_comb_reset_state(&coeffs->comb_coeffs, &state->comb_state);
static inline void bw_chorus_reset_state(const bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state *BW_RESTRICT state, float x_0) {
bw_comb_reset_state(&coeffs->comb_coeffs, &state->comb_state, x_0);
}
static inline void bw_chorus_update_coeffs_ctrl(bw_chorus_coeffs *BW_RESTRICT coeffs) {
@ -362,14 +367,16 @@ public:
~Chorus();
void setSampleRate(float sampleRate);
void reset();
void reset(float x_0 = 0.f);
void reset(const float *BW_RESTRICT x_0);
void reset(const std::array<float, N_CHANNELS> x_0);
void process(
const float * const *x,
float * const *y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setRate(float value);
@ -422,10 +429,22 @@ inline void Chorus<N_CHANNELS>::setSampleRate(float sampleRate) {
}
template<size_t N_CHANNELS>
inline void Chorus<N_CHANNELS>::reset() {
inline void Chorus<N_CHANNELS>::reset(float x_0) {
bw_chorus_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_chorus_reset_state(&coeffs, states + i);
bw_chorus_reset_state(&coeffs, states + i, x_0);
}
template<size_t N_CHANNELS>
inline void Chorus<N_CHANNELS>::reset(const float *BW_RESTRICT x_0) {
bw_chorus_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_chorus_reset_state(&coeffs, states + i, x_0[i]);
}
template<size_t N_CHANNELS>
inline void Chorus<N_CHANNELS>::reset(const std::array<float, N_CHANNELS> x_0) {
reset(x_0.data());
}
template<size_t N_CHANNELS>
@ -438,8 +457,8 @@ inline void Chorus<N_CHANNELS>::process(
template<size_t N_CHANNELS>
inline void Chorus<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), y.data(), nSamples);
}

View File

@ -48,6 +48,8 @@
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Changed default value for gain compensation to off.</li>
* <li>Added overladed C++ <code>reset()</code> functions taking arrays
* as arguments.</li>
* <li><code>bw_clip_process()</code> and
* <code>bw_clip_process_multi()</code> now use <code>size_t</code>
* to count samples and channels.</li>
@ -115,9 +117,10 @@ static inline void bw_clip_reset_coeffs(bw_clip_coeffs *BW_RESTRICT coeffs);
*
* #### bw_clip_reset_state()
* ```>>> */
static inline void bw_clip_reset_state(const bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state *BW_RESTRICT state);
static inline void bw_clip_reset_state(const bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state *BW_RESTRICT state, float x_0);
/*! <<<```
* 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 `x_0`.
*
* #### bw_clip_update_coeffs_ctrl()
* ```>>> */
@ -258,9 +261,10 @@ static inline void bw_clip_reset_coeffs(bw_clip_coeffs *BW_RESTRICT coeffs) {
bw_clip_do_update_coeffs(coeffs, 1);
}
static inline void bw_clip_reset_state(const bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state *BW_RESTRICT state) {
state->x_z1 = bw_one_pole_get_y_z1(&coeffs->smooth_bias_state);
const float a = bw_absf(state->x_z1);
static inline void bw_clip_reset_state(const bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state *BW_RESTRICT state, float 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);
const float a = bw_absf(x_0);
state->x_z1 = x;
state->F_z1 = a > 1.f ? a - 0.5f : 0.5f * a * a;
}
@ -346,14 +350,16 @@ public:
Clip();
void setSampleRate(float sampleRate);
void reset();
void reset(float x_0 = 0.f);
void reset(const float *BW_RESTRICT x_0);
void reset(const std::array<float, N_CHANNELS> x_0);
void process(
const float * const *x,
float * const *y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setBias(float value);
@ -388,10 +394,22 @@ inline void Clip<N_CHANNELS>::setSampleRate(float sampleRate) {
}
template<size_t N_CHANNELS>
inline void Clip<N_CHANNELS>::reset() {
inline void Clip<N_CHANNELS>::reset(float x_0) {
bw_clip_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_clip_reset_state(&coeffs, states + i);
bw_clip_reset_state(&coeffs, states + i, x_0);
}
template<size_t N_CHANNELS>
inline void Clip<N_CHANNELS>::reset(const float *BW_RESTRICT x_0) {
bw_clip_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_clip_reset_state(&coeffs, states + i, x_0[i]);
}
template<size_t N_CHANNELS>
inline void Clip<N_CHANNELS>::reset(const std::array<float, N_CHANNELS> x_0) {
reset(x_0.data());
}
template<size_t N_CHANNELS>
@ -404,8 +422,8 @@ inline void Clip<N_CHANNELS>::process(
template<size_t N_CHANNELS>
inline void Clip<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), y.data(), nSamples);
}

View File

@ -39,6 +39,10 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Added initial value argument in
* <code>bw_chorus_reset_state()</code>.</li>
* <li>Added overladed C++ <code>reset()</code> functions taking arrays
* as arguments.</li>
* <li>Now using <code>size_t</code> instead of
* <code>BW_SIZE_T</code>.</li>
* <li><code>bw_comb_process()</code> and
@ -130,9 +134,10 @@ static inline void bw_comb_reset_coeffs(bw_comb_coeffs *BW_RESTRICT coeffs);
*
* #### bw_comb_reset_state()
* ```>>> */
static inline void bw_comb_reset_state(const bw_comb_coeffs *BW_RESTRICT coeffs, bw_comb_state *BW_RESTRICT state);
static inline void bw_comb_reset_state(const bw_comb_coeffs *BW_RESTRICT coeffs, bw_comb_state *BW_RESTRICT state, float x_0);
/*! <<<```
* 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 `x_0`.
*
* #### bw_comb_update_coeffs_ctrl()
* ```>>> */
@ -328,8 +333,8 @@ static inline void bw_comb_reset_coeffs(bw_comb_coeffs *BW_RESTRICT coeffs) {
bw_comb_do_update_coeffs(coeffs, 1);
}
static inline void bw_comb_reset_state(const bw_comb_coeffs *BW_RESTRICT coeffs, bw_comb_state *BW_RESTRICT state) {
bw_delay_reset_state(&coeffs->delay_coeffs, &state->delay_state);
static inline void bw_comb_reset_state(const bw_comb_coeffs *BW_RESTRICT coeffs, bw_comb_state *BW_RESTRICT state, float x_0) {
bw_delay_reset_state(&coeffs->delay_coeffs, &state->delay_state, x_0);
}
static inline void bw_comb_update_coeffs_ctrl(bw_comb_coeffs *BW_RESTRICT coeffs) {
@ -409,14 +414,16 @@ public:
~Comb();
void setSampleRate(float sampleRate);
void reset();
void reset(float x_0 = 0.f);
void reset(const float *BW_RESTRICT x_0);
void reset(const std::array<float, N_CHANNELS> x_0);
void process(
const float * const *x,
float * const *y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setDelayFF(float value);
@ -468,10 +475,22 @@ inline void Comb<N_CHANNELS>::setSampleRate(float sampleRate) {
}
template<size_t N_CHANNELS>
inline void Comb<N_CHANNELS>::reset() {
inline void Comb<N_CHANNELS>::reset(float x_0) {
bw_comb_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_comb_reset_state(&coeffs, states + i);
bw_comb_reset_state(&coeffs, states + i, x_0);
}
template<size_t N_CHANNELS>
inline void Comb<N_CHANNELS>::reset(const float *BW_RESTRICT x_0) {
bw_comb_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_comb_reset_state(&coeffs, states + i, x_0[i]);
}
template<size_t N_CHANNELS>
inline void Comb<N_CHANNELS>::reset(const std::array<float, N_CHANNELS> x_0) {
reset(x_0.data());
}
template<size_t N_CHANNELS>
@ -484,8 +503,8 @@ inline void Comb<N_CHANNELS>::process(
template<size_t N_CHANNELS>
inline void Comb<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), y.data(), nSamples);
}

View File

@ -31,6 +31,10 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Added initial value arguments in
* <code>bw_comp_reset_state()</code>.</li>
* <li>Added overladed C++ <code>reset()</code> functions taking arrays
* as arguments.</li>
* <li><code>bw_comp_process()</code> and
* <code>bw_comp_process_multi()</code> now use <code>size_t</code>
* to count samples and channels.</li>
@ -106,9 +110,11 @@ static inline void bw_comp_reset_coeffs(bw_comp_coeffs *BW_RESTRICT coeffs);
*
* #### bw_comp_reset_state()
* ```>>> */
static inline void bw_comp_reset_state(const bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state);
static inline void bw_comp_reset_state(const bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state, float x_0, float x_sc_0);
/*! <<<```
* 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 `x_0` and sidechain input value
* `x_sc_0`.
*
* #### bw_comp_update_coeffs_ctrl()
* ```>>> */
@ -271,8 +277,9 @@ static inline void bw_comp_reset_coeffs(bw_comp_coeffs *BW_RESTRICT coeffs) {
bw_one_pole_reset_state(&coeffs->smooth_coeffs, &coeffs->smooth_ratio_state, coeffs->ratio);
}
static inline void bw_comp_reset_state(const bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state) {
bw_env_follow_reset_state(&coeffs->env_follow_coeffs, &state->env_follow_state);
static inline void bw_comp_reset_state(const bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state, float x_0, float x_sc_0) {
(void)x_0;
bw_env_follow_reset_state(&coeffs->env_follow_coeffs, &state->env_follow_state, x_sc_0);
}
static inline void bw_comp_update_coeffs_ctrl(bw_comp_coeffs *BW_RESTRICT coeffs) {
@ -357,16 +364,24 @@ public:
Comp();
void setSampleRate(float sampleRate);
void reset();
void reset(
float x_0 = 0.f,
float x_sc_0 = 0.f);
void reset(
const float *x_0,
const float *x_sc_0);
void reset(
const std::array<float, N_CHANNELS> x_0,
const std::array<float, N_CHANNELS> x_sc_0);
void process(
const float * const *x,
const float * const *xSC,
const float * const *x_sc,
float * const *y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> xSC,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<const float *, N_CHANNELS> x_sc,
const std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setTreshLin(float value);
@ -405,28 +420,46 @@ inline void Comp<N_CHANNELS>::setSampleRate(float sampleRate) {
}
template<size_t N_CHANNELS>
inline void Comp<N_CHANNELS>::reset() {
inline void Comp<N_CHANNELS>::reset(
float x_0,
float x_sc_0) {
bw_comp_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_comp_reset_state(&coeffs, states + i);
bw_comp_reset_state(&coeffs, states + i, x_0, x_sc_0);
}
template<size_t N_CHANNELS>
inline void Comp<N_CHANNELS>::reset(
const float *x_0,
const float *x_sc_0) {
bw_comp_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_comp_reset_state(&coeffs, states + i, x_0[i], x_sc_0[i]);
}
template<size_t N_CHANNELS>
inline void Comp<N_CHANNELS>::reset(
const std::array<float, N_CHANNELS> x_0,
const std::array<float, N_CHANNELS> x_sc_0) {
reset(x_0.data(), x_sc_0.data());
}
template<size_t N_CHANNELS>
inline void Comp<N_CHANNELS>::process(
const float * const *x,
const float * const *xSC,
const float * const *x_sc,
float * const *y,
size_t nSamples) {
bw_comp_process_multi(&coeffs, statesP, x, xSC, y, N_CHANNELS, nSamples);
bw_comp_process_multi(&coeffs, statesP, x, x_sc, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void Comp<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> xSC,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<const float *, N_CHANNELS> x_sc,
const std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), xSC.data(), y.data(), nSamples);
process(x.data(), x_sc.data(), y.data(), nSamples);
}
template<size_t N_CHANNELS>

View File

@ -33,6 +33,10 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Added initial value argument in
* <code>bw_delay_reset_state()</code>.</li>
* <li>Added overladed C++ <code>reset()</code> functions taking arrays
* as arguments.</li>
* <li>Now using <code>size_t</code> instead of
* <code>BW_SIZE_T</code>.</li>
* <li><code>bw_delay_process()</code> and
@ -123,9 +127,10 @@ static inline void bw_delay_reset_coeffs(bw_delay_coeffs *BW_RESTRICT coeffs);
*
* #### bw_delay_reset_state()
* ```>>> */
static inline void bw_delay_reset_state(const bw_delay_coeffs *BW_RESTRICT coeffs, bw_delay_state *BW_RESTRICT state);
static inline void bw_delay_reset_state(const bw_delay_coeffs *BW_RESTRICT coeffs, bw_delay_state *BW_RESTRICT state, float x_0);
/*! <<<```
* 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 `x_0`.
*
* #### bw_delay_read()
* ```>>> */
@ -254,8 +259,8 @@ static inline void bw_delay_reset_coeffs(bw_delay_coeffs *BW_RESTRICT coeffs) {
bw_delay_update_coeffs_ctrl(coeffs);
}
static inline void bw_delay_reset_state(const bw_delay_coeffs *BW_RESTRICT coeffs, bw_delay_state *BW_RESTRICT state) {
bw_buf_fill(0.f, state->buf, coeffs->len);
static inline void bw_delay_reset_state(const bw_delay_coeffs *BW_RESTRICT coeffs, bw_delay_state *BW_RESTRICT state, float x_0) {
bw_buf_fill(x_0, state->buf, coeffs->len);
state->idx = 0;
}
@ -332,14 +337,16 @@ public:
~Delay();
void setSampleRate(float sampleRate);
void reset();
void reset(float x_0 = 0.f);
void reset(const float *BW_RESTRICT x_0);
void reset(const std::array<float, N_CHANNELS> x_0);
void process(
const float * const *x,
float * const *y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples);
float read(size_t channel, size_t di, float df);
@ -392,10 +399,22 @@ inline void Delay<N_CHANNELS>::setSampleRate(float sampleRate) {
}
template<size_t N_CHANNELS>
inline void Delay<N_CHANNELS>::reset() {
inline void Delay<N_CHANNELS>::reset(float x_0) {
bw_delay_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_delay_reset_state(&coeffs, states + i);
bw_delay_reset_state(&coeffs, states + i, x_0);
}
template<size_t N_CHANNELS>
inline void Delay<N_CHANNELS>::reset(const float *BW_RESTRICT x_0) {
bw_delay_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_delay_reset_state(&coeffs, states + i, x_0[i]);
}
template<size_t N_CHANNELS>
inline void Delay<N_CHANNELS>::reset(const std::array<float, N_CHANNELS> x_0) {
reset(x_0.data());
}
template<size_t N_CHANNELS>
@ -408,8 +427,8 @@ inline void Delay<N_CHANNELS>::process(
template<size_t N_CHANNELS>
inline void Delay<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), y.data(), nSamples);
}

View File

@ -34,6 +34,10 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Added initial value argument in
* <code>bw_dist_reset_state()</code>.</li>
* <li>Added overladed C++ <code>reset()</code> functions taking arrays
* as arguments.</li>
* <li>Adjusted internal peak cutoff to more sensible value.</li>
* <li><code>bw_dist_process()</code> and
* <code>bw_dist_process_multi()</code> now use <code>size_t</code>
@ -102,9 +106,10 @@ static inline void bw_dist_reset_coeffs(bw_dist_coeffs *BW_RESTRICT coeffs);
*
* #### bw_dist_reset_state()
* ```>>> */
static inline void bw_dist_reset_state(const bw_dist_coeffs *BW_RESTRICT coeffs, bw_dist_state *BW_RESTRICT state);
static inline void bw_dist_reset_state(const bw_dist_coeffs *BW_RESTRICT coeffs, bw_dist_state *BW_RESTRICT state, float x_0);
/*! <<<```
* 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 `x_0`.
*
* #### bw_dist_update_coeffs_ctrl()
* ```>>> */
@ -244,8 +249,8 @@ static inline void bw_dist_reset_coeffs(bw_dist_coeffs *BW_RESTRICT coeffs) {
bw_gain_reset_coeffs(&coeffs->gain_coeffs);
}
static inline void bw_dist_reset_state(const bw_dist_coeffs *BW_RESTRICT coeffs, bw_dist_state *BW_RESTRICT state) {
bw_hp1_reset_state(&coeffs->hp1_coeffs, &state->hp1_state, 0.f);
static inline void bw_dist_reset_state(const bw_dist_coeffs *BW_RESTRICT coeffs, bw_dist_state *BW_RESTRICT state, float x_0) {
bw_hp1_reset_state(&coeffs->hp1_coeffs, &state->hp1_state, x_0); //...
bw_peak_reset_state(&coeffs->peak_coeffs, &state->peak_state, 0.f);
bw_clip_reset_state(&coeffs->clip_coeffs, &state->clip_state);
bw_satur_reset_state(&coeffs->satur_coeffs, &state->satur_state);
@ -320,14 +325,16 @@ public:
Dist();
void setSampleRate(float sampleRate);
void reset();
void reset(float x_0 = 0.f);
void reset(const float *BW_RESTRICT x_0);
void reset(const std::array<float, N_CHANNELS> x_0);
void process(
const float * const *x,
float * const *y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setDistortion(float value);
@ -362,10 +369,22 @@ inline void Dist<N_CHANNELS>::setSampleRate(float sampleRate) {
}
template<size_t N_CHANNELS>
inline void Dist<N_CHANNELS>::reset() {
inline void Dist<N_CHANNELS>::reset(float x_0) {
bw_dist_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_dist_reset_state(&coeffs, states + i);
bw_dist_reset_state(&coeffs, states + i, x_0);
}
template<size_t N_CHANNELS>
inline void Dist<N_CHANNELS>::reset(const float *BW_RESTRICT x_0) {
bw_dist_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_dist_reset_state(&coeffs, states + i, x_0[i]);
}
template<size_t N_CHANNELS>
inline void Dist<N_CHANNELS>::reset(const std::array<float, N_CHANNELS> x_0) {
reset(x_0.data());
}
template<size_t N_CHANNELS>
@ -378,8 +397,8 @@ inline void Dist<N_CHANNELS>::process(
template<size_t N_CHANNELS>
inline void Dist<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
const std::array<const float *, N_CHANNELS> x,
const std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), y.data(), nSamples);
}