polished bw_osc* + removed bwpp_osc* + fixed examples

This commit is contained in:
Stefano D'Angelo 2023-08-13 05:28:45 +02:00
parent 2a5d1721f8
commit 40503b7cb1
13 changed files with 488 additions and 500 deletions

View File

@ -24,11 +24,11 @@
#include "platform.h"
#include <bwpp_phase_gen.h>
#include <bwpp_osc_saw.h>
#include <bwpp_osc_pulse.h>
#include <bwpp_osc_tri.h>
#include <bwpp_osc_sin.h>
#include <bwpp_osc_filt.h>
#include <bw_osc_saw.h>
#include <bw_osc_pulse.h>
#include <bw_osc_tri.h>
#include <bw_osc_sin.h>
#include <bw_osc_filt.h>
#include <bw_noise_gen.h>
#include <bwpp_pink_filt.h>
#include <bwpp_svf.h>

View File

@ -25,11 +25,11 @@
#include <bw_note_queue.h>
#include <bwpp_phase_gen.h>
#include <bwpp_osc_saw.h>
#include <bwpp_osc_pulse.h>
#include <bwpp_osc_tri.h>
#include <bwpp_osc_sin.h>
#include <bwpp_osc_filt.h>
#include <bw_osc_saw.h>
#include <bw_osc_pulse.h>
#include <bw_osc_tri.h>
#include <bw_osc_sin.h>
#include <bw_osc_filt.h>
#include <bw_noise_gen.h>
#include <bwpp_pink_filt.h>
#include <bwpp_svf.h>

View File

@ -24,8 +24,8 @@
#include "platform.h"
#include <bwpp_phase_gen.h>
#include <bwpp_osc_pulse.h>
#include <bwpp_osc_filt.h>
#include <bw_osc_pulse.h>
#include <bw_osc_filt.h>
#include <bwpp_svf.h>
#include <bw_env_gen.h>
#include <bw_gain.h>

View File

@ -35,8 +35,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_osc_filt_process()</code> and
* <code>bw_osc_filt_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>:
@ -64,8 +71,8 @@
* }}}
*/
#ifndef _BW_OSC_FILT_H
#define _BW_OSC_FILT_H
#ifndef BW_OSC_FILT_H
#define BW_OSC_FILT_H
#include <bw_common.h>
@ -76,7 +83,7 @@ extern "C" {
/*! api {{{
* #### bw_osc_filt_state
* ```>>> */
typedef struct _bw_osc_filt_state bw_osc_filt_state;
typedef struct bw_osc_filt_state bw_osc_filt_state;
/*! <<<```
* Internal state and related.
*
@ -95,7 +102,7 @@ static inline float bw_osc_filt_process1(bw_osc_filt_state *BW_RESTRICT state, f
*
* #### bw_osc_filt_process()
* ```>>> */
static inline void bw_osc_filt_process(bw_osc_filt_state *BW_RESTRICT state, const float *x, float *y, int n_samples);
static inline void bw_osc_filt_process(bw_osc_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 and updating
@ -103,7 +110,7 @@ static inline void bw_osc_filt_process(bw_osc_filt_state *BW_RESTRICT state, con
*
* #### bw_osc_filt_process_multi()
* ```>>> */
static inline void bw_osc_filt_process_multi(bw_osc_filt_state **BW_RESTRICT state, const float **x, float **y, int n_channels, int n_samples);
static inline void bw_osc_filt_process_multi(bw_osc_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
@ -123,7 +130,7 @@ static inline void bw_osc_filt_process_multi(bw_osc_filt_state **BW_RESTRICT sta
extern "C" {
#endif
struct _bw_osc_filt_state {
struct bw_osc_filt_state {
float x_z1;
float y_z1;
};
@ -140,17 +147,85 @@ static inline float bw_osc_filt_process1(bw_osc_filt_state *BW_RESTRICT state, f
return y;
}
static inline void bw_osc_filt_process(bw_osc_filt_state *BW_RESTRICT state, const float *x, float *y, int n_samples) {
for (int i = 0; i < n_samples; i++)
static inline void bw_osc_filt_process(bw_osc_filt_state *BW_RESTRICT state, const float *x, float *y, size_t n_samples) {
for (size_t i = 0; i < n_samples; i++)
y[i] = bw_osc_filt_process1(state, x[i]);
}
static inline void bw_osc_filt_process_multi(bw_osc_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_osc_filt_process_multi(bw_osc_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_osc_filt_process(state[i], x[i], y[i], n_samples);
}
#ifdef __cplusplus
}
#include <array>
namespace Brickworks {
/*** Public C++ API ***/
/*! api_cpp {{{
* ##### Brickworks::OscFilt
* ```>>> */
template<size_t N_CHANNELS>
class OscFilt {
public:
OscFilt();
void reset();
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);
/*! <<<...
* }
* ```
* }}} */
/*** 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_osc_filt_state states[N_CHANNELS];
bw_osc_filt_state *statesP[N_CHANNELS];
};
template<size_t N_CHANNELS>
inline OscFilt<N_CHANNELS>::OscFilt() {
for (size_t i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<size_t N_CHANNELS>
inline void OscFilt<N_CHANNELS>::reset() {
for (size_t i = 0; i < N_CHANNELS; i++)
bw_osc_filt_reset_state(states + i);
}
template<size_t N_CHANNELS>
inline void OscFilt<N_CHANNELS>::process(
const float * const *x,
float **y,
size_t nSamples) {
bw_osc_filt_process_multi(statesP, x, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void OscFilt<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);
}
}
#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_osc_pulse_process()</code> and
* <code>bw_osc_pulse_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>:
@ -67,8 +74,8 @@
* }}}
*/
#ifndef _BW_OSC_PULSE_H
#define _BW_OSC_PULSE_H
#ifndef BW_OSC_PULSE_H
#define BW_OSC_PULSE_H
#include <bw_common.h>
@ -79,7 +86,7 @@ extern "C" {
/*! api {{{
* #### bw_osc_pulse_coeffs
* ```>>> */
typedef struct _bw_osc_pulse_coeffs bw_osc_pulse_coeffs;
typedef struct bw_osc_pulse_coeffs bw_osc_pulse_coeffs;
/*! <<<```
* Coefficients and related.
*
@ -129,7 +136,7 @@ static inline float bw_osc_pulse_process1_antialias(const bw_osc_pulse_coeffs *B
*
* #### bw_osc_pulse_process()
* ```>>> */
static inline void bw_osc_pulse_process(bw_osc_pulse_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, int n_samples);
static inline void bw_osc_pulse_process(bw_osc_pulse_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, size_t n_samples);
/*! <<<```
* Processes the first `n_samples` of the input buffer `x`, containing the
* normalized phase signal, and fills the first `n_samples` of the output
@ -140,7 +147,7 @@ static inline void bw_osc_pulse_process(bw_osc_pulse_coeffs *BW_RESTRICT coeffs,
*
* #### bw_osc_pulse_process_multi()
* ```>>> */
static inline void bw_osc_pulse_process_multi(bw_osc_pulse_coeffs *BW_RESTRICT coeffs, const float **x, const float **x_phase_inc, float **y, int n_channels, int n_samples);
static inline void bw_osc_pulse_process_multi(bw_osc_pulse_coeffs *BW_RESTRICT coeffs, const float * const *x, const float * const *x_phase_inc, float **y, size_t n_channels, size_t n_samples);
/*! <<<```
* Processes the first `n_samples` of the `n_channels` input buffers `x`,
* containing the normalized phase signals, and fills the first `n_samples`
@ -186,7 +193,7 @@ static inline void bw_osc_pulse_set_pulse_width(bw_osc_pulse_coeffs *BW_RESTRICT
extern "C" {
#endif
struct _bw_osc_pulse_coeffs {
struct bw_osc_pulse_coeffs {
// Sub-components
bw_one_pole_coeffs smooth_coeffs;
bw_one_pole_state smooth_state;
@ -226,7 +233,7 @@ static inline float bw_osc_pulse_process1(const bw_osc_pulse_coeffs *BW_RESTRICT
}
// PolyBLEP residual based on Parzen window (4th-order B-spline), one-sided (x in [0, 2])
static inline float _bw_osc_pulse_blep_diff(float x) {
static inline float bw_osc_pulse_blep_diff(float x) {
return x < 1.f
? x * ((0.25f * x - 0.6666666666666666f) * x * x + 1.333333333333333f) - 1.f
: x * (x * ((0.6666666666666666f - 0.08333333333333333f * x) * x - 2.f) + 2.666666666666667f) - 1.333333333333333f;
@ -243,41 +250,41 @@ static inline float bw_osc_pulse_process1_antialias(const bw_osc_pulse_coeffs *B
const float s_1_m_phase = 1.f - x;
const float s_1_m_phase_2 = 1.f - phase_2;
if (s_1_m_phase < phase_inc_2)
v -= _bw_osc_pulse_blep_diff(s_1_m_phase * phase_inc_rcp);
v -= bw_osc_pulse_blep_diff(s_1_m_phase * phase_inc_rcp);
if (s_1_m_phase_2 < phase_inc_2)
v += _bw_osc_pulse_blep_diff(s_1_m_phase_2 * phase_inc_rcp);
v += bw_osc_pulse_blep_diff(s_1_m_phase_2 * phase_inc_rcp);
if (x < phase_inc_2)
v += _bw_osc_pulse_blep_diff(x * phase_inc_rcp);
v += bw_osc_pulse_blep_diff(x * phase_inc_rcp);
if (phase_2 < phase_inc_2)
v -= _bw_osc_pulse_blep_diff(phase_2 * phase_inc_rcp);
v -= bw_osc_pulse_blep_diff(phase_2 * phase_inc_rcp);
}
return v;
}
static inline void bw_osc_pulse_process(bw_osc_pulse_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, int n_samples) {
static inline void bw_osc_pulse_process(bw_osc_pulse_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, size_t n_samples) {
if (coeffs->antialiasing)
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_osc_pulse_update_coeffs_audio(coeffs);
y[i] = bw_osc_pulse_process1_antialias(coeffs, x[i], x_phase_inc[i]);
}
else
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_osc_pulse_update_coeffs_audio(coeffs);
y[i] = bw_osc_pulse_process1(coeffs, x[i]);
}
}
static inline void bw_osc_pulse_process_multi(bw_osc_pulse_coeffs *BW_RESTRICT coeffs, const float **x, const float **x_phase_inc, float **y, int n_channels, int n_samples) {
static inline void bw_osc_pulse_process_multi(bw_osc_pulse_coeffs *BW_RESTRICT coeffs, const float * const *x, const float * const *x_phase_inc, float **y, size_t n_channels, size_t n_samples) {
if (coeffs->antialiasing)
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_osc_pulse_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_osc_pulse_process1_antialias(coeffs, x[j][i], x_phase_inc[j][i]);
}
else
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_osc_pulse_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_osc_pulse_process1(coeffs, x[j][i]);
}
}
@ -291,6 +298,94 @@ static inline void bw_osc_pulse_set_pulse_width(bw_osc_pulse_coeffs *BW_RESTRICT
}
#ifdef __cplusplus
}
#include <array>
namespace Brickworks {
/*** Public C++ API ***/
/*! api_cpp {{{
* ##### Brickworks::OscPulse
* ```>>> */
template<size_t N_CHANNELS>
class OscPulse {
public:
OscPulse();
void setSampleRate(float sampleRate);
void reset();
void process(
const float * const *x,
const float * const *x_phase_inc,
float **y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setAntialiasing(bool value);
void setPulseWidth(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_osc_pulse_coeffs coeffs;
};
template<size_t N_CHANNELS>
inline OscPulse<N_CHANNELS>::OscPulse() {
bw_osc_pulse_init(&coeffs);
}
template<size_t N_CHANNELS>
inline void OscPulse<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_osc_pulse_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void OscPulse<N_CHANNELS>::reset() {
bw_osc_pulse_reset_coeffs(&coeffs);
}
template<size_t N_CHANNELS>
inline void OscPulse<N_CHANNELS>::process(
const float * const *x,
const float * const *x_phase_inc,
float **y,
size_t nSamples) {
bw_osc_pulse_process_multi(&coeffs, x, x_phase_inc, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void OscPulse<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), x_phase_inc.data(), y.data(), nSamples);
}
template<size_t N_CHANNELS>
inline void OscPulse<N_CHANNELS>::setAntialiasing(bool value) {
bw_osc_pulse_set_antialiasing(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void OscPulse<N_CHANNELS>::setPulseWidth(float value) {
bw_osc_pulse_set_pulse_width(&coeffs, value);
}
}
#endif

View File

@ -32,8 +32,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_osc_saw_process()</code> and
* <code>bw_osc_saw_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>:
@ -66,8 +73,8 @@
* }}}
*/
#ifndef _BW_OSC_SAW_H
#define _BW_OSC_SAW_H
#ifndef BW_OSC_SAW_H
#define BW_OSC_SAW_H
#include <bw_common.h>
@ -78,7 +85,7 @@ extern "C" {
/*! api {{{
* #### bw_osc_saw_coeffs
* ```>>> */
typedef struct _bw_osc_saw_coeffs bw_osc_saw_coeffs;
typedef struct bw_osc_saw_coeffs bw_osc_saw_coeffs;
/*! <<<```
* Coefficients and related.
*
@ -104,7 +111,7 @@ static inline float bw_osc_saw_process1_antialias(const bw_osc_saw_coeffs *BW_RE
*
* #### bw_osc_saw_process()
* ```>>> */
static inline void bw_osc_saw_process(bw_osc_saw_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, int n_samples);
static inline void bw_osc_saw_process(bw_osc_saw_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, size_t n_samples);
/*! <<<```
* Processes the first `n_samples` of the input buffer `x`, containing the
* normalized phase signal, and fills the first `n_samples` of the output
@ -115,7 +122,7 @@ static inline void bw_osc_saw_process(bw_osc_saw_coeffs *BW_RESTRICT coeffs, con
*
* #### bw_osc_saw_process_multi()
* ```>>> */
static inline void bw_osc_saw_process_multi(bw_osc_saw_coeffs *BW_RESTRICT coeffs, const float **x, const float **x_phase_inc, float **y, int n_channels, int n_samples);
static inline void bw_osc_saw_process_multi(bw_osc_saw_coeffs *BW_RESTRICT coeffs, const float * const *x, const float * const *x_phase_inc, float **y, size_t n_channels, size_t n_samples);
/*! <<<```
* Processes the first `n_samples` of the `n_channels` input buffers `x`,
* containing the normalized phase signals, and fills the first `n_samples`
@ -150,7 +157,7 @@ static inline void bw_osc_saw_set_antialiasing(bw_osc_saw_coeffs *BW_RESTRICT co
extern "C" {
#endif
struct _bw_osc_saw_coeffs {
struct bw_osc_saw_coeffs {
// Parameters
char antialiasing;
};
@ -165,7 +172,7 @@ static inline float bw_osc_saw_process1(const bw_osc_saw_coeffs *BW_RESTRICT coe
}
// PolyBLEP residual based on Parzen window (4th-order B-spline), one-sided (x in [0, 2])
static inline float _bw_osc_saw_blep_diff(float x) {
static inline float bw_osc_saw_blep_diff(float x) {
return x < 1.f
? x * ((0.25f * x - 0.6666666666666666f) * x * x + 1.333333333333333f) - 1.f
: x * (x * ((0.6666666666666666f - 0.08333333333333333f * x) * x - 2.f) + 2.666666666666667f) - 1.333333333333333f;
@ -179,28 +186,28 @@ static inline float bw_osc_saw_process1_antialias(const bw_osc_saw_coeffs *BW_RE
const float phase_inc_2 = x_phase_inc + x_phase_inc;
const float phase_inc_rcp = bw_rcpf(x_phase_inc);
if (s_1_m_phase < phase_inc_2)
v += _bw_osc_saw_blep_diff(s_1_m_phase * phase_inc_rcp);
v += bw_osc_saw_blep_diff(s_1_m_phase * phase_inc_rcp);
if (x < phase_inc_2)
v -= _bw_osc_saw_blep_diff(x * phase_inc_rcp);
v -= bw_osc_saw_blep_diff(x * phase_inc_rcp);
}
return v;
}
static inline void bw_osc_saw_process(bw_osc_saw_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, int n_samples) {
static inline void bw_osc_saw_process(bw_osc_saw_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, size_t n_samples) {
if (coeffs->antialiasing)
for (int i = 0; i < n_samples; i++)
for (size_t i = 0; i < n_samples; i++)
y[i] = bw_osc_saw_process1_antialias(coeffs, x[i], x_phase_inc[i]);
else
for (int i = 0; i < n_samples; i++)
for (size_t i = 0; i < n_samples; i++)
y[i] = bw_osc_saw_process1(coeffs, x[i]);
}
static inline void bw_osc_saw_process_multi(bw_osc_saw_coeffs *BW_RESTRICT coeffs, const float **x, const float **x_phase_inc, float **y, int n_channels, int n_samples) {
static inline void bw_osc_saw_process_multi(bw_osc_saw_coeffs *BW_RESTRICT coeffs, const float * const *x, const float * const *x_phase_inc, float **y, size_t n_channels, size_t n_samples) {
if (x_phase_inc != NULL)
for (int i = 0; i < n_channels; i++)
for (size_t i = 0; i < n_channels; i++)
bw_osc_saw_process(coeffs, x[i], x_phase_inc[i], y[i], n_samples);
else
for (int i = 0; i < n_channels; i++)
for (size_t i = 0; i < n_channels; i++)
bw_osc_saw_process(coeffs, x[i], NULL, y[i], n_samples);
}
@ -209,6 +216,76 @@ static inline void bw_osc_saw_set_antialiasing(bw_osc_saw_coeffs *BW_RESTRICT co
}
#ifdef __cplusplus
}
#include <array>
namespace Brickworks {
/*** Public C++ API ***/
/*! api_cpp {{{
* ##### Brickworks::OscSaw
* ```>>> */
template<size_t N_CHANNELS>
class OscSaw {
public:
OscSaw();
void process(
const float * const *x,
const float * const *x_phase_inc,
float **y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setAntialiasing(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_osc_saw_coeffs coeffs;
};
template<size_t N_CHANNELS>
inline OscSaw<N_CHANNELS>::OscSaw() {
bw_osc_saw_init(&coeffs);
}
template<size_t N_CHANNELS>
inline void OscSaw<N_CHANNELS>::process(
const float * const *x,
const float * const *x_phase_inc,
float **y,
size_t nSamples) {
bw_osc_saw_process_multi(&coeffs, x, x_phase_inc, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void OscSaw<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), x_phase_inc.data(), y.data(), nSamples);
}
template<size_t N_CHANNELS>
inline void OscSaw<N_CHANNELS>::setAntialiasing(bool value) {
bw_osc_saw_set_antialiasing(&coeffs, value);
}
}
#endif

View File

@ -32,8 +32,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_osc_sin_process()</code> and
* <code>bw_osc_sin_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>oscSinProcess()</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>:
@ -61,8 +68,8 @@
* }}}
*/
#ifndef _BW_OSC_SIN_H
#define _BW_OSC_SIN_H
#ifndef BW_OSC_SIN_H
#define BW_OSC_SIN_H
#include <bw_common.h>
@ -81,7 +88,7 @@ static inline float bw_osc_sin_process1(float x);
*
* #### bw_osc_sin_process()
* ```>>> */
static inline void bw_osc_sin_process(const float *x, float *y, int n_samples);
static inline void bw_osc_sin_process(const float *x, float *y, size_t n_samples);
/*! <<<```
* Processes the first `n_samples` of the input buffer `x`, containing the
* normalized phase signal, and fills the first `n_samples` of the output
@ -89,7 +96,7 @@ static inline void bw_osc_sin_process(const float *x, float *y, int n_samples);
*
* #### bw_osc_sin_process_multi()
* ```>>> */
static inline void bw_osc_sin_process_multi(const float **x, float **y, int n_channels, int n_samples);
static inline void bw_osc_sin_process_multi(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`,
* containing the normalized phase signals, and fills the first `n_samples`
@ -115,17 +122,63 @@ static inline float bw_osc_sin_process1(float x) {
return bw_sin2pif(x);
}
static inline void bw_osc_sin_process(const float *x, float *y, int n_samples) {
for (int i = 0; i < n_samples; i++)
static inline void bw_osc_sin_process(const float *x, float *y, size_t n_samples) {
for (size_t i = 0; i < n_samples; i++)
y[i] = bw_osc_sin_process1(x[i]);
}
static inline void bw_osc_sin_process_multi(const float **x, float **y, int n_channels, int n_samples) {
for (int i = 0; i < n_channels; i++)
static inline void bw_osc_sin_process_multi(const float * const *x, float **y, size_t n_channels, size_t n_samples) {
for (size_t i = 0; i < n_channels; i++)
bw_osc_sin_process(x[i], y[i], n_samples);
}
#ifdef __cplusplus
}
#include <array>
namespace Brickworks {
/*** Public C++ API ***/
/*! api_cpp {{{
* ##### Brickworks::oscSinProcess
* ```>>> */
template<size_t N_CHANNELS>
void oscSinProcess(
const float * const *x,
float **y,
size_t nSamples);
template<size_t N_CHANNELS>
void oscSinProcess(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
size_t nSamples);
/*! <<<```
* }}} */
/*** 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. */
template<size_t N_CHANNELS>
inline void oscSinProcess(
const float * const *x,
float **y,
size_t nSamples) {
bw_osc_sin_process_multi(x, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void oscSinProcess(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
size_t nSamples) {
oscSinProcess<N_CHANNELS>(x.data(), y.data(), nSamples);
}
}
#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_osc_tri_process()</code> and
* <code>bw_osc_tri_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>:
@ -69,8 +76,8 @@
* }}}
*/
#ifndef _BW_OSC_TRI_H
#define _BW_OSC_TRI_H
#ifndef BW_OSC_TRI_H
#define BW_OSC_TRI_H
#include <bw_common.h>
@ -81,7 +88,7 @@ extern "C" {
/*! api {{{
* #### bw_osc_tri_coeffs
* ```>>> */
typedef struct _bw_osc_tri_coeffs bw_osc_tri_coeffs;
typedef struct bw_osc_tri_coeffs bw_osc_tri_coeffs;
/*! <<<```
* Coefficients and related.
*
@ -131,7 +138,7 @@ static inline float bw_osc_tri_process1_antialias(const bw_osc_tri_coeffs *BW_RE
*
* #### bw_osc_tri_process()
* ```>>> */
static inline void bw_osc_tri_process(bw_osc_tri_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, int n_samples);
static inline void bw_osc_tri_process(bw_osc_tri_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, size_t n_samples);
/*! <<<```
* Processes the first `n_samples` of the input buffer `x`, containing the
* normalized phase signal, and fills the first `n_samples` of the output
@ -142,7 +149,7 @@ static inline void bw_osc_tri_process(bw_osc_tri_coeffs *BW_RESTRICT coeffs, con
*
* #### bw_osc_tri_process_multi()
* ```>>> */
static inline void bw_osc_tri_process_multi(bw_osc_tri_coeffs *BW_RESTRICT coeffs, const float **x, const float **x_phase_inc, float **y, int n_channels, int n_samples);
static inline void bw_osc_tri_process_multi(bw_osc_tri_coeffs *BW_RESTRICT coeffs, const float * const *x, const float * const *x_phase_inc, float **y, size_t n_channels, size_t n_samples);
/*! <<<```
* Processes the first `n_samples` of the `n_channels` input buffers `x`,
* containing the normalized phase signals, and fills the first `n_samples`
@ -188,7 +195,7 @@ static inline void bw_osc_tri_set_slope(bw_osc_tri_coeffs *BW_RESTRICT coeffs, f
extern "C" {
#endif
struct _bw_osc_tri_coeffs {
struct bw_osc_tri_coeffs {
// Sub-components
bw_one_pole_coeffs smooth_coeffs;
bw_one_pole_state smooth_state;
@ -229,7 +236,7 @@ static inline float bw_osc_tri_process1(const bw_osc_tri_coeffs *BW_RESTRICT coe
}
// PolyBLAMP residual based on Parzen window (4th-order B-spline), one-sided (x in [0, 2])
static inline float _bw_osc_tri_blamp_diff(float x) {
static inline float bw_osc_tri_blamp_diff(float x) {
return x < 1.f
? x * (x * ((0.05f * x - 0.1666666666666667f) * x * x + 0.6666666666666666f) - 1.0f) + 0.4666666666666667f
: x * (x * (x * ((0.1666666666666667f - 0.01666666666666667f * x) * x - 0.6666666666666666f) + 1.333333333333333f) - 1.333333333333333f) + 0.5333333333333333f;
@ -250,42 +257,42 @@ static inline float bw_osc_tri_process1_antialias(const bw_osc_tri_coeffs *BW_RE
const float s_1_m_phase_2 = 1.f - phase_2;
float blamp = 0.f;
if (s_1_m_phase_2 < phase_inc_2)
blamp += _bw_osc_tri_blamp_diff(s_1_m_phase_2 * phase_inc_rcp);
blamp += bw_osc_tri_blamp_diff(s_1_m_phase_2 * phase_inc_rcp);
if (s_1_m_phase < phase_inc_2)
blamp -= _bw_osc_tri_blamp_diff(s_1_m_phase * phase_inc_rcp);
blamp -= bw_osc_tri_blamp_diff(s_1_m_phase * phase_inc_rcp);
if (x < phase_inc_2)
blamp -= _bw_osc_tri_blamp_diff(x * phase_inc_rcp);
blamp -= bw_osc_tri_blamp_diff(x * phase_inc_rcp);
if (phase_2 < phase_inc_2)
blamp += _bw_osc_tri_blamp_diff(phase_2 * phase_inc_rcp);
blamp += bw_osc_tri_blamp_diff(phase_2 * phase_inc_rcp);
v -= bw_rcpf(slope * s_1_m_pw) * bw_absf(x_phase_inc) * blamp;
}
return v;
}
static inline void bw_osc_tri_process(bw_osc_tri_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, int n_samples) {
static inline void bw_osc_tri_process(bw_osc_tri_coeffs *BW_RESTRICT coeffs, const float *x, const float *x_phase_inc, float *y, size_t n_samples) {
if (coeffs->antialiasing)
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_osc_tri_update_coeffs_audio(coeffs);
y[i] = bw_osc_tri_process1_antialias(coeffs, x[i], x_phase_inc[i]);
}
else
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_osc_tri_update_coeffs_audio(coeffs);
y[i] = bw_osc_tri_process1(coeffs, x[i]);
}
}
static inline void bw_osc_tri_process_multi(bw_osc_tri_coeffs *BW_RESTRICT coeffs, const float **x, const float **x_phase_inc, float **y, int n_channels, int n_samples) {
static inline void bw_osc_tri_process_multi(bw_osc_tri_coeffs *BW_RESTRICT coeffs, const float * const *x, const float * const *x_phase_inc, float **y, size_t n_channels, size_t n_samples) {
if (coeffs->antialiasing)
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_osc_tri_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_osc_tri_process1_antialias(coeffs, x[j][i], x_phase_inc[j][i]);
}
else
for (int i = 0; i < n_samples; i++) {
for (size_t i = 0; i < n_samples; i++) {
bw_osc_tri_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_osc_tri_process1(coeffs, x[j][i]);
}
}
@ -299,6 +306,94 @@ static inline void bw_osc_tri_set_slope(bw_osc_tri_coeffs *BW_RESTRICT coeffs, f
}
#ifdef __cplusplus
}
#include <array>
namespace Brickworks {
/*** Public C++ API ***/
/*! api_cpp {{{
* ##### Brickworks::OscTri
* ```>>> */
template<size_t N_CHANNELS>
class OscTri {
public:
OscTri();
void setSampleRate(float sampleRate);
void reset();
void process(
const float * const *x,
const float * const *x_phase_inc,
float **y,
size_t nSamples);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
size_t nSamples);
void setAntialiasing(bool value);
void setSlope(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_osc_tri_coeffs coeffs;
};
template<size_t N_CHANNELS>
inline OscTri<N_CHANNELS>::OscTri() {
bw_osc_tri_init(&coeffs);
}
template<size_t N_CHANNELS>
inline void OscTri<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_osc_tri_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void OscTri<N_CHANNELS>::reset() {
bw_osc_tri_reset_coeffs(&coeffs);
}
template<size_t N_CHANNELS>
inline void OscTri<N_CHANNELS>::process(
const float * const *x,
const float * const *x_phase_inc,
float **y,
size_t nSamples) {
bw_osc_tri_process_multi(&coeffs, x, x_phase_inc, y, N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void OscTri<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
size_t nSamples) {
process(x.data(), x_phase_inc.data(), y.data(), nSamples);
}
template<size_t N_CHANNELS>
inline void OscTri<N_CHANNELS>::setAntialiasing(bool value) {
bw_osc_tri_set_antialiasing(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void OscTri<N_CHANNELS>::setSlope(float value) {
bw_osc_tri_set_slope(&coeffs, value);
}
}
#endif

View File

@ -1,79 +0,0 @@
/*
* Brickworks
*
* Copyright (C) 2023 Orastron Srl unipersonale
*
* Brickworks is free software: you can reosc_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 osc_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 <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#ifndef BWPP_OSC_FILT_H
#define BWPP_OSC_FILT_H
#include <bw_osc_filt.h>
#include <array>
namespace Brickworks {
/*! api {{{
* ##### Brickworks::OscFilt
* ```>>> */
template<size_t N_CHANNELS>
class OscFilt {
public:
OscFilt();
void reset();
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples);
/*! <<<...
* }
* ```
* }}} */
/*** 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_osc_filt_state states[N_CHANNELS];
bw_osc_filt_state *statesP[N_CHANNELS];
};
template<size_t N_CHANNELS>
inline OscFilt<N_CHANNELS>::OscFilt() {
for (size_t i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<size_t N_CHANNELS>
inline void OscFilt<N_CHANNELS>::reset() {
for (size_t i = 0; i < N_CHANNELS; i++)
bw_osc_filt_reset_state(states + i);
}
template<size_t N_CHANNELS>
inline void OscFilt<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_osc_filt_process_multi(statesP, x.data(), y.data(), N_CHANNELS, nSamples);
}
}
#endif

View File

@ -1,97 +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_OSC_PULSE_H
#define BWPP_OSC_PULSE_H
#include <bw_osc_pulse.h>
#include <array>
namespace Brickworks {
/*! api {{{
* ##### Brickworks::OscPulse
* ```>>> */
template<size_t N_CHANNELS>
class OscPulse {
public:
OscPulse();
void setSampleRate(float sampleRate);
void reset();
void process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
int nSamples);
void setAntialiasing(bool value);
void setPulseWidth(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_osc_pulse_coeffs coeffs;
};
template<size_t N_CHANNELS>
inline OscPulse<N_CHANNELS>::OscPulse() {
bw_osc_pulse_init(&coeffs);
}
template<size_t N_CHANNELS>
inline void OscPulse<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_osc_pulse_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void OscPulse<N_CHANNELS>::reset() {
bw_osc_pulse_reset_coeffs(&coeffs);
}
template<size_t N_CHANNELS>
inline void OscPulse<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_osc_pulse_process_multi(&coeffs, x.data(), x_phase_inc.data(), y.data(), N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void OscPulse<N_CHANNELS>::setAntialiasing(bool value) {
bw_osc_pulse_set_antialiasing(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void OscPulse<N_CHANNELS>::setPulseWidth(float value) {
bw_osc_pulse_set_pulse_width(&coeffs, value);
}
}
#endif

View File

@ -1,79 +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_OSC_SAW_H
#define BWPP_OSC_SAW_H
#include <bw_osc_saw.h>
#include <array>
namespace Brickworks {
/*! api {{{
* ##### Brickworks::OscSaw
* ```>>> */
template<size_t N_CHANNELS>
class OscSaw {
public:
OscSaw();
void process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
int nSamples);
void setAntialiasing(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_osc_saw_coeffs coeffs;
};
template<size_t N_CHANNELS>
inline OscSaw<N_CHANNELS>::OscSaw() {
bw_osc_saw_init(&coeffs);
}
template<size_t N_CHANNELS>
inline void OscSaw<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_osc_saw_process_multi(&coeffs, x.data(), x_phase_inc.data(), y.data(), N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void OscSaw<N_CHANNELS>::setAntialiasing(bool value) {
bw_osc_saw_set_antialiasing(&coeffs, value);
}
}
#endif

View File

@ -1,55 +0,0 @@
/*
* Brickworks
*
* Copyright (C) 2023 Orastron Srl unipersonale
*
* Brickworks is free software: you can reosc_sinribute 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 osc_sinributed 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_OSC_SIN_H
#define BWPP_OSC_SIN_H
#include <bw_osc_sin.h>
#include <array>
namespace Brickworks {
/*! api {{{
* ##### Brickworks::oscSinProcess
* ```>>> */
template<size_t N_CHANNELS>
void oscSinProcess(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples);
/*! <<<```
* }}} */
/*** 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. */
template<size_t N_CHANNELS>
inline void oscSinProcess(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_osc_sin_process_multi(x.data(), y.data(), N_CHANNELS, nSamples);
}
}
#endif

View File

@ -1,97 +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_OSC_TRI_H
#define BWPP_OSC_TRI_H
#include <bw_osc_tri.h>
#include <array>
namespace Brickworks {
/*! api {{{
* ##### Brickworks::OscTri
* ```>>> */
template<size_t N_CHANNELS>
class OscTri {
public:
OscTri();
void setSampleRate(float sampleRate);
void reset();
void process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
int nSamples);
void setAntialiasing(bool value);
void setSlope(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_osc_tri_coeffs coeffs;
};
template<size_t N_CHANNELS>
inline OscTri<N_CHANNELS>::OscTri() {
bw_osc_tri_init(&coeffs);
}
template<size_t N_CHANNELS>
inline void OscTri<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_osc_tri_set_sample_rate(&coeffs, sampleRate);
}
template<size_t N_CHANNELS>
inline void OscTri<N_CHANNELS>::reset() {
bw_osc_tri_reset_coeffs(&coeffs);
}
template<size_t N_CHANNELS>
inline void OscTri<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<const float *, N_CHANNELS> x_phase_inc,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_osc_tri_process_multi(&coeffs, x.data(), x_phase_inc.data(), y.data(), N_CHANNELS, nSamples);
}
template<size_t N_CHANNELS>
inline void OscTri<N_CHANNELS>::setAntialiasing(bool value) {
bw_osc_tri_set_antialiasing(&coeffs, value);
}
template<size_t N_CHANNELS>
inline void OscTri<N_CHANNELS>::setSlope(float value) {
bw_osc_tri_set_slope(&coeffs, value);
}
}
#endif