diff --git a/examples/fxpp_chorus/src/bw_example_fxpp_chorus.h b/examples/fxpp_chorus/src/bw_example_fxpp_chorus.h index 895a7fb..c65f9fa 100644 --- a/examples/fxpp_chorus/src/bw_example_fxpp_chorus.h +++ b/examples/fxpp_chorus/src/bw_example_fxpp_chorus.h @@ -23,7 +23,7 @@ #include "platform.h" -#include +#include using namespace Brickworks; diff --git a/examples/fxpp_clip/src/bw_example_fxpp_clip.h b/examples/fxpp_clip/src/bw_example_fxpp_clip.h index a6f06a8..ec4e4b4 100644 --- a/examples/fxpp_clip/src/bw_example_fxpp_clip.h +++ b/examples/fxpp_clip/src/bw_example_fxpp_clip.h @@ -23,7 +23,7 @@ #include "platform.h" -#include +#include #include using namespace Brickworks; diff --git a/include/bw_balance.h b/include/bw_balance.h index c12503d..ea5aba5 100644 --- a/include/bw_balance.h +++ b/include/bw_balance.h @@ -242,7 +242,7 @@ namespace Brickworks { /*** Public C++ API ***/ -/*! api {{{ +/*! api_cpp {{{ * ##### Brickworks::Balance * ```>>> */ template diff --git a/include/bw_bd_reduce.h b/include/bw_bd_reduce.h index d86d47d..cfc9e9f 100644 --- a/include/bw_bd_reduce.h +++ b/include/bw_bd_reduce.h @@ -219,7 +219,7 @@ namespace Brickworks { /*** Public C++ API ***/ -/*! api {{{ +/*! api_cpp {{{ * ##### Brickworks::BDReduce * ```>>> */ template diff --git a/include/bw_chorus.h b/include/bw_chorus.h index 19c23b7..93b57ec 100644 --- a/include/bw_chorus.h +++ b/include/bw_chorus.h @@ -40,6 +40,15 @@ *
    *
  • Now using size_t instead of * BW_SIZE_T.
  • + *
  • bw_chorus_process() and + * bw_chorus_process_multi() now use + * size_t to count samples and channels.
  • + *
  • Added more const specifiers to input + * arguments.
  • + *
  • Moved C++ code to C header.
  • + *
  • Added overladed C++ process() function taking + * C-style arrays as arguments.
  • + *
  • Removed usage of reserved identifiers.
  • *
* *
  • Version 0.6.0: @@ -64,8 +73,8 @@ * }}} */ -#ifndef _BW_CHORUS_H -#define _BW_CHORUS_H +#ifndef BW_CHORUS_H +#define BW_CHORUS_H #include @@ -76,13 +85,13 @@ extern "C" { /*! api {{{ * #### bw_chorus_coeffs * ```>>> */ -typedef struct _bw_chorus_coeffs bw_chorus_coeffs; +typedef struct bw_chorus_coeffs bw_chorus_coeffs; /*! <<<``` * Coefficients and related. * * #### bw_chorus_state * ```>>> */ -typedef struct _bw_chorus_state bw_chorus_state; +typedef struct bw_chorus_state bw_chorus_state; /*! <<<``` * Internal state and related. * @@ -145,7 +154,7 @@ static inline float bw_chorus_process1(const bw_chorus_coeffs *BW_RESTRICT coeff * * #### bw_chorus_process() * ```>>> */ -static inline void bw_chorus_process(bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state *BW_RESTRICT state, const float *x, float *y, int n_samples); +static inline void bw_chorus_process(bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_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 @@ -153,7 +162,7 @@ static inline void bw_chorus_process(bw_chorus_coeffs *BW_RESTRICT coeffs, bw_ch * * #### bw_chorus_process_multi() * ```>>> */ -static inline void bw_chorus_process_multi(bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples); +static inline void bw_chorus_process_multi(bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state * const *BW_RESTRICT state, const float * const *x, float **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 @@ -226,7 +235,7 @@ static inline void bw_chorus_set_coeff_fb(bw_chorus_coeffs *BW_RESTRICT coeffs, extern "C" { #endif -struct _bw_chorus_coeffs { +struct bw_chorus_coeffs { // Sub-components bw_phase_gen_coeffs phase_gen_coeffs; bw_phase_gen_state phase_gen_state; @@ -237,7 +246,7 @@ struct _bw_chorus_coeffs { float amount; }; -struct _bw_chorus_state { +struct bw_chorus_state { // Sub-components bw_comb_state comb_state; }; @@ -293,19 +302,19 @@ static inline float bw_chorus_process1(const bw_chorus_coeffs *BW_RESTRICT coeff return bw_comb_process1(&coeffs->comb_coeffs, &state->comb_state, x); } -static inline void bw_chorus_process(bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state *BW_RESTRICT state, const float *x, float *y, int n_samples) { +static inline void bw_chorus_process(bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples) { bw_chorus_update_coeffs_ctrl(coeffs); - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_chorus_update_coeffs_audio(coeffs); y[i] = bw_chorus_process1(coeffs, state, x[i]); } } -static inline void bw_chorus_process_multi(bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples) { +static inline void bw_chorus_process_multi(bw_chorus_coeffs *BW_RESTRICT coeffs, bw_chorus_state * const *BW_RESTRICT state, const float * const *x, float **y, size_t n_channels, size_t n_samples) { bw_chorus_update_coeffs_ctrl(coeffs); - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_chorus_update_coeffs_audio(coeffs); - for (int j = 0; j < n_channels; j++) + for (size_t j = 0; j < n_channels; j++) y[j][i] = bw_chorus_process1(coeffs, state[j], x[j][i]); } } @@ -336,6 +345,136 @@ static inline void bw_chorus_set_coeff_fb(bw_chorus_coeffs *BW_RESTRICT coeffs, } #ifdef __cplusplus +} + +#include + +namespace Brickworks { + +/*** Public C++ API ***/ + +/*! api_cpp {{{ + * ##### Brickworks::Chorus + * ```>>> */ +template +class Chorus { +public: + Chorus(float maxDelay = 0.01f); + ~Chorus(); + + void setSampleRate(float sampleRate); + void reset(); + void process( + const float * const *x, + float **y, + size_t nSamples); + void process( + std::array x, + std::array y, + size_t nSamples); + + void setRate(float value); + void setDelay(float value); + void setAmount(float value); + void setCoeffX(float value); + void setCoeffMod(float value); + void setCoeffFB(float value); +/*! <<<... + * } + * ``` + * }}} */ + +/*** Implementation ***/ + +/* WARNING: This part of the file is not part of the public API. Its content may + * change at any time in future versions. Please, do not use it directly. */ + +private: + bw_chorus_coeffs coeffs; + bw_chorus_state states[N_CHANNELS]; + bw_chorus_state *statesP[N_CHANNELS]; + void *mem; +}; + +template +inline Chorus::Chorus(float maxDelay) { + bw_chorus_init(&coeffs, maxDelay); + for (size_t i = 0; i < N_CHANNELS; i++) + statesP[i] = states + i; + mem = nullptr; +} + +template +inline Chorus::~Chorus() { + if (mem != nullptr) + operator delete(mem); +} + +template +inline void Chorus::setSampleRate(float sampleRate) { + bw_chorus_set_sample_rate(&coeffs, sampleRate); + size_t req = bw_chorus_mem_req(&coeffs); + if (mem != nullptr) + operator delete(mem); + mem = operator new(req * N_CHANNELS); + void *m = mem; + for (size_t i = 0; i < N_CHANNELS; i++, m = static_cast(m) + req) + bw_chorus_mem_set(&coeffs, states + i, m); +} + +template +inline void Chorus::reset() { + bw_chorus_reset_coeffs(&coeffs); + for (size_t i = 0; i < N_CHANNELS; i++) + bw_chorus_reset_state(&coeffs, states + i); +} + +template +inline void Chorus::process( + const float * const *x, + float **y, + size_t nSamples) { + bw_chorus_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples); +} + +template +inline void Chorus::process( + std::array x, + std::array y, + size_t nSamples) { + process(x.data(), y.data(), nSamples); +} + +template +inline void Chorus::setRate(float value) { + bw_chorus_set_rate(&coeffs, value); +} + +template +inline void Chorus::setDelay(float value) { + bw_chorus_set_delay(&coeffs, value); +} + +template +inline void Chorus::setAmount(float value) { + bw_chorus_set_amount(&coeffs, value); +} + +template +inline void Chorus::setCoeffX(float value) { + bw_chorus_set_coeff_x(&coeffs, value); +} + +template +inline void Chorus::setCoeffMod(float value) { + bw_chorus_set_coeff_mod(&coeffs, value); +} + +template +inline void Chorus::setCoeffFB(float value) { + bw_chorus_set_coeff_fb(&coeffs, value); +} + } #endif diff --git a/include/bw_clip.h b/include/bw_clip.h index 7b50294..a2bb7a7 100644 --- a/include/bw_clip.h +++ b/include/bw_clip.h @@ -40,8 +40,15 @@ *
      *
    • Version 1.0.0: *
        - *
      • Now using size_t instead of - * BW_SIZE_T.
      • + *
      • bw_chorus_process() and + * bw_chorus_process_multi() now use + * size_t to count samples and channels.
      • + *
      • Added more const specifiers to input + * arguments.
      • + *
      • Moved C++ code to C header.
      • + *
      • Added overladed C++ process() function taking + * C-style arrays as arguments.
      • + *
      • Removed usage of reserved identifiers.
      • *
      *
    • *
    • Version 0.6.0: @@ -58,8 +65,8 @@ * }}} */ -#ifndef _BW_CLIP_H -#define _BW_CLIP_H +#ifndef BW_CLIP_H +#define BW_CLIP_H #include @@ -70,13 +77,13 @@ extern "C" { /*! api {{{ * #### bw_clip_coeffs * ```>>> */ -typedef struct _bw_clip_coeffs bw_clip_coeffs; +typedef struct bw_clip_coeffs bw_clip_coeffs; /*! <<<``` * Coefficients and related. * * #### bw_clip_state * ```>>> */ -typedef struct _bw_clip_state bw_clip_state; +typedef struct bw_clip_state bw_clip_state; /*! <<<``` * Internal state and related. * @@ -130,7 +137,7 @@ static inline float bw_clip_process1_comp(const bw_clip_coeffs *BW_RESTRICT coef * * #### bw_clip_process() * ```>>> */ -static inline void bw_clip_process(bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state *BW_RESTRICT state, const float *x, float *y, int n_samples); +static inline void bw_clip_process(bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_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 @@ -138,7 +145,7 @@ static inline void bw_clip_process(bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_s * * #### bw_clip_process_multi() * ```>>> */ -static inline void bw_clip_process_multi(bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples); +static inline void bw_clip_process_multi(bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state * const *BW_RESTRICT state, const float * const *x, float **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 @@ -189,7 +196,7 @@ static inline void bw_clip_set_gain_compensation(bw_clip_coeffs *BW_RESTRICT coe extern "C" { #endif -struct _bw_clip_coeffs { +struct bw_clip_coeffs { // Sub-components bw_one_pole_coeffs smooth_coeffs; bw_one_pole_state smooth_bias_state; @@ -205,7 +212,7 @@ struct _bw_clip_coeffs { char gain_compensation; }; -struct _bw_clip_state { +struct bw_clip_state { float x_z1; float F_z1; }; @@ -224,7 +231,7 @@ static inline void bw_clip_set_sample_rate(bw_clip_coeffs *BW_RESTRICT coeffs, f bw_one_pole_reset_coeffs(&coeffs->smooth_coeffs); } -static inline void _bw_clip_do_update_coeffs(bw_clip_coeffs *BW_RESTRICT coeffs, char force) { +static inline void bw_clip_do_update_coeffs(bw_clip_coeffs *BW_RESTRICT coeffs, char force) { float bias_cur = bw_one_pole_get_y_z1(&coeffs->smooth_bias_state); if (force || coeffs->bias != bias_cur) { bias_cur = bw_one_pole_process1_sticky_abs(&coeffs->smooth_coeffs, &coeffs->smooth_bias_state, coeffs->bias); @@ -240,7 +247,7 @@ static inline void _bw_clip_do_update_coeffs(bw_clip_coeffs *BW_RESTRICT coeffs, static inline void bw_clip_reset_coeffs(bw_clip_coeffs *BW_RESTRICT coeffs) { bw_one_pole_reset_state(&coeffs->smooth_coeffs, &coeffs->smooth_bias_state, coeffs->bias); bw_one_pole_reset_state(&coeffs->smooth_coeffs, &coeffs->smooth_gain_state, coeffs->gain); - _bw_clip_do_update_coeffs(coeffs, 1); + 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) { @@ -254,7 +261,7 @@ static inline void bw_clip_update_coeffs_ctrl(bw_clip_coeffs *BW_RESTRICT coeffs } static inline void bw_clip_update_coeffs_audio(bw_clip_coeffs *BW_RESTRICT coeffs) { - _bw_clip_do_update_coeffs(coeffs, 0); + bw_clip_do_update_coeffs(coeffs, 0); } static inline float bw_clip_process1(const bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state *BW_RESTRICT state, float x) { @@ -273,30 +280,30 @@ static inline float bw_clip_process1_comp(const bw_clip_coeffs *BW_RESTRICT coef return coeffs->inv_gain * y; } -static inline void bw_clip_process(bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state *BW_RESTRICT state, const float *x, float *y, int n_samples) { +static inline void bw_clip_process(bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples) { if (coeffs->gain_compensation) - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_clip_update_coeffs_audio(coeffs); y[i] = bw_clip_process1_comp(coeffs, state, x[i]); } else - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_clip_update_coeffs_audio(coeffs); y[i] = bw_clip_process1(coeffs, state, x[i]); } } -static inline void bw_clip_process_multi(bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples) { +static inline void bw_clip_process_multi(bw_clip_coeffs *BW_RESTRICT coeffs, bw_clip_state * const *BW_RESTRICT state, const float * const *x, float **y, size_t n_channels, size_t n_samples) { if (coeffs->gain_compensation) - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_clip_update_coeffs_audio(coeffs); - for (int j = 0; j < n_channels; j++) + for (size_t j = 0; j < n_channels; j++) y[j][i] = bw_clip_process1_comp(coeffs, state[j], x[j][i]); } else - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_clip_update_coeffs_audio(coeffs); - for (int j = 0; j < n_channels; j++) + for (size_t j = 0; j < n_channels; j++) y[j][i] = bw_clip_process1(coeffs, state[j], x[j][i]); } } @@ -314,6 +321,100 @@ static inline void bw_clip_set_gain_compensation(bw_clip_coeffs *BW_RESTRICT coe } #ifdef __cplusplus +} + +#include + +namespace Brickworks { + +/*! api {{{ + * ##### Brickworks::Clip + * ```>>> */ +template +class Clip { +public: + Clip(); + + void setSampleRate(float sampleRate); + void reset(); + void process( + const float * const *x, + float **y, + size_t nSamples); + void process( + std::array x, + std::array y, + size_t nSamples); + + void setBias(float value); + void setGain(float value); + void setGainCompensation(bool value); +/*! <<<... + * } + * ``` + * }}} */ + +/*** Implementation ***/ + +/* WARNING: This part of the file is not part of the public API. Its content may + * change at any time in future versions. Please, do not use it directly. */ + +private: + bw_clip_coeffs coeffs; + bw_clip_state states[N_CHANNELS]; + bw_clip_state *statesP[N_CHANNELS]; +}; + +template +inline Clip::Clip() { + bw_clip_init(&coeffs); + for (size_t i = 0; i < N_CHANNELS; i++) + statesP[i] = states + i; +} + +template +inline void Clip::setSampleRate(float sampleRate) { + bw_clip_set_sample_rate(&coeffs, sampleRate); +} + +template +inline void Clip::reset() { + bw_clip_reset_coeffs(&coeffs); + for (size_t i = 0; i < N_CHANNELS; i++) + bw_clip_reset_state(&coeffs, states + i); +} + +template +inline void Clip::process( + const float * const *x, + float **y, + size_t nSamples) { + bw_clip_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples); +} + +template +inline void Clip::process( + std::array x, + std::array y, + size_t nSamples) { + process(x.data(), y.data(), nSamples); +} + +template +inline void Clip::setBias(float value) { + bw_clip_set_bias(&coeffs, value); +} + +template +inline void Clip::setGain(float value) { + bw_clip_set_gain(&coeffs, value); +} + +template +inline void Clip::setGainCompensation(bool value) { + bw_clip_set_gain_compensation(&coeffs, value); +} + } #endif diff --git a/include/bwpp_chorus.h b/include/bwpp_chorus.h deleted file mode 100644 index c2198f4..0000000 --- a/include/bwpp_chorus.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Brickworks - * - * 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 - * the Free Software Foundation, version 3 of the License. - * - * Brickworks is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Brickworks. If not, see . - * - * File author: Stefano D'Angelo - */ - -#ifndef BWPP_CHORUS_H -#define BWPP_CHORUS_H - -#include -#include - -namespace Brickworks { - -/*! api {{{ - * ##### Brickworks::Chorus - * ```>>> */ -template -class Chorus { -public: - Chorus(float maxDelay = 0.01f); - ~Chorus(); - - void setSampleRate(float sampleRate); - void reset(); - void process( - std::array x, - std::array y, - int nSamples); - - void setRate(float value); - void setDelay(float value); - void setAmount(float value); - void setCoeffX(float value); - void setCoeffMod(float value); - void setCoeffFB(float value); -/*! <<<... - * } - * ``` - * }}} */ - -/*** Implementation ***/ - -/* WARNING: This part of the file is not part of the public API. Its content may - * change at any time in future versions. Please, do not use it directly. */ - -private: - bw_chorus_coeffs coeffs; - bw_chorus_state states[N_CHANNELS]; - bw_chorus_state *statesP[N_CHANNELS]; - void *mem; -}; - -template -inline Chorus::Chorus(float maxDelay) { - bw_chorus_init(&coeffs, maxDelay); - for (size_t i = 0; i < N_CHANNELS; i++) - statesP[i] = states + i; - mem = nullptr; -} - -template -inline Chorus::~Chorus() { - if (mem != nullptr) - operator delete(mem); -} - -template -inline void Chorus::setSampleRate(float sampleRate) { - bw_chorus_set_sample_rate(&coeffs, sampleRate); - size_t req = bw_chorus_mem_req(&coeffs); - if (mem != nullptr) - operator delete(mem); - mem = operator new(req * N_CHANNELS); - void *m = mem; - for (size_t i = 0; i < N_CHANNELS; i++, m = static_cast(m) + req) - bw_chorus_mem_set(&coeffs, states + i, m); -} - -template -inline void Chorus::reset() { - bw_chorus_reset_coeffs(&coeffs); - for (size_t i = 0; i < N_CHANNELS; i++) - bw_chorus_reset_state(&coeffs, states + i); -} - -template -inline void Chorus::process( - std::array x, - std::array y, - int nSamples) { - bw_chorus_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples); -} - -template -inline void Chorus::setRate(float value) { - bw_chorus_set_rate(&coeffs, value); -} - -template -inline void Chorus::setDelay(float value) { - bw_chorus_set_delay(&coeffs, value); -} - -template -inline void Chorus::setAmount(float value) { - bw_chorus_set_amount(&coeffs, value); -} - -template -inline void Chorus::setCoeffX(float value) { - bw_chorus_set_coeff_x(&coeffs, value); -} - -template -inline void Chorus::setCoeffMod(float value) { - bw_chorus_set_coeff_mod(&coeffs, value); -} - -template -inline void Chorus::setCoeffFB(float value) { - bw_chorus_set_coeff_fb(&coeffs, value); -} - -} - -#endif diff --git a/include/bwpp_clip.h b/include/bwpp_clip.h deleted file mode 100644 index 3c52173..0000000 --- a/include/bwpp_clip.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Brickworks - * - * 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 - * the Free Software Foundation, version 3 of the License. - * - * Brickworks is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Brickworks. If not, see . - * - * File author: Stefano D'Angelo - */ - -#ifndef BWPP_CLIP_H -#define BWPP_CLIP_H - -#include -#include - -namespace Brickworks { - -/*! api {{{ - * ##### Brickworks::Clip - * ```>>> */ -template -class Clip { -public: - Clip(); - - void setSampleRate(float sampleRate); - void reset(); - void process( - std::array x, - std::array y, - int nSamples); - - void setBias(float value); - void setGain(float value); - void setGainCompensation(bool value); -/*! <<<... - * } - * ``` - * }}} */ - -/*** Implementation ***/ - -/* WARNING: This part of the file is not part of the public API. Its content may - * change at any time in future versions. Please, do not use it directly. */ - -private: - bw_clip_coeffs coeffs; - bw_clip_state states[N_CHANNELS]; - bw_clip_state *statesP[N_CHANNELS]; -}; - -template -inline Clip::Clip() { - bw_clip_init(&coeffs); - for (size_t i = 0; i < N_CHANNELS; i++) - statesP[i] = states + i; -} - -template -inline void Clip::setSampleRate(float sampleRate) { - bw_clip_set_sample_rate(&coeffs, sampleRate); -} - -template -inline void Clip::reset() { - bw_clip_reset_coeffs(&coeffs); - for (size_t i = 0; i < N_CHANNELS; i++) - bw_clip_reset_state(&coeffs, states + i); -} - -template -inline void Clip::process( - std::array x, - std::array y, - int nSamples) { - bw_clip_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples); -} - -template -inline void Clip::setBias(float value) { - bw_clip_set_bias(&coeffs, value); -} - -template -inline void Clip::setGain(float value) { - bw_clip_set_gain(&coeffs, value); -} - -template -inline void Clip::setGainCompensation(bool value) { - bw_clip_set_gain_compensation(&coeffs, value); -} - -} - -#endif