tentative bwpp_{chorus,comb,reverb}
This commit is contained in:
parent
ebf1712e74
commit
1a4ada6ef6
127
include/bwpp_chorus.h
Normal file
127
include/bwpp_chorus.h
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
* 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_CHORUS_H
|
||||
#define BWPP_CHORUS_H
|
||||
|
||||
#include <bw_chorus.h>
|
||||
#include <array>
|
||||
|
||||
namespace Brickworks {
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
class Chorus {
|
||||
public:
|
||||
Chorus(float maxDelay = 1.f);
|
||||
~Chorus();
|
||||
|
||||
void setSampleRate(float sampleRate);
|
||||
void reset();
|
||||
void process(
|
||||
std::array<const float *, N_CHANNELS> x,
|
||||
std::array<float *, N_CHANNELS> y,
|
||||
int nSamples);
|
||||
|
||||
void setRate(float value);
|
||||
void setDelay(float value);
|
||||
void setAmount(float value);
|
||||
void setCoeffX(float value);
|
||||
void setCoeffMod(float value);
|
||||
void setCoeffFB(float value);
|
||||
|
||||
private:
|
||||
bw_chorus_coeffs coeffs;
|
||||
bw_chorus_state states[N_CHANNELS];
|
||||
bw_chorus_state *statesP[N_CHANNELS];
|
||||
void *mem;
|
||||
};
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline Chorus<N_CHANNELS>::Chorus(float maxDelay) {
|
||||
bw_chorus_init(&coeffs, maxDelay);
|
||||
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
|
||||
statesP[i] = states + i;
|
||||
mem = nullptr;
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline Chorus<N_CHANNELS>::~Chorus() {
|
||||
if (mem != nullptr)
|
||||
operator delete(mem);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Chorus<N_CHANNELS>::setSampleRate(float sampleRate) {
|
||||
bw_chorus_set_sample_rate(&coeffs, sampleRate);
|
||||
BW_SIZE_T req = bw_chorus_mem_req(&coeffs);
|
||||
if (mem != nullptr)
|
||||
operator delete(mem);
|
||||
mem = operator new(req * N_CHANNELS);
|
||||
void *m = mem;
|
||||
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++, m = static_cast<char *>(m) + req)
|
||||
bw_chorus_mem_set(&coeffs, states + i, m);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Chorus<N_CHANNELS>::reset() {
|
||||
bw_chorus_reset_coeffs(&coeffs);
|
||||
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
|
||||
bw_chorus_reset_state(&coeffs, states + i);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Chorus<N_CHANNELS>::process(
|
||||
std::array<const float *, N_CHANNELS> x,
|
||||
std::array<float *, N_CHANNELS> y,
|
||||
int nSamples) {
|
||||
bw_chorus_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Chorus<N_CHANNELS>::setRate(float value) {
|
||||
bw_chorus_set_rate(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Chorus<N_CHANNELS>::setDelay(float value) {
|
||||
bw_chorus_set_delay(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Chorus<N_CHANNELS>::setAmount(float value) {
|
||||
bw_chorus_set_amount(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Chorus<N_CHANNELS>::setCoeffX(float value) {
|
||||
bw_chorus_set_coeff_x(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Chorus<N_CHANNELS>::setCoeffMod(float value) {
|
||||
bw_chorus_set_coeff_mod(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Chorus<N_CHANNELS>::setCoeffFB(float value) {
|
||||
bw_chorus_set_coeff_fb(&coeffs, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
126
include/bwpp_comb.h
Normal file
126
include/bwpp_comb.h
Normal file
@ -0,0 +1,126 @@
|
||||
/*
|
||||
* 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_COMB_H
|
||||
#define BWPP_COMB_H
|
||||
|
||||
#include <bw_comb.h>
|
||||
#include <array>
|
||||
|
||||
namespace Brickworks {
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
class Comb {
|
||||
public:
|
||||
Comb(float maxDelay = 1.f);
|
||||
~Comb();
|
||||
|
||||
void setSampleRate(float sampleRate);
|
||||
void reset();
|
||||
void process(
|
||||
std::array<const float *, N_CHANNELS> x,
|
||||
std::array<float *, N_CHANNELS> y,
|
||||
int nSamples);
|
||||
|
||||
void setDelayFF(float value);
|
||||
void setDelayFB(float value);
|
||||
void setCoeffBlend(float value);
|
||||
void setCoeffFF(float value);
|
||||
void setCoeffFB(float value);
|
||||
|
||||
private:
|
||||
bw_comb_coeffs coeffs;
|
||||
bw_comb_state states[N_CHANNELS];
|
||||
bw_comb_state *statesP[N_CHANNELS];
|
||||
void *mem;
|
||||
};
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline Comb<N_CHANNELS>::Comb(float maxDelay) {
|
||||
bw_comb_init(&coeffs, maxDelay);
|
||||
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
|
||||
statesP[i] = states + i;
|
||||
mem = nullptr;
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline Comb<N_CHANNELS>::~Comb() {
|
||||
if (mem != nullptr)
|
||||
operator delete(mem);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Comb<N_CHANNELS>::setSampleRate(float sampleRate) {
|
||||
bw_comb_set_sample_rate(&coeffs, sampleRate);
|
||||
BW_SIZE_T req = bw_comb_mem_req(&coeffs);
|
||||
if (mem != nullptr)
|
||||
operator delete(mem);
|
||||
mem = operator new(req * N_CHANNELS);
|
||||
void *m = mem;
|
||||
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++, m = static_cast<char *>(m) + req)
|
||||
bw_comb_mem_set(&coeffs, states + i, m);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Comb<N_CHANNELS>::reset() {
|
||||
bw_comb_reset_coeffs(&coeffs);
|
||||
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
|
||||
bw_comb_reset_state(&coeffs, states + i);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Comb<N_CHANNELS>::process(
|
||||
std::array<const float *, N_CHANNELS> x,
|
||||
std::array<float *, N_CHANNELS> y,
|
||||
int nSamples) {
|
||||
bw_comb_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Comb<N_CHANNELS>::setDelayFF(float value) {
|
||||
bw_comb_set_delay_ff(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Comb<N_CHANNELS>::setDelayFB(float value) {
|
||||
bw_comb_set_delay_fb(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Comb<N_CHANNELS>::setDelayFB(float value) {
|
||||
bw_comb_set_delay_fb(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Comb<N_CHANNELS>::setCoeffBlend(float value) {
|
||||
bw_comb_set_coeff_blend(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Comb<N_CHANNELS>::setCoeffFF(float value) {
|
||||
bw_comb_set_coeff_ff(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Comb<N_CHANNELS>::setCoeffFB(float value) {
|
||||
bw_comb_set_coeff_fb(&coeffs, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
125
include/bwpp_reverb.h
Normal file
125
include/bwpp_reverb.h
Normal file
@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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_REVERB_H
|
||||
#define BWPP_REVERB_H
|
||||
|
||||
#include <bw_reverb.h>
|
||||
#include <array>
|
||||
|
||||
namespace Brickworks {
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
class Reverb {
|
||||
public:
|
||||
Reverb();
|
||||
~Reverb();
|
||||
|
||||
void setSampleRate(float sampleRate);
|
||||
void reset();
|
||||
void process(
|
||||
std::array<const float *, N_CHANNELS> xl,
|
||||
std::array<const float *, N_CHANNELS> xr,
|
||||
std::array<float *, N_CHANNELS> yl,
|
||||
std::array<float *, N_CHANNELS> yr,
|
||||
int nSamples);
|
||||
|
||||
void setPredelay(float value);
|
||||
void setBandwidth(float value);
|
||||
void setDamping(float value);
|
||||
void setDecay(float value);
|
||||
void setWet(float value);
|
||||
|
||||
private:
|
||||
bw_reverb_coeffs coeffs;
|
||||
bw_reverb_state states[N_CHANNELS];
|
||||
bw_reverb_state *statesP[N_CHANNELS];
|
||||
void *mem;
|
||||
};
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline Reverb<N_CHANNELS>::Reverb() {
|
||||
bw_reverb_init(&coeffs);
|
||||
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
|
||||
statesP[i] = states + i;
|
||||
mem = nullptr;
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline Reverb<N_CHANNELS>::~Reverb() {
|
||||
if (mem != nullptr)
|
||||
operator delete(mem);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Reverb<N_CHANNELS>::setSampleRate(float sampleRate) {
|
||||
bw_reverb_set_sample_rate(&coeffs, sampleRate);
|
||||
BW_SIZE_T req = bw_reverb_mem_req(&coeffs);
|
||||
if (mem != nullptr)
|
||||
operator delete(mem);
|
||||
mem = operator new(req * N_CHANNELS);
|
||||
void *m = mem;
|
||||
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++, m = static_cast<char *>(m) + req)
|
||||
bw_reverb_mem_set(&coeffs, states + i, m);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Reverb<N_CHANNELS>::reset() {
|
||||
bw_reverb_reset_coeffs(&coeffs);
|
||||
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
|
||||
bw_reverb_reset_state(&coeffs, states + i);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Reverb<N_CHANNELS>::process(
|
||||
std::array<const float *, N_CHANNELS> xl,
|
||||
std::array<const float *, N_CHANNELS> xr,
|
||||
std::array<float *, N_CHANNELS> yl,
|
||||
std::array<float *, N_CHANNELS> yr,
|
||||
int nSamples) {
|
||||
bw_reverb_process_multi(&coeffs, statesP, xl.data(), xr.data(), yl.data(), yr.data(), N_CHANNELS, nSamples);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Reverb<N_CHANNELS>::setPredelay(float value) {
|
||||
bw_reverb_set_predelay(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Reverb<N_CHANNELS>::setBandwidth(float value) {
|
||||
bw_reverb_set_bandwidth(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Reverb<N_CHANNELS>::setDamping(float value) {
|
||||
bw_reverb_set_damping(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Reverb<N_CHANNELS>::setDecay(float value) {
|
||||
bw_reverb_set_decay(&coeffs, value);
|
||||
}
|
||||
|
||||
template<BW_SIZE_T N_CHANNELS>
|
||||
inline void Reverb<N_CHANNELS>::setWet(float value) {
|
||||
bw_reverb_set_wet(&coeffs, value);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user