polished bw_{balance,bd_reduce,one_pole} + removed
bwpp_{balance,bd_reduce} + fixed fxpp_bitcrush
This commit is contained in:
parent
5ec809bc4f
commit
7a2630951f
@ -24,7 +24,7 @@
|
||||
#include "platform.h"
|
||||
|
||||
#include <bwpp_sr_reduce.h>
|
||||
#include <bwpp_bd_reduce.h>
|
||||
#include <bw_bd_reduce.h>
|
||||
|
||||
using namespace Brickworks;
|
||||
|
||||
|
@ -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_balance_process()</code> and
|
||||
* <code>bw_balance_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>:
|
||||
@ -56,8 +63,8 @@
|
||||
* }}}
|
||||
*/
|
||||
|
||||
#ifndef _BW_BALANCE_H
|
||||
#define _BW_BALANCE_H
|
||||
#ifndef BW_BALANCE_H
|
||||
#define BW_BALANCE_H
|
||||
|
||||
#include <bw_common.h>
|
||||
|
||||
@ -68,7 +75,7 @@ extern "C" {
|
||||
/*! api {{{
|
||||
* #### bw_balance_coeffs
|
||||
* ```>>> */
|
||||
typedef struct _bw_balance_coeffs bw_balance_coeffs;
|
||||
typedef struct bw_balance_coeffs bw_balance_coeffs;
|
||||
/*! <<<```
|
||||
* Coefficients and related.
|
||||
*
|
||||
@ -112,7 +119,7 @@ static inline void bw_balance_process1(const bw_balance_coeffs *BW_RESTRICT coef
|
||||
*
|
||||
* #### bw_balance_process()
|
||||
* ```>>> */
|
||||
static inline void bw_balance_process(bw_balance_coeffs *BW_RESTRICT coeffs, const float *x_l, const float *x_r, float *y_l, float *y_r, int n_samples);
|
||||
static inline void bw_balance_process(bw_balance_coeffs *BW_RESTRICT coeffs, const float *x_l, const float *x_r, float *y_l, float *y_r, size_t n_samples);
|
||||
/*! <<<```
|
||||
* Processes the first `n_samples` of the input buffers `x_l` (left) and
|
||||
* `x_r` (right) and fills the first `n_samples` of the output buffers `y_l`
|
||||
@ -121,7 +128,7 @@ static inline void bw_balance_process(bw_balance_coeffs *BW_RESTRICT coeffs, con
|
||||
*
|
||||
* #### bw_balance_process_multi()
|
||||
* ```>>> */
|
||||
static inline void bw_balance_process_multi(bw_balance_coeffs *BW_RESTRICT coeffs, const float **x_l, const float **x_r, float **y_l, float **y_r, int n_channels, int n_samples);
|
||||
static inline void bw_balance_process_multi(bw_balance_coeffs *BW_RESTRICT coeffs, const float * const *x_l, const float * const *x_r, float **y_l, float **y_r, size_t n_channels, size_t n_samples);
|
||||
/*! <<<```
|
||||
* Processes the first `n_samples` of the `n_channels` input buffers `x_l`
|
||||
* (left) and `x_r` (right) and fills the first `n_samples` of the
|
||||
@ -154,7 +161,7 @@ static inline void bw_balance_set_balance(bw_balance_coeffs *BW_RESTRICT coeffs,
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _bw_balance_coeffs {
|
||||
struct bw_balance_coeffs {
|
||||
// Sub-components
|
||||
bw_gain_coeffs l_coeffs;
|
||||
bw_gain_coeffs r_coeffs;
|
||||
@ -175,7 +182,7 @@ static inline void bw_balance_set_sample_rate(bw_balance_coeffs *BW_RESTRICT coe
|
||||
bw_gain_set_sample_rate(&coeffs->r_coeffs, sample_rate);
|
||||
}
|
||||
|
||||
static inline void _bw_balance_do_update_coeffs(bw_balance_coeffs *BW_RESTRICT coeffs, char force) {
|
||||
static inline void bw_balance_do_update_coeffs(bw_balance_coeffs *BW_RESTRICT coeffs, char force) {
|
||||
if (force || coeffs->balance != coeffs->balance_prev) {
|
||||
bw_gain_set_gain_lin(&coeffs->l_coeffs, bw_minf(1.f - coeffs->balance, 1.f));
|
||||
bw_gain_set_gain_lin(&coeffs->r_coeffs, bw_minf(1.f + coeffs->balance, 1.f));
|
||||
@ -184,13 +191,13 @@ static inline void _bw_balance_do_update_coeffs(bw_balance_coeffs *BW_RESTRICT c
|
||||
}
|
||||
|
||||
static inline void bw_balance_reset_coeffs(bw_balance_coeffs *BW_RESTRICT coeffs) {
|
||||
_bw_balance_do_update_coeffs(coeffs, 1);
|
||||
bw_balance_do_update_coeffs(coeffs, 1);
|
||||
bw_gain_reset_coeffs(&coeffs->l_coeffs);
|
||||
bw_gain_reset_coeffs(&coeffs->r_coeffs);
|
||||
}
|
||||
|
||||
static inline void bw_balance_update_coeffs_ctrl(bw_balance_coeffs *BW_RESTRICT coeffs) {
|
||||
_bw_balance_do_update_coeffs(coeffs, 0);
|
||||
bw_balance_do_update_coeffs(coeffs, 0);
|
||||
bw_gain_update_coeffs_ctrl(&coeffs->l_coeffs);
|
||||
bw_gain_update_coeffs_ctrl(&coeffs->r_coeffs);
|
||||
}
|
||||
@ -205,19 +212,19 @@ static inline void bw_balance_process1(const bw_balance_coeffs *BW_RESTRICT coef
|
||||
*y_r = bw_gain_process1(&coeffs->r_coeffs, x_r);
|
||||
}
|
||||
|
||||
static inline void bw_balance_process(bw_balance_coeffs *BW_RESTRICT coeffs, const float *x_l, const float *x_r, float *y_l, float *y_r, int n_samples){
|
||||
static inline void bw_balance_process(bw_balance_coeffs *BW_RESTRICT coeffs, const float *x_l, const float *x_r, float *y_l, float *y_r, size_t n_samples){
|
||||
bw_balance_update_coeffs_ctrl(coeffs);
|
||||
for (int i = 0; i < n_samples; i++) {
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
bw_balance_update_coeffs_audio(coeffs);
|
||||
bw_balance_process1(coeffs, x_l[i], x_r[i], y_l + i, y_r + i);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bw_balance_process_multi(bw_balance_coeffs *BW_RESTRICT coeffs, const float **x_l, const float **x_r, float **y_l, float **y_r, int n_channels, int n_samples) {
|
||||
static inline void bw_balance_process_multi(bw_balance_coeffs *BW_RESTRICT coeffs, const float * const *x_l, const float * const *x_r, float **y_l, float **y_r, size_t n_channels, size_t n_samples) {
|
||||
bw_balance_update_coeffs_ctrl(coeffs);
|
||||
for (int i = 0; i < n_samples; i++) {
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
bw_balance_update_coeffs_audio(coeffs);
|
||||
for (int j = 0; j < n_channels; j++)
|
||||
for (size_t j = 0; j < n_channels; j++)
|
||||
bw_balance_process1(coeffs, x_l[j][i], x_r[j][i], y_l[j] + i, y_r[j] + i);
|
||||
}
|
||||
}
|
||||
@ -227,6 +234,92 @@ static inline void bw_balance_set_balance(bw_balance_coeffs *BW_RESTRICT coeffs,
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace Brickworks {
|
||||
|
||||
/*** Public C++ API ***/
|
||||
|
||||
/*! api {{{
|
||||
* ##### Brickworks::Balance
|
||||
* ```>>> */
|
||||
template<size_t N_CHANNELS>
|
||||
class Balance {
|
||||
public:
|
||||
Balance();
|
||||
|
||||
void setSampleRate(float sampleRate);
|
||||
void reset();
|
||||
void process(
|
||||
const float * const *x_l,
|
||||
const float * const *x_r,
|
||||
float **y_l,
|
||||
float **y_r,
|
||||
size_t nSamples);
|
||||
void process(
|
||||
std::array<const float *, N_CHANNELS> x_l,
|
||||
std::array<const float *, N_CHANNELS> x_r,
|
||||
std::array<float *, N_CHANNELS> y_l,
|
||||
std::array<float *, N_CHANNELS> y_r,
|
||||
size_t nSamples);
|
||||
|
||||
void setBalance(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_balance_coeffs coeffs;
|
||||
};
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline Balance<N_CHANNELS>::Balance() {
|
||||
bw_balance_init(&coeffs);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void Balance<N_CHANNELS>::setSampleRate(float sampleRate) {
|
||||
bw_balance_set_sample_rate(&coeffs, sampleRate);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void Balance<N_CHANNELS>::reset() {
|
||||
bw_balance_reset_coeffs(&coeffs);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void Balance<N_CHANNELS>::process(
|
||||
const float * const *x_l,
|
||||
const float * const *x_r,
|
||||
float **y_l,
|
||||
float **y_r,
|
||||
size_t nSamples) {
|
||||
bw_balance_process_multi(&coeffs, x_l, x_r, y_l, y_r, N_CHANNELS, nSamples);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void Balance<N_CHANNELS>::process(
|
||||
std::array<const float *, N_CHANNELS> x_l,
|
||||
std::array<const float *, N_CHANNELS> x_r,
|
||||
std::array<float *, N_CHANNELS> y_l,
|
||||
std::array<float *, N_CHANNELS> y_r,
|
||||
size_t nSamples) {
|
||||
process(x_l.data(), x_r.data(), y_l.data(), y_r.data(), nSamples);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void Balance<N_CHANNELS>::setBalance(float value) {
|
||||
bw_balance_set_balance(&coeffs, value);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -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_bd_reduce_process()</code> and
|
||||
* <code>bw_bd_reduce_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_BD_REDUCE_H
|
||||
#define _BW_BD_REDUCE_H
|
||||
#ifndef BW_BD_REDUCE_H
|
||||
#define BW_BD_REDUCE_H
|
||||
|
||||
#include <bw_common.h>
|
||||
|
||||
@ -74,7 +81,7 @@ extern "C" {
|
||||
/*! api {{{
|
||||
* #### bw_bd_reduce_coeffs
|
||||
* ```>>> */
|
||||
typedef struct _bw_bd_reduce_coeffs bw_bd_reduce_coeffs;
|
||||
typedef struct bw_bd_reduce_coeffs bw_bd_reduce_coeffs;
|
||||
/*! <<<```
|
||||
* Coefficients and related.
|
||||
*
|
||||
@ -111,7 +118,7 @@ static inline float bw_bd_reduce_process1(const bw_bd_reduce_coeffs *BW_RESTRICT
|
||||
*
|
||||
* #### bw_bd_reduce_process()
|
||||
* ```>>> */
|
||||
static inline void bw_bd_reduce_process(bw_bd_reduce_coeffs *BW_RESTRICT coeffs, const float *x, float *y, int n_samples);
|
||||
static inline void bw_bd_reduce_process(bw_bd_reduce_coeffs *BW_RESTRICT coeffs, 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
|
||||
@ -119,7 +126,7 @@ static inline void bw_bd_reduce_process(bw_bd_reduce_coeffs *BW_RESTRICT coeffs,
|
||||
*
|
||||
* #### bw_bd_reduce_process_multi()
|
||||
* ```>>> */
|
||||
static inline void bw_bd_reduce_process_multi(bw_bd_reduce_coeffs *BW_RESTRICT coeffs, const float **x, float **y, int n_channels, int n_samples);
|
||||
static inline void bw_bd_reduce_process_multi(bw_bd_reduce_coeffs *BW_RESTRICT coeffs, 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
|
||||
@ -149,7 +156,7 @@ static inline void bw_bd_reduce_set_bit_depth(bw_bd_reduce_coeffs *BW_RESTRICT c
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct _bw_bd_reduce_coeffs {
|
||||
struct bw_bd_reduce_coeffs {
|
||||
// Coefficients
|
||||
float ki;
|
||||
float k;
|
||||
@ -186,16 +193,16 @@ static inline float bw_bd_reduce_process1(const bw_bd_reduce_coeffs *BW_RESTRICT
|
||||
return coeffs->ki * (bw_floorf(coeffs->k * bw_clipf(x, -coeffs->max, coeffs->max)) + 0.5f);
|
||||
}
|
||||
|
||||
static inline void bw_bd_reduce_process(bw_bd_reduce_coeffs *BW_RESTRICT coeffs, const float *x, float *y, int n_samples) {
|
||||
static inline void bw_bd_reduce_process(bw_bd_reduce_coeffs *BW_RESTRICT coeffs, const float *x, float *y, size_t n_samples) {
|
||||
bw_bd_reduce_update_coeffs_ctrl(coeffs);
|
||||
for (int i = 0; i < n_samples; i++)
|
||||
for (size_t i = 0; i < n_samples; i++)
|
||||
y[i] = bw_bd_reduce_process1(coeffs, x[i]);
|
||||
}
|
||||
|
||||
static inline void bw_bd_reduce_process_multi(bw_bd_reduce_coeffs *BW_RESTRICT coeffs, const float **x, float **y, int n_channels, int n_samples) {
|
||||
static inline void bw_bd_reduce_process_multi(bw_bd_reduce_coeffs *BW_RESTRICT coeffs, const float * const *x, float **y, size_t n_channels, size_t n_samples) {
|
||||
bw_bd_reduce_update_coeffs_ctrl(coeffs);
|
||||
for (int i = 0; i < n_samples; i++)
|
||||
for (int j = 0; j < n_channels; j++)
|
||||
for (size_t i = 0; i < n_samples; i++)
|
||||
for (size_t j = 0; j < n_channels; j++)
|
||||
y[j][i] = bw_bd_reduce_process1(coeffs, x[j][i]);
|
||||
}
|
||||
|
||||
@ -204,6 +211,78 @@ static inline void bw_bd_reduce_set_bit_depth(bw_bd_reduce_coeffs *BW_RESTRICT c
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
#include <array>
|
||||
|
||||
namespace Brickworks {
|
||||
|
||||
/*** Public C++ API ***/
|
||||
|
||||
/*! api {{{
|
||||
* ##### Brickworks::BDReduce
|
||||
* ```>>> */
|
||||
template<size_t N_CHANNELS>
|
||||
class BDReduce {
|
||||
public:
|
||||
BDReduce();
|
||||
|
||||
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);
|
||||
|
||||
void setBitDepth(char 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_bd_reduce_coeffs coeffs;
|
||||
};
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline BDReduce<N_CHANNELS>::BDReduce() {
|
||||
bw_bd_reduce_init(&coeffs);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void BDReduce<N_CHANNELS>::reset() {
|
||||
bw_bd_reduce_reset_coeffs(&coeffs);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void BDReduce<N_CHANNELS>::process(
|
||||
const float * const *x,
|
||||
float **y,
|
||||
size_t nSamples) {
|
||||
bw_bd_reduce_process_multi(&coeffs, x, y, N_CHANNELS, nSamples);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void BDReduce<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 BDReduce<N_CHANNELS>::setBitDepth(char value) {
|
||||
bw_bd_reduce_set_bit_depth(&coeffs, value);
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -421,7 +421,7 @@ static inline void bw_one_pole_set_sample_rate(bw_one_pole_coeffs *BW_RESTRICT c
|
||||
BW_ASSERT_DEEP(coeffs->state == bw_one_pole_coeffs_state_set_sample_rate);
|
||||
}
|
||||
|
||||
static inline void _bw_one_pole_do_update_coeffs_ctrl(bw_one_pole_coeffs *BW_RESTRICT coeffs) {
|
||||
static inline void bw_one_pole_do_update_coeffs_ctrl(bw_one_pole_coeffs *BW_RESTRICT coeffs) {
|
||||
if (coeffs->param_changed) {
|
||||
if (coeffs->param_changed & BW_ONE_POLE_PARAM_CUTOFF_UP)
|
||||
coeffs->mA1u = coeffs->cutoff_up > 1.591549430918953e8f ? 0.f : bw_expf(coeffs->Ttm2pi * coeffs->cutoff_up);
|
||||
@ -441,7 +441,7 @@ static inline void bw_one_pole_reset_coeffs(bw_one_pole_coeffs *BW_RESTRICT coef
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_set_sample_rate);
|
||||
|
||||
coeffs->param_changed = ~0;
|
||||
_bw_one_pole_do_update_coeffs_ctrl(coeffs);
|
||||
bw_one_pole_do_update_coeffs_ctrl(coeffs);
|
||||
|
||||
#ifdef BW_DEBUG_DEEP
|
||||
coeffs->state = _bw_one_pole_coeffs_state_reset_coeffs;
|
||||
@ -476,7 +476,7 @@ static inline void bw_one_pole_update_coeffs_ctrl(bw_one_pole_coeffs *BW_RESTRIC
|
||||
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs);
|
||||
|
||||
_bw_one_pole_do_update_coeffs_ctrl(coeffs);
|
||||
bw_one_pole_do_update_coeffs_ctrl(coeffs);
|
||||
|
||||
BW_ASSERT_DEEP(bw_one_pole_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_one_pole_coeffs_state_reset_coeffs);
|
||||
|
@ -1,93 +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_BALANCE_H
|
||||
#define BWPP_BALANCE_H
|
||||
|
||||
#include <bw_balance.h>
|
||||
#include <array>
|
||||
|
||||
namespace Brickworks {
|
||||
|
||||
/*! api {{{
|
||||
* ##### Brickworks::Balance
|
||||
* ```>>> */
|
||||
template<size_t N_CHANNELS>
|
||||
class Balance {
|
||||
public:
|
||||
Balance();
|
||||
|
||||
void setSampleRate(float sampleRate);
|
||||
void reset();
|
||||
void process(
|
||||
std::array<const float *, N_CHANNELS> x_l,
|
||||
std::array<const float *, N_CHANNELS> x_r,
|
||||
std::array<float *, N_CHANNELS> y_l,
|
||||
std::array<float *, N_CHANNELS> y_r,
|
||||
int nSamples);
|
||||
|
||||
void setBalance(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_balance_coeffs coeffs;
|
||||
};
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline Balance<N_CHANNELS>::Balance() {
|
||||
bw_balance_init(&coeffs);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void Balance<N_CHANNELS>::setSampleRate(float sampleRate) {
|
||||
bw_balance_set_sample_rate(&coeffs, sampleRate);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void Balance<N_CHANNELS>::reset() {
|
||||
bw_balance_reset_coeffs(&coeffs);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void Balance<N_CHANNELS>::process(
|
||||
std::array<const float *, N_CHANNELS> x_l,
|
||||
std::array<const float *, N_CHANNELS> x_r,
|
||||
std::array<float *, N_CHANNELS> y_l,
|
||||
std::array<float *, N_CHANNELS> y_r,
|
||||
int nSamples) {
|
||||
bw_balance_process_multi(&coeffs, x_l.data(), x_r.data(), y_l.data(), y_r.data(), N_CHANNELS, nSamples);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void Balance<N_CHANNELS>::setBalance(float value) {
|
||||
bw_balance_set_balance(&coeffs, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,83 +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_BD_REDUCE_H
|
||||
#define BWPP_BD_REDUCE_H
|
||||
|
||||
#include <bw_bd_reduce.h>
|
||||
#include <array>
|
||||
|
||||
namespace Brickworks {
|
||||
|
||||
/*! api {{{
|
||||
* ##### Brickworks::BDReduce
|
||||
* ```>>> */
|
||||
template<size_t N_CHANNELS>
|
||||
class BDReduce {
|
||||
public:
|
||||
BDReduce();
|
||||
|
||||
void reset();
|
||||
void process(
|
||||
std::array<const float *, N_CHANNELS> x,
|
||||
std::array<float *, N_CHANNELS> y,
|
||||
int nSamples);
|
||||
|
||||
void setBitDepth(char 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_bd_reduce_coeffs coeffs;
|
||||
};
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline BDReduce<N_CHANNELS>::BDReduce() {
|
||||
bw_bd_reduce_init(&coeffs);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void BDReduce<N_CHANNELS>::reset() {
|
||||
bw_bd_reduce_reset_coeffs(&coeffs);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void BDReduce<N_CHANNELS>::process(
|
||||
std::array<const float *, N_CHANNELS> x,
|
||||
std::array<float *, N_CHANNELS> y,
|
||||
int nSamples) {
|
||||
bw_bd_reduce_process_multi(&coeffs, x.data(), y.data(), N_CHANNELS, nSamples);
|
||||
}
|
||||
|
||||
template<size_t N_CHANNELS>
|
||||
inline void BDReduce<N_CHANNELS>::setBitDepth(char value) {
|
||||
bw_bd_reduce_set_bit_depth(&coeffs, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user