diff --git a/examples/fxpp_balance/src/bw_example_fxpp_balance.h b/examples/fxpp_balance/src/bw_example_fxpp_balance.h index 10b7c8d..d12b881 100644 --- a/examples/fxpp_balance/src/bw_example_fxpp_balance.h +++ b/examples/fxpp_balance/src/bw_example_fxpp_balance.h @@ -23,8 +23,8 @@ #include "platform.h" -#include -#include +#include +#include using namespace Brickworks; diff --git a/examples/fxpp_pan/src/bw_example_fxpp_pan.h b/examples/fxpp_pan/src/bw_example_fxpp_pan.h index 0806bbe..ec4aba5 100644 --- a/examples/fxpp_pan/src/bw_example_fxpp_pan.h +++ b/examples/fxpp_pan/src/bw_example_fxpp_pan.h @@ -24,7 +24,7 @@ #include "platform.h" #include -#include +#include using namespace Brickworks; diff --git a/examples/fxpp_phaser/src/bw_example_fxpp_phaser.h b/examples/fxpp_phaser/src/bw_example_fxpp_phaser.h index 4d383e4..17d749a 100644 --- a/examples/fxpp_phaser/src/bw_example_fxpp_phaser.h +++ b/examples/fxpp_phaser/src/bw_example_fxpp_phaser.h @@ -23,7 +23,7 @@ #include "platform.h" -#include +#include using namespace Brickworks; diff --git a/examples/synthpp_mono/src/bw_example_synthpp_mono.h b/examples/synthpp_mono/src/bw_example_synthpp_mono.h index c9a4742..f8efce6 100644 --- a/examples/synthpp_mono/src/bw_example_synthpp_mono.h +++ b/examples/synthpp_mono/src/bw_example_synthpp_mono.h @@ -30,11 +30,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include using namespace Brickworks; diff --git a/examples/synthpp_poly/src/bw_example_synthpp_poly.h b/examples/synthpp_poly/src/bw_example_synthpp_poly.h index c80ecc9..becd786 100644 --- a/examples/synthpp_poly/src/bw_example_synthpp_poly.h +++ b/examples/synthpp_poly/src/bw_example_synthpp_poly.h @@ -31,11 +31,11 @@ #include #include #include -#include +#include #include #include #include -#include +#include using namespace Brickworks; diff --git a/examples/synthpp_simple/src/bw_example_synthpp_simple.h b/examples/synthpp_simple/src/bw_example_synthpp_simple.h index 22fccad..25a2a97 100644 --- a/examples/synthpp_simple/src/bw_example_synthpp_simple.h +++ b/examples/synthpp_simple/src/bw_example_synthpp_simple.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include using namespace Brickworks; diff --git a/include/bw_phaser.h b/include/bw_phaser.h index 6c2f70c..dae4f63 100644 --- a/include/bw_phaser.h +++ b/include/bw_phaser.h @@ -32,8 +32,15 @@ *
    *
  • Version 1.0.0: *
      - *
    • Now using size_t instead of - * BW_SIZE_T.
    • + *
    • bw_phaser_process() and + * bw_phaser_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: @@ -57,8 +64,8 @@ * }}} */ -#ifndef _BW_PHASER_H -#define _BW_PHASER_H +#ifndef BW_PHASER_H +#define BW_PHASER_H #include @@ -69,13 +76,13 @@ extern "C" { /*! api {{{ * #### bw_phaser_coeffs * ```>>> */ -typedef struct _bw_phaser_coeffs bw_phaser_coeffs; +typedef struct bw_phaser_coeffs bw_phaser_coeffs; /*! <<<``` * Coefficients and related. * * #### bw_phaser_state * ```>>> */ -typedef struct _bw_phaser_state bw_phaser_state; +typedef struct bw_phaser_state bw_phaser_state; /*! <<<``` * Internal state and related. * @@ -124,7 +131,7 @@ static inline float bw_phaser_process1(const bw_phaser_coeffs *BW_RESTRICT coeff * * #### bw_phaser_process() * ```>>> */ -static inline void bw_phaser_process(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state *BW_RESTRICT state, const float *x, float *y, int n_samples); +static inline void bw_phaser_process(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_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 @@ -132,7 +139,7 @@ static inline void bw_phaser_process(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_ph * * #### bw_phaser_process_multi() * ```>>> */ -static inline void bw_phaser_process_multi(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples); +static inline void bw_phaser_process_multi(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_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 @@ -182,7 +189,7 @@ static inline void bw_phaser_set_amount(bw_phaser_coeffs *BW_RESTRICT coeffs, fl extern "C" { #endif -struct _bw_phaser_coeffs { +struct bw_phaser_coeffs { // Sub-components bw_phase_gen_coeffs phase_gen_coeffs; bw_phase_gen_state phase_gen_state; @@ -196,7 +203,7 @@ struct _bw_phaser_coeffs { float amount; }; -struct _bw_phaser_state { +struct bw_phaser_state { bw_ap1_state ap1_state[4]; }; @@ -248,19 +255,19 @@ static inline float bw_phaser_process1(const bw_phaser_coeffs *BW_RESTRICT coeff return x + bw_ap1_process1(&coeffs->ap1_coeffs, &state->ap1_state[3], y); } -static inline void bw_phaser_process(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state *BW_RESTRICT state, const float *x, float *y, int n_samples) { +static inline void bw_phaser_process(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples) { bw_phaser_update_coeffs_ctrl(coeffs); - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_phaser_update_coeffs_audio(coeffs); y[i] = bw_phaser_process1(coeffs, state, x[i]); } } -static inline void bw_phaser_process_multi(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples) { +static inline void bw_phaser_process_multi(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state * const *BW_RESTRICT state, const float * const *x, float **y, size_t n_channels, size_t n_samples) { bw_phaser_update_coeffs_ctrl(coeffs); - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_phaser_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_phaser_process1(coeffs, state[j], x[j][i]); } } @@ -278,6 +285,102 @@ static inline void bw_phaser_set_amount(bw_phaser_coeffs *BW_RESTRICT coeffs, fl } #ifdef __cplusplus +} + +#include + +namespace Brickworks { + +/*** Public C++ API ***/ + +/*! api_cpp {{{ + * ##### Brickworks::Phaser + * ```>>> */ +template +class Phaser { +public: + Phaser(); + + 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 setCenter(float value); + void setAmount(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_phaser_coeffs coeffs; + bw_phaser_state states[N_CHANNELS]; + bw_phaser_state *statesP[N_CHANNELS]; +}; + +template +inline Phaser::Phaser() { + bw_phaser_init(&coeffs); + for (size_t i = 0; i < N_CHANNELS; i++) + statesP[i] = states + i; +} + +template +inline void Phaser::setSampleRate(float sampleRate) { + bw_phaser_set_sample_rate(&coeffs, sampleRate); +} + +template +inline void Phaser::reset() { + bw_phaser_reset_coeffs(&coeffs); + for (size_t i = 0; i < N_CHANNELS; i++) + bw_phaser_reset_state(&coeffs, states + i); +} + +template +inline void Phaser::process( + const float * const *x, + float **y, + size_t nSamples) { + bw_phaser_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples); +} + +template +inline void Phaser::process( + std::array x, + std::array y, + size_t nSamples) { + process(x.data(), y.data(), nSamples); +} + +template +inline void Phaser::setRate(float value) { + bw_phaser_set_rate(&coeffs, value); +} + +template +inline void Phaser::setCenter(float value) { + bw_phaser_set_center(&coeffs, value); +} + +template +inline void Phaser::setAmount(float value) { + bw_phaser_set_amount(&coeffs, value); +} + } #endif diff --git a/include/bw_pink_filt.h b/include/bw_pink_filt.h index 9387526..7a361b7 100644 --- a/include/bw_pink_filt.h +++ b/include/bw_pink_filt.h @@ -36,8 +36,15 @@ *
      *
    • Version 1.0.0: *
        - *
      • Now using size_t instead of - * BW_SIZE_T.
      • + *
      • bw_pink_filt_process() and + * bw_pink_filt_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: @@ -78,8 +85,8 @@ * }}} */ -#ifndef _BW_PINK_FILT_H -#define _BW_PINK_FILT_H +#ifndef BW_PINK_FILT_H +#define BW_PINK_FILT_H #include @@ -90,13 +97,13 @@ extern "C" { /*! api {{{ * #### bw_pink_filt_coeffs * ```>>> */ -typedef struct _bw_pink_filt_coeffs bw_pink_filt_coeffs; +typedef struct bw_pink_filt_coeffs bw_pink_filt_coeffs; /*! <<<``` * Coefficients and related. * * #### bw_pink_filt_state * ```>>> */ -typedef struct _bw_pink_filt_state bw_pink_filt_state; +typedef struct bw_pink_filt_state bw_pink_filt_state; /*! <<<``` * Internal state and related. * @@ -133,7 +140,7 @@ static inline float bw_pink_filt_process1_scaling(const bw_pink_filt_coeffs *BW_ * * #### bw_pink_filt_process() * ```>>> */ -static inline void bw_pink_filt_process(bw_pink_filt_coeffs *BW_RESTRICT coeffs, bw_pink_filt_state *BW_RESTRICT state, const float *x, float *y, int n_samples); +static inline void bw_pink_filt_process(bw_pink_filt_coeffs *BW_RESTRICT coeffs, bw_pink_filt_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 `coeffs` and @@ -141,7 +148,7 @@ static inline void bw_pink_filt_process(bw_pink_filt_coeffs *BW_RESTRICT coeffs, * * #### bw_pink_filt_process_multi() * ```>>> */ -static inline void bw_pink_filt_process_multi(bw_pink_filt_coeffs *BW_RESTRICT coeffs, bw_pink_filt_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples); +static inline void bw_pink_filt_process_multi(bw_pink_filt_coeffs *BW_RESTRICT coeffs, bw_pink_filt_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 @@ -183,7 +190,7 @@ static inline float bw_pink_filt_get_scaling_k(const bw_pink_filt_coeffs *BW_RES extern "C" { #endif -struct _bw_pink_filt_coeffs { +struct bw_pink_filt_coeffs { // Coefficients float scaling_k; @@ -191,7 +198,7 @@ struct _bw_pink_filt_coeffs { float sample_rate_scaling; }; -struct _bw_pink_filt_state { +struct bw_pink_filt_state { float s1_z1; float s2_z1; float s3_z1; @@ -232,17 +239,17 @@ static inline float bw_pink_filt_process1_scaling(const bw_pink_filt_coeffs *BW_ return coeffs->scaling_k * bw_pink_filt_process1(coeffs, state, x); } -static inline void bw_pink_filt_process(bw_pink_filt_coeffs *BW_RESTRICT coeffs, bw_pink_filt_state *BW_RESTRICT state, const float *x, float* y, int n_samples) { +static inline void bw_pink_filt_process(bw_pink_filt_coeffs *BW_RESTRICT coeffs, bw_pink_filt_state *BW_RESTRICT state, const float *x, float* y, size_t n_samples) { if (coeffs->sample_rate_scaling) - for (int i = 0; i < n_samples; i++) + for (size_t i = 0; i < n_samples; i++) y[i] = bw_pink_filt_process1_scaling(coeffs, state, x[i]); else - for (int i = 0; i < n_samples; i++) + for (size_t i = 0; i < n_samples; i++) y[i] = bw_pink_filt_process1(coeffs, state, x[i]); } -static inline void bw_pink_filt_process_multi(bw_pink_filt_coeffs *BW_RESTRICT coeffs, bw_pink_filt_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples) { - for (int i = 0; i < n_channels; i++) +static inline void bw_pink_filt_process_multi(bw_pink_filt_coeffs *BW_RESTRICT coeffs, bw_pink_filt_state * const *BW_RESTRICT state, const float * const *x, float **y, size_t n_channels, size_t n_samples) { + for (size_t i = 0; i < n_channels; i++) bw_pink_filt_process(coeffs, state[i], x[i], y[i], n_samples); } @@ -255,6 +262,96 @@ static inline float bw_pink_filt_get_scaling_k(const bw_pink_filt_coeffs *BW_RES } #ifdef __cplusplus +} + +#include + +namespace Brickworks { + +/*** Public C++ API ***/ + +/*! api_cpp {{{ + * ##### Brickworks::PinkFilt + * ```>>> */ +template +class PinkFilt { +public: + PinkFilt(); + + 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 setSampleRateScaling(bool value); + + float getScalingK(); +/*! <<<... + * } + * ``` + * }}} */ + +/*** 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_pink_filt_coeffs coeffs; + bw_pink_filt_state states[N_CHANNELS]; + bw_pink_filt_state *statesP[N_CHANNELS]; +}; + +template +inline PinkFilt::PinkFilt() { + bw_pink_filt_init(&coeffs); + for (size_t i = 0; i < N_CHANNELS; i++) + statesP[i] = states + i; +} + +template +inline void PinkFilt::setSampleRate(float sampleRate) { + bw_pink_filt_set_sample_rate(&coeffs, sampleRate); +} + +template +inline void PinkFilt::reset() { + for (size_t i = 0; i < N_CHANNELS; i++) + bw_pink_filt_reset_state(&coeffs, states + i); +} + +template +inline void PinkFilt::process( + const float * const *x, + float **y, + size_t nSamples) { + bw_pink_filt_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples); +} + +template +inline void PinkFilt::process( + std::array x, + std::array y, + size_t nSamples) { + process(x.data(), y.data(), nSamples); +} + +template +inline void PinkFilt::setSampleRateScaling(bool value) { + bw_pink_filt_set_sample_rate_scaling(&coeffs, value); +} + +template +inline float PinkFilt::getScalingK() { + return bw_pink_filt_get_scaling_k(&coeffs); +} + } #endif diff --git a/include/bw_ppm.h b/include/bw_ppm.h index ba098fe..c9a61de 100644 --- a/include/bw_ppm.h +++ b/include/bw_ppm.h @@ -32,8 +32,15 @@ *
        *
      • Version 1.0.0: *
          - *
        • Now using size_t instead of - * BW_SIZE_T.
        • + *
        • bw_ppm_process() and + * bw_ppm_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_PPM_H -#define _BW_PPM_H +#ifndef BW_PPM_H +#define BW_PPM_H #include @@ -70,13 +77,13 @@ extern "C" { /*! api {{{ * #### bw_ppm_coeffs * ```>>> */ -typedef struct _bw_ppm_coeffs bw_ppm_coeffs; +typedef struct bw_ppm_coeffs bw_ppm_coeffs; /*! <<<``` * Coefficients and related. * * #### bw_ppm_state * ```>>> */ -typedef struct _bw_ppm_state bw_ppm_state; +typedef struct bw_ppm_state bw_ppm_state; /*! <<<``` * Internal state and related. * @@ -125,7 +132,7 @@ static inline float bw_ppm_process1(const bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ * * #### bw_ppm_process() * ```>>> */ -static inline void bw_ppm_process(bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state *BW_RESTRICT state, const float *x, float *y, int n_samples); +static inline void bw_ppm_process(bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_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 @@ -137,7 +144,7 @@ static inline void bw_ppm_process(bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_stat * * #### bw_ppm_process_multi() * ```>>> */ -static inline void bw_ppm_process_multi(bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples); +static inline void bw_ppm_process_multi(bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_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 @@ -178,12 +185,12 @@ static inline float bw_ppm_get_y_z1(const bw_ppm_state *BW_RESTRICT state); extern "C" { #endif -struct _bw_ppm_coeffs { +struct bw_ppm_coeffs { // Sub-components bw_env_follow_coeffs env_follow_coeffs; }; -struct _bw_ppm_state { +struct bw_ppm_state { bw_env_follow_state env_follow_state; float y_z1; }; @@ -221,35 +228,35 @@ static inline float bw_ppm_process1(const bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ return y; } -static inline void bw_ppm_process(bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state *BW_RESTRICT state, const float *x, float *y, int n_samples) { +static inline void bw_ppm_process(bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples) { bw_ppm_update_coeffs_ctrl(coeffs); if (y != NULL) - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_ppm_update_coeffs_audio(coeffs); y[i] = bw_ppm_process1(coeffs, state, x[i]); } else - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_ppm_update_coeffs_audio(coeffs); bw_ppm_process1(coeffs, state, x[i]); } } -static inline void bw_ppm_process_multi(bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples) { +static inline void bw_ppm_process_multi(bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state * const *BW_RESTRICT state, const float * const *x, float **y, size_t n_channels, size_t n_samples) { bw_ppm_update_coeffs_ctrl(coeffs); if (y != NULL) - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_ppm_update_coeffs_audio(coeffs); - for (int j = 0; j < n_channels; j++) { + for (size_t j = 0; j < n_channels; j++) { const float v = bw_ppm_process1(coeffs, state[j], x[j][i]); if (y[j] != NULL) y[j][i] = v; } } else - for (int i = 0; i < n_samples; i++) { + for (size_t i = 0; i < n_samples; i++) { bw_ppm_update_coeffs_audio(coeffs); - for (int j = 0; j < n_channels; j++) + for (size_t j = 0; j < n_channels; j++) bw_ppm_process1(coeffs, state[j], x[j][i]); } } @@ -263,6 +270,97 @@ static inline float bw_ppm_get_y_z1(const bw_ppm_state *BW_RESTRICT state) { } #ifdef __cplusplus +} + +#include + +namespace Brickworks { + +/*** Public C++ API ***/ + +/*! api_cpp {{{ + * ##### Brickworks::PPM + * ```>>> */ +template +class PPM { +public: + PPM(); + + 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 setIntegrationTau(float value); + + float getYZ1(size_t channel); +/*! <<<... + * } + * ``` + * }}} */ + +/*** 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_ppm_coeffs coeffs; + bw_ppm_state states[N_CHANNELS]; + bw_ppm_state *statesP[N_CHANNELS]; +}; + +template +inline PPM::PPM() { + bw_ppm_init(&coeffs); + for (size_t i = 0; i < N_CHANNELS; i++) + statesP[i] = states + i; +} + +template +inline void PPM::setSampleRate(float sampleRate) { + bw_ppm_set_sample_rate(&coeffs, sampleRate); +} + +template +inline void PPM::reset() { + bw_ppm_reset_coeffs(&coeffs); + for (size_t i = 0; i < N_CHANNELS; i++) + bw_ppm_reset_state(&coeffs, states + i); +} + +template +inline void PPM::process( + const float * const *x, + float **y, + size_t nSamples) { + bw_ppm_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples); +} + +template +inline void PPM::process( + std::array x, + std::array y, + size_t nSamples) { + process(x.data(), y.data(), nSamples); +} + +template +inline void PPM::setIntegrationTau(float value) { + bw_ppm_set_integration_tau(&coeffs, value); +} + +template +inline float PPM::getYZ1(size_t channel) { + return bw_ppm_get_y_z1(states + channel); +} + } #endif diff --git a/include/bwpp_phaser.h b/include/bwpp_phaser.h deleted file mode 100644 index 26ce764..0000000 --- a/include/bwpp_phaser.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_PHASER_H -#define BWPP_PHASER_H - -#include -#include - -namespace Brickworks { - -/*! api {{{ - * ##### Brickworks::Phaser - * ```>>> */ -template -class Phaser { -public: - Phaser(); - - void setSampleRate(float sampleRate); - void reset(); - void process( - std::array x, - std::array y, - int nSamples); - - void setRate(float value); - void setCenter(float value); - void setAmount(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_phaser_coeffs coeffs; - bw_phaser_state states[N_CHANNELS]; - bw_phaser_state *statesP[N_CHANNELS]; -}; - -template -inline Phaser::Phaser() { - bw_phaser_init(&coeffs); - for (size_t i = 0; i < N_CHANNELS; i++) - statesP[i] = states + i; -} - -template -inline void Phaser::setSampleRate(float sampleRate) { - bw_phaser_set_sample_rate(&coeffs, sampleRate); -} - -template -inline void Phaser::reset() { - bw_phaser_reset_coeffs(&coeffs); - for (size_t i = 0; i < N_CHANNELS; i++) - bw_phaser_reset_state(&coeffs, states + i); -} - -template -inline void Phaser::process( - std::array x, - std::array y, - int nSamples) { - bw_phaser_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples); -} - -template -inline void Phaser::setRate(float value) { - bw_phaser_set_rate(&coeffs, value); -} - -template -inline void Phaser::setCenter(float value) { - bw_phaser_set_center(&coeffs, value); -} - -template -inline void Phaser::setAmount(float value) { - bw_phaser_set_amount(&coeffs, value); -} - -} - -#endif diff --git a/include/bwpp_pink_filt.h b/include/bwpp_pink_filt.h deleted file mode 100644 index 8b4851b..0000000 --- a/include/bwpp_pink_filt.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Brickworks - * - * Copyright (C) 2023 Orastron Srl unipersonale - * - * Brickworks is free software: you can repink_filtribute 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 pink_filtributed 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_PINK_FILT_H -#define BWPP_PINK_FILT_H - -#include -#include - -namespace Brickworks { - -/*! api {{{ - * ##### Brickworks::PinkFilt - * ```>>> */ -template -class PinkFilt { -public: - PinkFilt(); - - void setSampleRate(float sampleRate); - void reset(); - void process( - std::array x, - std::array y, - int nSamples); - - void setSampleRateScaling(bool value); - - float getScalingK(); -/*! <<<... - * } - * ``` - * }}} */ - -/*** 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_pink_filt_coeffs coeffs; - bw_pink_filt_state states[N_CHANNELS]; - bw_pink_filt_state *statesP[N_CHANNELS]; -}; - -template -inline PinkFilt::PinkFilt() { - bw_pink_filt_init(&coeffs); - for (size_t i = 0; i < N_CHANNELS; i++) - statesP[i] = states + i; -} - -template -inline void PinkFilt::setSampleRate(float sampleRate) { - bw_pink_filt_set_sample_rate(&coeffs, sampleRate); -} - -template -inline void PinkFilt::reset() { - for (size_t i = 0; i < N_CHANNELS; i++) - bw_pink_filt_reset_state(&coeffs, states + i); -} - -template -inline void PinkFilt::process( - std::array x, - std::array y, - int nSamples) { - bw_pink_filt_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples); -} - -template -inline void PinkFilt::setSampleRateScaling(bool value) { - bw_pink_filt_set_sample_rate_scaling(&coeffs, value); -} - -template -inline float PinkFilt::getScalingK() { - return bw_pink_filt_get_scaling_k(&coeffs); -} - -} - -#endif diff --git a/include/bwpp_ppm.h b/include/bwpp_ppm.h deleted file mode 100644 index 38b469a..0000000 --- a/include/bwpp_ppm.h +++ /dev/null @@ -1,102 +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_PPM_H -#define BWPP_PPM_H - -#include -#include - -namespace Brickworks { - -/*! api {{{ - * ##### Brickworks::PPM - * ```>>> */ -template -class PPM { -public: - PPM(); - - void setSampleRate(float sampleRate); - void reset(); - void process( - std::array x, - std::array y, - int nSamples); - - void setIntegrationTau(float value); - - float getYZ1(size_t channel); -/*! <<<... - * } - * ``` - * }}} */ - -/*** 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_ppm_coeffs coeffs; - bw_ppm_state states[N_CHANNELS]; - bw_ppm_state *statesP[N_CHANNELS]; -}; - -template -inline PPM::PPM() { - bw_ppm_init(&coeffs); - for (size_t i = 0; i < N_CHANNELS; i++) - statesP[i] = states + i; -} - -template -inline void PPM::setSampleRate(float sampleRate) { - bw_ppm_set_sample_rate(&coeffs, sampleRate); -} - -template -inline void PPM::reset() { - bw_ppm_reset_coeffs(&coeffs); - for (size_t i = 0; i < N_CHANNELS; i++) - bw_ppm_reset_state(&coeffs, states + i); -} - -template -inline void PPM::process( - std::array x, - std::array y, - int nSamples) { - bw_ppm_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples); -} - -template -inline void PPM::setIntegrationTau(float value) { - bw_ppm_set_integration_tau(&coeffs, value); -} - -template -inline float PPM::getYZ1(size_t channel) { - return bw_ppm_get_y_z1(states + channel); -} - -} - -#endif