polished bw_{mm1,mm2,noise_gate,noise_gen,notch} + removed corresponding bwpp and bwpp_note_queue + fixed examples

This commit is contained in:
Stefano D'Angelo 2023-08-13 04:55:29 +02:00
parent 22030272d9
commit 2a5d1721f8
16 changed files with 636 additions and 718 deletions

View File

@ -23,7 +23,7 @@
#include "platform.h"
#include <bwpp_mm2.h>
#include <bw_mm2.h>
using namespace Brickworks;

View File

@ -23,7 +23,7 @@
#include "platform.h"
#include <bwpp_noise_gate.h>
#include <bw_noise_gate.h>
using namespace Brickworks;

View File

@ -23,7 +23,7 @@
#include "platform.h"
#include <bwpp_notch.h>
#include <bw_notch.h>
using namespace Brickworks;

View File

@ -29,7 +29,7 @@
#include <bwpp_osc_tri.h>
#include <bwpp_osc_sin.h>
#include <bwpp_osc_filt.h>
#include <bwpp_noise_gen.h>
#include <bw_noise_gen.h>
#include <bwpp_pink_filt.h>
#include <bwpp_svf.h>
#include <bw_env_gen.h>

View File

@ -30,7 +30,7 @@
#include <bwpp_osc_tri.h>
#include <bwpp_osc_sin.h>
#include <bwpp_osc_filt.h>
#include <bwpp_noise_gen.h>
#include <bw_noise_gen.h>
#include <bwpp_pink_filt.h>
#include <bwpp_svf.h>
#include <bw_env_gen.h>

View File

@ -29,8 +29,15 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Now using <code>size_t</code> instead of
* <code>BW_SIZE_T</code>.</li>
* <li><code>bw_mm1_process()</code> and
* <code>bw_mm1_process_multi()</code> now use <code>size_t</code>
* to count samples and channels.</li>
* <li>Added more <code>const</code> specifiers to input
* arguments.</li>
* <li>Moved C++ code to C header.</li>
* <li>Added overladed C++ <code>process()</code> function taking
* C-style arrays as arguments.</li>
* <li>Removed usage of reserved identifiers.</li>
* </ul>
* </li>
* <li>Version <strong>0.6.0</strong>:
@ -59,8 +66,8 @@
* }}}
*/
#ifndef _BW_MM1_H
#define _BW_MM1_H
#ifndef BW_MM1_H
#define BW_MM1_H
#include <bw_common.h>
@ -71,13 +78,13 @@ extern "C" {
/*! api {{{
* #### bw_mm1_coeffs
* ```>>> */
typedef struct _bw_mm1_coeffs bw_mm1_coeffs;
typedef struct bw_mm1_coeffs bw_mm1_coeffs;
/*! <<<```
* Coefficients and related.
*
* #### bw_mm1_state
* ```>>> */
typedef struct _bw_mm1_state bw_mm1_state;
typedef struct bw_mm1_state bw_mm1_state;
/*! <<<```
* Internal state and related.
*
@ -101,10 +108,10 @@ static inline void bw_mm1_reset_coeffs(bw_mm1_coeffs *BW_RESTRICT coeffs);
*
* #### bw_mm1_reset_state()
* ```>>> */
static inline void bw_mm1_reset_state(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, float x0);
static inline void bw_mm1_reset_state(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_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 `x0`.
* and the quiescent/initial input value `x_0`.
*
* #### bw_mm1_update_coeffs_ctrl()
* ```>>> */
@ -127,7 +134,7 @@ static inline float bw_mm1_process1(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_
*
* #### bw_mm1_process()
* ```>>> */
static inline void bw_mm1_process(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, const float *x, float *y, int n_samples);
static inline void bw_mm1_process(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_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
@ -135,7 +142,7 @@ static inline void bw_mm1_process(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_stat
*
* #### bw_mm1_process_multi()
* ```>>> */
static inline void bw_mm1_process_multi(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples);
static inline void bw_mm1_process_multi(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_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
@ -202,14 +209,14 @@ static inline void bw_mm1_set_coeff_lp(bw_mm1_coeffs *BW_RESTRICT coeffs, float
extern "C" {
#endif
struct _bw_mm1_coeffs {
struct bw_mm1_coeffs {
// Sub-components
bw_lp1_coeffs lp1_coeffs;
bw_gain_coeffs gain_x_coeffs;
bw_gain_coeffs gain_lp_coeffs;
};
struct _bw_mm1_state {
struct bw_mm1_state {
bw_lp1_state lp1_state;
};
@ -235,8 +242,8 @@ static inline void bw_mm1_reset_coeffs(bw_mm1_coeffs *BW_RESTRICT coeffs) {
bw_gain_reset_coeffs(&coeffs->gain_lp_coeffs);
}
static inline void bw_mm1_reset_state(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, float x0) {
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x0);
static inline void bw_mm1_reset_state(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, float x_0) {
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, x_0);
}
static inline void bw_mm1_update_coeffs_ctrl(bw_mm1_coeffs *BW_RESTRICT coeffs) {
@ -258,19 +265,19 @@ static inline float bw_mm1_process1(const bw_mm1_coeffs *BW_RESTRICT coeffs, bw_
return vx + vlp;
}
static inline void bw_mm1_process(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, const float *x, float *y, int n_samples) {
static inline void bw_mm1_process(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples) {
bw_mm1_update_coeffs_ctrl(coeffs);
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_mm1_update_coeffs_audio(coeffs);
y[i] = bw_mm1_process1(coeffs, state, x[i]);
}
}
static inline void bw_mm1_process_multi(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples) {
static inline void bw_mm1_process_multi(bw_mm1_coeffs *BW_RESTRICT coeffs, bw_mm1_state * const *BW_RESTRICT state, const float * const *x, float **y, size_t n_channels, size_t n_samples) {
bw_mm1_update_coeffs_ctrl(coeffs);
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_mm1_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_mm1_process1(coeffs, state[j], x[j][i]);
}
}
@ -296,6 +303,114 @@ static inline void bw_mm1_set_coeff_lp(bw_mm1_coeffs *BW_RESTRICT coeffs, float
}
#ifdef __cplusplus
}
#include <array>
namespace Brickworks {
/*** Public C++ API ***/
/*! api_cpp {{{
* ##### Brickworks::MM1
* ```>>> */
template<size_t N_CHANNELS>
class MM1 {
public:
MM1();
void setSampleRate(float sampleRate);
void reset(float x_0 = 0.f);
void process(
const float * const *x,
float **y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setCutoff(float value);
void setPrewarpAtCutoff(bool value);
void setPrewarpFreq(float value);
void setCoeffX(float value);
void setCoeffLp(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_mm1_coeffs coeffs;
bw_mm1_state states[N_CHANNELS];
bw_mm1_state *statesP[N_CHANNELS];
};
template<size_t N_CHANNELS>
inline MM1<N_CHANNELS>::MM1() {
bw_mm1_init(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_mm1_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::reset(float x_0) {
bw_mm1_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_mm1_reset_state(&coeffs, states + i, x_0);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::process(
const float * const *x,
float **y,
size_t nSamples) {
bw_mm1_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), y.data(), nSamples);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setCutoff(float value) {
bw_mm1_set_cutoff(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setPrewarpAtCutoff(bool value) {
bw_mm1_set_prewarp_at_cutoff(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setPrewarpFreq(float value) {
bw_mm1_set_prewarp_freq(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setCoeffX(float value) {
bw_mm1_set_coeff_x(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setCoeffLp(float value) {
bw_mm1_set_coeff_lp(&coeffs, value);
}
}
#endif

View File

@ -29,8 +29,15 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Now using <code>size_t</code> instead of
* <code>BW_SIZE_T</code>.</li>
* <li><code>bw_mm2_process()</code> and
* <code>bw_mm2_process_multi()</code> now use <code>size_t</code>
* to count samples and channels.</li>
* <li>Added more <code>const</code> specifiers to input
* arguments.</li>
* <li>Moved C++ code to C header.</li>
* <li>Added overladed C++ <code>process()</code> function taking
* C-style arrays as arguments.</li>
* <li>Removed usage of reserved identifiers.</li>
* </ul>
* </li>
* <li>Version <strong>0.6.0</strong>:
@ -59,8 +66,8 @@
* }}}
*/
#ifndef _BW_MM2_H
#define _BW_MM2_H
#ifndef BW_MM2_H
#define BW_MM2_H
#include <bw_common.h>
@ -71,13 +78,13 @@ extern "C" {
/*! api {{{
* #### bw_mm2_coeffs
* ```>>> */
typedef struct _bw_mm2_coeffs bw_mm2_coeffs;
typedef struct bw_mm2_coeffs bw_mm2_coeffs;
/*! <<<```
* Coefficients and related.
*
* #### bw_mm2_state
* ```>>> */
typedef struct _bw_mm2_state bw_mm2_state;
typedef struct bw_mm2_state bw_mm2_state;
/*! <<<```
* Internal state and related.
*
@ -101,10 +108,10 @@ static inline void bw_mm2_reset_coeffs(bw_mm2_coeffs *BW_RESTRICT coeffs);
*
* #### bw_mm2_reset_state()
* ```>>> */
static inline void bw_mm2_reset_state(const bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_state *BW_RESTRICT state, float x0);
static inline void bw_mm2_reset_state(const bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_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 `x0`.
* and the quiescent/initial input value `x_0`.
*
* #### bw_mm2_update_coeffs_ctrl()
* ```>>> */
@ -127,7 +134,7 @@ static inline float bw_mm2_process1(const bw_mm2_coeffs *BW_RESTRICT coeffs, bw_
*
* #### bw_mm2_process()
* ```>>> */
static inline void bw_mm2_process(bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_state *BW_RESTRICT state, const float *x, float *y, int n_samples);
static inline void bw_mm2_process(bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_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
@ -135,7 +142,7 @@ static inline void bw_mm2_process(bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_stat
*
* #### bw_mm2_process_multi()
* ```>>> */
static inline void bw_mm2_process_multi(bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples);
static inline void bw_mm2_process_multi(bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_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
@ -228,7 +235,7 @@ static inline void bw_mm2_set_coeff_hp(bw_mm2_coeffs *BW_RESTRICT coeffs, float
extern "C" {
#endif
struct _bw_mm2_coeffs {
struct bw_mm2_coeffs {
// Sub-components
bw_svf_coeffs svf_coeffs;
bw_gain_coeffs gain_x_coeffs;
@ -237,7 +244,7 @@ struct _bw_mm2_coeffs {
bw_gain_coeffs gain_hp_coeffs;
};
struct _bw_mm2_state {
struct bw_mm2_state {
bw_svf_state svf_state;
};
@ -273,8 +280,8 @@ static inline void bw_mm2_reset_coeffs(bw_mm2_coeffs *BW_RESTRICT coeffs) {
bw_gain_reset_coeffs(&coeffs->gain_hp_coeffs);
}
static inline void bw_mm2_reset_state(const bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_state *BW_RESTRICT state, float x0) {
bw_svf_reset_state(&coeffs->svf_coeffs, &state->svf_state, x0);
static inline void bw_mm2_reset_state(const bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_state *BW_RESTRICT state, float x_0) {
bw_svf_reset_state(&coeffs->svf_coeffs, &state->svf_state, x_0);
}
static inline void bw_mm2_update_coeffs_ctrl(bw_mm2_coeffs *BW_RESTRICT coeffs) {
@ -303,19 +310,19 @@ static inline float bw_mm2_process1(const bw_mm2_coeffs *BW_RESTRICT coeffs, bw_
return vx + vlp + vbp + vhp;
}
static inline void bw_mm2_process(bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_state *BW_RESTRICT state, const float *x, float *y, int n_samples) {
static inline void bw_mm2_process(bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples) {
bw_mm2_update_coeffs_ctrl(coeffs);
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_mm2_update_coeffs_audio(coeffs);
y[i] = bw_mm2_process1(coeffs, state, x[i]);
}
}
static inline void bw_mm2_process_multi(bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples) {
static inline void bw_mm2_process_multi(bw_mm2_coeffs *BW_RESTRICT coeffs, bw_mm2_state * const *BW_RESTRICT state, const float * const *x, float **y, size_t n_channels, size_t n_samples) {
bw_mm2_update_coeffs_ctrl(coeffs);
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_mm2_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_mm2_process1(coeffs, state[j], x[j][i]);
}
}
@ -353,6 +360,132 @@ static inline void bw_mm2_set_coeff_hp(bw_mm2_coeffs *BW_RESTRICT coeffs, float
}
#ifdef __cplusplus
}
#include <array>
namespace Brickworks {
/*** Public C++ API ***/
/*! api_cpp {{{
* ##### Brickworks::MM2
* ```>>> */
template<size_t N_CHANNELS>
class MM2 {
public:
MM2();
void setSampleRate(float sampleRate);
void reset(float x_0 = 0.f);
void process(
const float * const *x,
float **y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setCutoff(float value);
void setQ(float value);
void setPrewarpAtCutoff(bool value);
void setPrewarpFreq(float value);
void setCoeffX(float value);
void setCoeffLp(float value);
void setCoeffBp(float value);
void setCoeffHp(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_mm2_coeffs coeffs;
bw_mm2_state states[N_CHANNELS];
bw_mm2_state *statesP[N_CHANNELS];
};
template<size_t N_CHANNELS>
inline MM2<N_CHANNELS>::MM2() {
bw_mm2_init(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_mm2_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::reset(float x_0) {
bw_mm2_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_mm2_reset_state(&coeffs, states + i, x_0);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::process(
const float * const *x,
float **y,
size_t nSamples) {
bw_mm2_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), y.data(), nSamples);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setCutoff(float value) {
bw_mm2_set_cutoff(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setQ(float value) {
bw_mm2_set_Q(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setPrewarpAtCutoff(bool value) {
bw_mm2_set_prewarp_at_cutoff(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setPrewarpFreq(float value) {
bw_mm2_set_prewarp_freq(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setCoeffX(float value) {
bw_mm2_set_coeff_x(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setCoeffLp(float value) {
bw_mm2_set_coeff_lp(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setCoeffBp(float value) {
bw_mm2_set_coeff_bp(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setCoeffHp(float value) {
bw_mm2_set_coeff_hp(&coeffs, value);
}
}
#endif

View File

@ -29,8 +29,15 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Now using <code>size_t</code> instead of
* <code>BW_SIZE_T</code>.</li>
* <li><code>bw_noise_gate_process()</code> and
* <code>bw_noise_gate_process_multi()</code> now use
* <code>size_t</code> to count samples and channels.</li>
* <li>Added more <code>const</code> specifiers to input
* arguments.</li>
* <li>Moved C++ code to C header.</li>
* <li>Added overladed C++ <code>process()</code> function taking
* C-style arrays as arguments.</li>
* <li>Removed usage of reserved identifiers.</li>
* </ul>
* </li>
* <li>Version <strong>0.6.0</strong>:
@ -53,8 +60,8 @@
* }}}
*/
#ifndef _BW_NOISE_GATE_H
#define _BW_NOISE_GATE_H
#ifndef BW_NOISE_GATE_H
#define BW_NOISE_GATE_H
#include <bw_common.h>
@ -65,13 +72,13 @@ extern "C" {
/*! api {{{
* #### bw_noise_gate_coeffs
* ```>>> */
typedef struct _bw_noise_gate_coeffs bw_noise_gate_coeffs;
typedef struct bw_noise_gate_coeffs bw_noise_gate_coeffs;
/*! <<<```
* Coefficients and related.
*
* #### bw_noise_gate_state
* ```>>> */
typedef struct _bw_noise_gate_state bw_noise_gate_state;
typedef struct bw_noise_gate_state bw_noise_gate_state;
/*! <<<```
* Internal state and related.
*
@ -121,7 +128,7 @@ static inline float bw_noise_gate_process1(const bw_noise_gate_coeffs *BW_RESTRI
*
* #### bw_noise_gate_process()
* ```>>> */
static inline void bw_noise_gate_process(bw_noise_gate_coeffs *BW_RESTRICT coeffs, bw_noise_gate_state *BW_RESTRICT state, const float *x, const float *x_sc, float *y, int n_samples);
static inline void bw_noise_gate_process(bw_noise_gate_coeffs *BW_RESTRICT coeffs, bw_noise_gate_state *BW_RESTRICT state, const float *x, const float *x_sc, float *y, size_t n_samples);
/*! <<<```
* Processes the first `n_samples` of the input buffer `x` and the first
* `n_samples` of the sidechain input buffer `x_sc`, and fills the first
@ -130,7 +137,7 @@ static inline void bw_noise_gate_process(bw_noise_gate_coeffs *BW_RESTRICT coeff
*
* #### bw_noise_gate_process_multi()
* ```>>> */
static inline void bw_noise_gate_process_multi(bw_noise_gate_coeffs *BW_RESTRICT coeffs, bw_noise_gate_state **BW_RESTRICT state, const float **x, const float **x_sc, float **y, int n_channels, int n_samples);
static inline void bw_noise_gate_process_multi(bw_noise_gate_coeffs *BW_RESTRICT coeffs, bw_noise_gate_state * const *BW_RESTRICT state, const float * const *x, const float * const *x_sc, float **y, size_t n_channels, size_t n_samples);
/*! <<<```
* Processes the first `n_samples` of the `n_channels` input buffers `x` and
* the first `n_samples` of the `n_channels` sidechain input buffers `x_sc`,
@ -201,7 +208,7 @@ static inline void bw_noise_gate_set_release_tau(bw_noise_gate_coeffs *BW_RESTRI
extern "C" {
#endif
struct _bw_noise_gate_coeffs {
struct bw_noise_gate_coeffs {
// Sub-noise_gateonents
bw_env_follow_coeffs env_follow_coeffs;
bw_one_pole_coeffs smooth_coeffs;
@ -216,7 +223,7 @@ struct _bw_noise_gate_coeffs {
float ratio;
};
struct _bw_noise_gate_state {
struct bw_noise_gate_state {
bw_env_follow_state env_follow_state;
};
@ -260,19 +267,19 @@ static inline float bw_noise_gate_process1(const bw_noise_gate_coeffs *BW_RESTRI
return env < thresh ? bw_pow2f(coeffs->kc * bw_log2f(thresh * bw_rcpf(env))) * x : x;
}
static inline void bw_noise_gate_process(bw_noise_gate_coeffs *BW_RESTRICT coeffs, bw_noise_gate_state *BW_RESTRICT state, const float *x, const float *x_sc, float *y, int n_samples) {
static inline void bw_noise_gate_process(bw_noise_gate_coeffs *BW_RESTRICT coeffs, bw_noise_gate_state *BW_RESTRICT state, const float *x, const float *x_sc, float *y, size_t n_samples) {
bw_noise_gate_update_coeffs_ctrl(coeffs);
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_noise_gate_update_coeffs_audio(coeffs);
y[i] = bw_noise_gate_process1(coeffs, state, x[i], x_sc[i]);
}
}
static inline void bw_noise_gate_process_multi(bw_noise_gate_coeffs *BW_RESTRICT coeffs, bw_noise_gate_state **BW_RESTRICT state, const float **x, const float **x_sc, float **y, int n_channels, int n_samples) {
static inline void bw_noise_gate_process_multi(bw_noise_gate_coeffs *BW_RESTRICT coeffs, bw_noise_gate_state * const *BW_RESTRICT state, const float * const *x, const float * const *x_sc, float **y, size_t n_channels, size_t n_samples) {
bw_noise_gate_update_coeffs_ctrl(coeffs);
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_noise_gate_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_noise_gate_process1(coeffs, state[j], x[j][i], x_sc[j][i]);
}
}
@ -298,6 +305,118 @@ static inline void bw_noise_gate_set_release_tau(bw_noise_gate_coeffs *BW_RESTRI
}
#ifdef __cplusplus
}
#include <array>
namespace Brickworks {
/*** Public C++ API ***/
/*! api_cpp {{{
* ##### Brickworks::NoiseGate
* ```>>> */
template<size_t N_CHANNELS>
class NoiseGate {
public:
NoiseGate();
void setSampleRate(float sampleRate);
void reset();
void process(
const float * const *x,
const float * const *xSC,
float **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,
size_t nSamples);
void setTreshLin(float value);
void setTreshDBFS(float value);
void setRatio(float value);
void setAttackTau(float value);
void setReleaseTau(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_noise_gate_coeffs coeffs;
bw_noise_gate_state states[N_CHANNELS];
bw_noise_gate_state *statesP[N_CHANNELS];
};
template<size_t N_CHANNELS>
inline NoiseGate<N_CHANNELS>::NoiseGate() {
bw_noise_gate_init(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_noise_gate_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::reset() {
bw_noise_gate_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_noise_gate_reset_state(&coeffs, states + i);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::process(
const float * const *x,
const float * const *xSC,
float **y,
size_t nSamples) {
bw_noise_gate_process_multi(&coeffs, statesP, x, xSC, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> xSC,
std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), xSC.data(), y.data(), nSamples);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setTreshLin(float value) {
bw_noise_gate_set_thresh_lin(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setTreshDBFS(float value) {
bw_noise_gate_set_thresh_dBFS(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setRatio(float value) {
bw_noise_gate_set_ratio(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setAttackTau(float value) {
bw_noise_gate_set_attack_tau(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setReleaseTau(float value) {
bw_noise_gate_set_release_tau(&coeffs, value);
}
}
#endif

View File

@ -33,8 +33,15 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Now using <code>size_t</code> instead of
* <code>BW_SIZE_T</code>.</li>
* <li><code>bw_noise_gen_process()</code> and
* <code>bw_noise_gen_process_multi()</code> now use
* <code>size_t</code> to count samples and channels.</li>
* <li>Added more <code>const</code> specifiers to input
* arguments.</li>
* <li>Moved C++ code to C header.</li>
* <li>Added overladed C++ <code>process()</code> function taking
* C-style arrays as arguments.</li>
* <li>Removed usage of reserved identifiers.</li>
* </ul>
* </li>
* <li>Version <strong>0.6.0</strong>:
@ -62,8 +69,8 @@
* }}}
*/
#ifndef _BW_NOISE_GEN_H
#define _BW_NOISE_GEN_H
#ifndef BW_NOISE_GEN_H
#define BW_NOISE_GEN_H
#include <bw_common.h>
@ -74,7 +81,7 @@ extern "C" {
/*! api {{{
* #### bw_noise_gen_coeffs
* ```>>> */
typedef struct _bw_noise_gen_coeffs bw_noise_gen_coeffs;
typedef struct bw_noise_gen_coeffs bw_noise_gen_coeffs;
/*! <<<```
* Coefficients and related.
*
@ -103,14 +110,14 @@ static inline float bw_noise_gen_process1_scaling(const bw_noise_gen_coeffs *BW_
*
* #### bw_noise_gen_process()
* ```>>> */
static inline void bw_noise_gen_process(bw_noise_gen_coeffs *BW_RESTRICT coeffs, float *BW_RESTRICT y, int n_samples);
static inline void bw_noise_gen_process(bw_noise_gen_coeffs *BW_RESTRICT coeffs, float *BW_RESTRICT y, size_t n_samples);
/*! <<<```
* Generates and fills the first `n_samples` of the output buffer `y` using
* `coeffs`.
*
* #### bw_noise_gen_process_multi()
* ```>>> */
static inline void bw_noise_gen_process_multi(bw_noise_gen_coeffs *BW_RESTRICT coeffs, float **y, int n_channels, int n_samples);
static inline void bw_noise_gen_process_multi(bw_noise_gen_coeffs *BW_RESTRICT coeffs, float **y, size_t n_channels, size_t n_samples);
/*! <<<```
* Generates and fills the first `n_samples` of the `n_channels` output
* buffers `y` using `coeffs`.
@ -153,7 +160,7 @@ static inline float bw_noise_gen_get_scaling_k(const bw_noise_gen_coeffs *BW_RES
extern "C" {
#endif
struct _bw_noise_gen_coeffs {
struct bw_noise_gen_coeffs {
// Coefficients
float scaling_k;
@ -179,17 +186,17 @@ static inline float bw_noise_gen_process1_scaling(const bw_noise_gen_coeffs *BW_
return coeffs->scaling_k * bw_randf(coeffs->state);
}
static inline void bw_noise_gen_process(bw_noise_gen_coeffs *BW_RESTRICT coeffs, float *BW_RESTRICT y, int n_samples) {
static inline void bw_noise_gen_process(bw_noise_gen_coeffs *BW_RESTRICT coeffs, float *BW_RESTRICT 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_noise_gen_process1(coeffs);
else
for (int i = 0; i < n_samples; i++)
for (size_t i = 0; i < n_samples; i++)
y[i] = bw_noise_gen_process1_scaling(coeffs);
}
static inline void bw_noise_gen_process_multi(bw_noise_gen_coeffs *BW_RESTRICT coeffs, float **y, int n_channels, int n_samples) {
for (int i = 0; i < n_channels; i++)
static inline void bw_noise_gen_process_multi(bw_noise_gen_coeffs *BW_RESTRICT coeffs, float **y, size_t n_channels, size_t n_samples) {
for (size_t i = 0; i < n_channels; i++)
bw_noise_gen_process(coeffs, y[i], n_samples);
}
@ -202,6 +209,81 @@ static inline float bw_noise_gen_get_scaling_k(const bw_noise_gen_coeffs *BW_RES
}
#ifdef __cplusplus
}
#include <array>
namespace Brickworks {
/*** Public C++ API ***/
/*! api_cpp {{{
* ##### Brickworks::NoiseGen
* ```>>> */
template<size_t N_CHANNELS>
class NoiseGen {
public:
NoiseGen(uint64_t *BW_RESTRICT state);
void setSampleRate(float sampleRate);
void process(
float **y,
size_t nSamples);
void process(
std::array<float *, N_CHANNELS> 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_noise_gen_coeffs coeffs;
};
template<size_t N_CHANNELS>
inline NoiseGen<N_CHANNELS>::NoiseGen(uint64_t *BW_RESTRICT state) {
bw_noise_gen_init(&coeffs, state);
}
template<size_t N_CHANNELS>
inline void NoiseGen<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_noise_gen_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void NoiseGen<N_CHANNELS>::process(
float **y,
size_t nSamples) {
bw_noise_gen_process_multi(&coeffs, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void NoiseGen<N_CHANNELS>::process(
std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(y.data(), nSamples);
}
template<size_t N_CHANNELS>
inline void NoiseGen<N_CHANNELS>::setSampleRateScaling(bool value) {
bw_noise_gen_set_sample_rate_scaling(&coeffs, value);
}
template<size_t N_CHANNELS>
inline float NoiseGen<N_CHANNELS>::getScalingK() {
return bw_noise_gen_get_scaling_k(&coeffs);
}
}
#endif

View File

@ -30,8 +30,15 @@
* <ul>
* <li>Version <strong>1.0.0</strong>:
* <ul>
* <li>Now using <code>size_t</code> instead of
* <code>BW_SIZE_T</code>.</li>
* <li><code>bw_notch_process()</code> and
* <code>bw_notch_process_multi()</code> now use
* <code>size_t</code> to count samples and channels.</li>
* <li>Added more <code>const</code> specifiers to input
* arguments.</li>
* <li>Moved C++ code to C header.</li>
* <li>Added overladed C++ <code>process()</code> function taking
* C-style arrays as arguments.</li>
* <li>Removed usage of reserved identifiers.</li>
* </ul>
* </li>
* <li>Version <strong>0.6.0</strong>:
@ -60,8 +67,8 @@
* }}}
*/
#ifndef _BW_NOTCH_H
#define _BW_NOTCH_H
#ifndef BW_NOTCH_H
#define BW_NOTCH_H
#include <bw_common.h>
@ -72,13 +79,13 @@ extern "C" {
/*! api {{{
* #### bw_notch_coeffs
* ```>>> */
typedef struct _bw_notch_coeffs bw_notch_coeffs;
typedef struct bw_notch_coeffs bw_notch_coeffs;
/*! <<<```
* Coefficients and related.
*
* #### bw_notch_state
* ```>>> */
typedef struct _bw_notch_state bw_notch_state;
typedef struct bw_notch_state bw_notch_state;
/*! <<<```
* Internal state and related.
*
@ -102,10 +109,10 @@ static inline void bw_notch_reset_coeffs(bw_notch_coeffs *BW_RESTRICT coeffs);
*
* #### bw_notch_reset_state()
* ```>>> */
static inline void bw_notch_reset_state(const bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_state *BW_RESTRICT state, float x0);
static inline void bw_notch_reset_state(const bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_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 `x0`.
* and the quiescent/initial input value `x_0`.
*
* #### bw_notch_update_coeffs_ctrl()
* ```>>> */
@ -128,7 +135,7 @@ static inline float bw_notch_process1(const bw_notch_coeffs *BW_RESTRICT coeffs,
*
* #### bw_notch_process()
* ```>>> */
static inline void bw_notch_process(bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_state *BW_RESTRICT state, const float *x, float *y, int n_samples);
static inline void bw_notch_process(bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_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
@ -136,7 +143,7 @@ static inline void bw_notch_process(bw_notch_coeffs *BW_RESTRICT coeffs, bw_notc
*
* #### bw_notch_process_multi()
* ```>>> */
static inline void bw_notch_process_multi(bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples);
static inline void bw_notch_process_multi(bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_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
@ -177,12 +184,12 @@ static inline void bw_notch_set_Q(bw_notch_coeffs *BW_RESTRICT coeffs, float val
extern "C" {
#endif
struct _bw_notch_coeffs {
struct bw_notch_coeffs {
// Sub-components
bw_svf_coeffs svf_coeffs;
};
struct _bw_notch_state {
struct bw_notch_state {
bw_svf_state svf_state;
};
@ -198,8 +205,8 @@ static inline void bw_notch_reset_coeffs(bw_notch_coeffs *BW_RESTRICT coeffs) {
bw_svf_reset_coeffs(&coeffs->svf_coeffs);
}
static inline void bw_notch_reset_state(const bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_state *BW_RESTRICT state, float x0) {
bw_svf_reset_state(&coeffs->svf_coeffs, &state->svf_state, x0);
static inline void bw_notch_reset_state(const bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_state *BW_RESTRICT state, float x_0) {
bw_svf_reset_state(&coeffs->svf_coeffs, &state->svf_state, x_0);
}
static inline void bw_notch_update_coeffs_ctrl(bw_notch_coeffs *BW_RESTRICT coeffs) {
@ -216,19 +223,19 @@ static inline float bw_notch_process1(const bw_notch_coeffs *BW_RESTRICT coeffs,
return lp + hp;
}
static inline void bw_notch_process(bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_state *BW_RESTRICT state, const float *x, float *y, int n_samples) {
static inline void bw_notch_process(bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples) {
bw_notch_update_coeffs_ctrl(coeffs);
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_notch_update_coeffs_audio(coeffs);
y[i] = bw_notch_process1(coeffs, state, x[i]);
}
}
static inline void bw_notch_process_multi(bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples) {
static inline void bw_notch_process_multi(bw_notch_coeffs *BW_RESTRICT coeffs, bw_notch_state * const *BW_RESTRICT state, const float * const *x, float **y, size_t n_channels, size_t n_samples) {
bw_notch_update_coeffs_ctrl(coeffs);
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_notch_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_notch_process1(coeffs, state[j], x[j][i]);
}
}
@ -242,6 +249,96 @@ static inline void bw_notch_set_Q(bw_notch_coeffs *BW_RESTRICT coeffs, float val
}
#ifdef __cplusplus
}
#include <array>
namespace Brickworks {
/*** Public C++ API ***/
/*! api_cpp {{{
* ##### Brickworks::Notch
* ```>>> */
template<size_t N_CHANNELS>
class Notch {
public:
Notch();
void setSampleRate(float sampleRate);
void reset(float x_0 = 0.f);
void process(
const float * const *x,
float **y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setCutoff(float value);
void setQ(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_notch_coeffs coeffs;
bw_notch_state states[N_CHANNELS];
bw_notch_state *statesP[N_CHANNELS];
};
template<size_t N_CHANNELS>
inline Notch<N_CHANNELS>::Notch() {
bw_notch_init(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<size_t N_CHANNELS>
inline void Notch<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_notch_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void Notch<N_CHANNELS>::reset(float x0) {
bw_notch_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_notch_reset_state(&coeffs, states + i, x0);
}
template<size_t N_CHANNELS>
inline void Notch<N_CHANNELS>::process(
const float * const *x,
float **y,
size_t nSamples) {
bw_notch_process_multi(&coeffs, statesP, x, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void Notch<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), y.data(), nSamples);
}
template<size_t N_CHANNELS>
inline void Notch<N_CHANNELS>::setCutoff(float value) {
bw_notch_set_cutoff(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void Notch<N_CHANNELS>::setQ(float value) {
bw_notch_set_Q(&coeffs, value);
}
}
#endif

View File

@ -1,119 +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 <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#ifndef BWPP_MM1_H
#define BWPP_MM1_H
#include <bw_mm1.h>
#include <array>
namespace Brickworks {
/*! api {{{
* ##### Brickworks::MM1
* ```>>> */
template<size_t N_CHANNELS>
class MM1 {
public:
MM1();
void setSampleRate(float sampleRate);
void reset(float x0 = 0.f);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples);
void setCutoff(float value);
void setPrewarpAtCutoff(bool value);
void setPrewarpFreq(float value);
void setCoeffX(float value);
void setCoeffLp(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_mm1_coeffs coeffs;
bw_mm1_state states[N_CHANNELS];
bw_mm1_state *statesP[N_CHANNELS];
};
template<size_t N_CHANNELS>
inline MM1<N_CHANNELS>::MM1() {
bw_mm1_init(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_mm1_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::reset(float x0) {
bw_mm1_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_mm1_reset_state(&coeffs, states + i, x0);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_mm1_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setCutoff(float value) {
bw_mm1_set_cutoff(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setPrewarpAtCutoff(bool value) {
bw_mm1_set_prewarp_at_cutoff(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setPrewarpFreq(float value) {
bw_mm1_set_prewarp_freq(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setCoeffX(float value) {
bw_mm1_set_coeff_x(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM1<N_CHANNELS>::setCoeffLp(float value) {
bw_mm1_set_coeff_lp(&coeffs, value);
}
}
#endif

View File

@ -1,137 +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 <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#ifndef BWPP_MM2_H
#define BWPP_MM2_H
#include <bw_mm2.h>
#include <array>
namespace Brickworks {
/*! api {{{
* ##### Brickworks::MM2
* ```>>> */
template<size_t N_CHANNELS>
class MM2 {
public:
MM2();
void setSampleRate(float sampleRate);
void reset(float x0 = 0.f);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples);
void setCutoff(float value);
void setQ(float value);
void setPrewarpAtCutoff(bool value);
void setPrewarpFreq(float value);
void setCoeffX(float value);
void setCoeffLp(float value);
void setCoeffBp(float value);
void setCoeffHp(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_mm2_coeffs coeffs;
bw_mm2_state states[N_CHANNELS];
bw_mm2_state *statesP[N_CHANNELS];
};
template<size_t N_CHANNELS>
inline MM2<N_CHANNELS>::MM2() {
bw_mm2_init(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_mm2_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::reset(float x0) {
bw_mm2_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_mm2_reset_state(&coeffs, states + i, x0);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_mm2_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setCutoff(float value) {
bw_mm2_set_cutoff(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setQ(float value) {
bw_mm2_set_Q(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setPrewarpAtCutoff(bool value) {
bw_mm2_set_prewarp_at_cutoff(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setPrewarpFreq(float value) {
bw_mm2_set_prewarp_freq(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setCoeffX(float value) {
bw_mm2_set_coeff_x(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setCoeffLp(float value) {
bw_mm2_set_coeff_lp(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setCoeffBp(float value) {
bw_mm2_set_coeff_bp(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void MM2<N_CHANNELS>::setCoeffHp(float value) {
bw_mm2_set_coeff_hp(&coeffs, value);
}
}
#endif

View File

@ -1,121 +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 <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#ifndef BWPP_NOISE_GATE_H
#define BWPP_NOISE_GATE_H
#include <bw_noise_gate.h>
#include <array>
namespace Brickworks {
/*! api {{{
* ##### Brickworks::NoiseGate
* ```>>> */
template<size_t N_CHANNELS>
class NoiseGate {
public:
NoiseGate();
void setSampleRate(float sampleRate);
void reset();
void process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> xSC,
std::array<float *, N_CHANNELS> y,
int nSamples);
void setTreshLin(float value);
void setTreshDBFS(float value);
void setRatio(float value);
void setAttackTau(float value);
void setReleaseTau(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_noise_gate_coeffs coeffs;
bw_noise_gate_state states[N_CHANNELS];
bw_noise_gate_state *statesP[N_CHANNELS];
};
template<size_t N_CHANNELS>
inline NoiseGate<N_CHANNELS>::NoiseGate() {
bw_noise_gate_init(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_noise_gate_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::reset() {
bw_noise_gate_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_noise_gate_reset_state(&coeffs, states + i);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> xSC,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_noise_gate_process_multi(&coeffs, statesP, x.data(), xSC.data(), y.data(), N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setTreshLin(float value) {
bw_noise_gate_set_thresh_lin(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setTreshDBFS(float value) {
bw_noise_gate_set_thresh_dBFS(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setRatio(float value) {
bw_noise_gate_set_ratio(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setAttackTau(float value) {
bw_noise_gate_set_attack_tau(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void NoiseGate<N_CHANNELS>::setReleaseTau(float value) {
bw_noise_gate_set_release_tau(&coeffs, value);
}
}
#endif

View File

@ -1,88 +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 <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#ifndef BWPP_NOISE_GEN_H
#define BWPP_NOISE_GEN_H
#include <bw_noise_gen.h>
#include <array>
namespace Brickworks {
/*! api {{{
* ##### Brickworks::NoiseGen
* ```>>> */
template<size_t N_CHANNELS>
class NoiseGen {
public:
NoiseGen(uint64_t *BW_RESTRICT state);
void setSampleRate(float sampleRate);
void process(
std::array<float *, N_CHANNELS> 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_noise_gen_coeffs coeffs;
};
template<size_t N_CHANNELS>
inline NoiseGen<N_CHANNELS>::NoiseGen(uint64_t *BW_RESTRICT state) {
bw_noise_gen_init(&coeffs, state);
}
template<size_t N_CHANNELS>
inline void NoiseGen<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_noise_gen_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void NoiseGen<N_CHANNELS>::process(
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_noise_gen_process_multi(&coeffs, y.data(), N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void NoiseGen<N_CHANNELS>::setSampleRateScaling(bool value) {
bw_noise_gen_set_sample_rate_scaling(&coeffs, value);
}
template<size_t N_CHANNELS>
inline float NoiseGen<N_CHANNELS>::getScalingK() {
return bw_noise_gen_get_scaling_k(&coeffs);
}
}
#endif

View File

@ -1,101 +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 <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#ifndef BWPP_NOTCH_H
#define BWPP_NOTCH_H
#include <bw_notch.h>
#include <array>
namespace Brickworks {
/*! api {{{
* ##### Brickworks::Notch
* ```>>> */
template<size_t N_CHANNELS>
class Notch {
public:
Notch();
void setSampleRate(float sampleRate);
void reset(float x0 = 0.f);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples);
void setCutoff(float value);
void setQ(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_notch_coeffs coeffs;
bw_notch_state states[N_CHANNELS];
bw_notch_state *statesP[N_CHANNELS];
};
template<size_t N_CHANNELS>
inline Notch<N_CHANNELS>::Notch() {
bw_notch_init(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<size_t N_CHANNELS>
inline void Notch<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_notch_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void Notch<N_CHANNELS>::reset(float x0) {
bw_notch_reset_coeffs(&coeffs);
for (size_t i = 0; i < N_CHANNELS; i++)
bw_notch_reset_state(&coeffs, states + i, x0);
}
template<size_t N_CHANNELS>
inline void Notch<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_notch_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void Notch<N_CHANNELS>::setCutoff(float value) {
bw_notch_set_cutoff(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void Notch<N_CHANNELS>::setQ(float value) {
bw_notch_set_Q(&coeffs, value);
}
}
#endif

View File

@ -1,62 +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 <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#ifndef BWPP_NOTE_QUEUE_H
#define BWPP_NOTE_QUEUE_H
#include <bw_note_queue.h>
namespace Brickworks {
/*! api {{{
* ##### Brickworks::NoteQueue
* ```>>> */
class NoteQueue {
public:
NoteQueue();
void clear();
void add(unsigned char note, bool pressed, float velocity, bool force_went_off);
bw_note_queue queue;
};
/*! <<<```
* }}} */
/*** 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. */
inline NoteQueue::NoteQueue() {
bw_note_queue_reset(&queue);
}
inline void NoteQueue::clear() {
bw_note_queue_clear(&queue);
}
inline void NoteQueue::add(unsigned char note, bool pressed, float velocity, bool force_went_off) {
bw_note_queue_add(&queue, note, pressed, velocity, force_went_off);
}
}
#endif