bwpp_{satur,noise_gate,noise_gen} + fxpp_{satur,noise_gate}

This commit is contained in:
Stefano D'Angelo 2023-06-26 11:19:08 +02:00
parent 2a5e3d3ece
commit 4dd9e863ce
17 changed files with 866 additions and 0 deletions

View File

@ -0,0 +1,7 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
TARGET = bw_example_fxpp_noise_gate
CPP_SOURCES_EXTRA = ${ROOT_DIR}/../src/bw_example_fxpp_noise_gate.cpp
include ${ROOT_DIR}/../../common/daisy-seed/daisy-seed.mk

View File

@ -0,0 +1,38 @@
/*
* 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 authors: Stefano D'Angelo
*/
#ifndef _CONFIG_DAISY_SEED_H
#define _CONFIG_DAISY_SEED_H
struct config_pin {
int param_index;
int pin;
};
#define NUM_PINS 4
static struct config_pin config_pins[NUM_PINS] = {
{ 0, 15 },
{ 1, 16 },
{ 2, 17 },
{ 3, 18 }
};
#endif

View File

@ -0,0 +1,59 @@
/*
* 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
*/
#include "bw_example_fxpp_noise_gate.h"
void bw_example_fxpp_noise_gate_init(bw_example_fxpp_noise_gate *instance) {
(void)instance;
}
void bw_example_fxpp_noise_gate_set_sample_rate(bw_example_fxpp_noise_gate *instance, float sample_rate) {
instance->noise_gate.setSampleRate(sample_rate);
}
void bw_example_fxpp_noise_gate_reset(bw_example_fxpp_noise_gate *instance) {
instance->noise_gate.reset();
}
void bw_example_fxpp_noise_gate_process(bw_example_fxpp_noise_gate *instance, const float** x, float** y, int n_samples) {
instance->noise_gate.process({x[0]}, {x[0]}, {y[0]}, n_samples);
}
void bw_example_fxpp_noise_gate_set_parameter(bw_example_fxpp_noise_gate *instance, int index, float value) {
instance->params[index] = value;
switch (index) {
case p_thresh:
instance->noise_gate.setTreshDBFS(60.f * value - 60.f);
break;
case p_ratio:
instance->noise_gate.setRatio(value < 0.999f ? 1.f / (1.f - value) : INFINITY);
break;
case p_attack:
instance->noise_gate.setAttackTau(value);
break;
case p_release:
instance->noise_gate.setReleaseTau(value);
break;
}
}
float bw_example_fxpp_noise_gate_get_parameter(bw_example_fxpp_noise_gate *instance, int index) {
return instance->params[index];
}

View File

@ -0,0 +1,56 @@
/*
* 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 _BW_EXAMPLE_FXPP_NOISE_GATE_H
#define _BW_EXAMPLE_FXPP_NOISE_GATE_H
#include <bwpp_noise_gate.h>
using namespace Brickworks;
extern "C" {
enum {
p_thresh,
p_ratio,
p_attack,
p_release,
p_n
};
struct _bw_example_fxpp_noise_gate {
// Sub-noise_gateonents
NoiseGate<1> noise_gate;
// Parameters
float params[p_n];
};
typedef struct _bw_example_fxpp_noise_gate bw_example_fxpp_noise_gate;
void bw_example_fxpp_noise_gate_init(bw_example_fxpp_noise_gate *instance);
void bw_example_fxpp_noise_gate_set_sample_rate(bw_example_fxpp_noise_gate *instance, float sample_rate);
void bw_example_fxpp_noise_gate_reset(bw_example_fxpp_noise_gate *instance);
void bw_example_fxpp_noise_gate_process(bw_example_fxpp_noise_gate *instance, const float** x, float** y, int n_samples);
void bw_example_fxpp_noise_gate_set_parameter(bw_example_fxpp_noise_gate *instance, int index, float value);
float bw_example_fxpp_noise_gate_get_parameter(bw_example_fxpp_noise_gate *instance, int index);
}
#endif

View File

@ -0,0 +1,90 @@
/*
* 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 authors: Stefano D'Angelo
*/
#ifndef _CONFIG_H
#define _CONFIG_H
// Definitions
#define IO_MONO 1
#define IO_STEREO (1<<1)
struct config_io_bus {
const char *name;
char out;
char aux;
char cv;
char configs;
};
struct config_parameter {
const char *name;
const char *shortName;
const char *units;
char out;
char bypass;
int steps;
float defaultValueUnmapped;
};
// Data
#define COMPANY_NAME "Orastron"
#define COMPANY_WEBSITE "https://www.orastron.com/"
#define COMPANY_MAILTO "mailto:info@orastron.com"
#define PLUGIN_NAME "bw_example_fxpp_noise_gate"
#define PLUGIN_VERSION "0.5.0"
#define NUM_BUSES_IN 1
#define NUM_BUSES_OUT 1
#define NUM_CHANNELS_IN 1
#define NUM_CHANNELS_OUT 1
static struct config_io_bus config_buses_in[NUM_BUSES_IN] = {
{ "Audio in", 0, 0, 0, IO_MONO }
};
static struct config_io_bus config_buses_out[NUM_BUSES_OUT] = {
{ "Audio out", 1, 0, 0, IO_MONO }
};
#define NUM_PARAMETERS 4
static struct config_parameter config_parameters[NUM_PARAMETERS] = {
{ "Threshold", "Thresh", "", 0, 0, 0, 1.f },
{ "Ratio", "Ratio", "", 0, 0, 0, 1.f },
{ "Attack", "Attack", "s", 0, 0, 0, 0.f },
{ "Release", "Release", "s", 0, 0, 0, 0.f }
};
// Internal API
#include "bw_example_fxpp_noise_gate.h"
#define P_TYPE bw_example_fxpp_noise_gate
#define P_INIT bw_example_fxpp_noise_gate_init
#define P_SET_SAMPLE_RATE bw_example_fxpp_noise_gate_set_sample_rate
#define P_RESET bw_example_fxpp_noise_gate_reset
#define P_PROCESS bw_example_fxpp_noise_gate_process
#define P_SET_PARAMETER bw_example_fxpp_noise_gate_set_parameter
#define P_GET_PARAMETER bw_example_fxpp_noise_gate_get_parameter
#endif

View File

@ -0,0 +1,6 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
NAME := bw_example_fxpp_noise_gate
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fxpp_noise_gate.cpp
include ${ROOT_DIR}/../../common/vst3/vst3.mk

View File

@ -0,0 +1,36 @@
/*
* 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 authors: Stefano D'Angelo, Paolo Marrone
*/
#ifndef _VST3_CONFIG_H
#define _VST3_CONFIG_H
#define PLUGIN_SUBCATEGORY "Fx|Restoration"
#define PLUGIN_GUID_1 0x61e80a39
#define PLUGIN_GUID_2 0x48ec44ca
#define PLUGIN_GUID_3 0x924cd7b6
#define PLUGIN_GUID_4 0x5f784609
#define CTRL_GUID_1 0x9630e7c7
#define CTRL_GUID_2 0x73d64256
#define CTRL_GUID_3 0xbf06438c
#define CTRL_GUID_4 0xb4d914c0
#endif

View File

@ -0,0 +1,7 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
TARGET = bw_example_fxpp_satur
CPP_SOURCES_EXTRA = ${ROOT_DIR}/../src/bw_example_fxpp_satur.cpp
include ${ROOT_DIR}/../../common/daisy-seed/daisy-seed.mk

View File

@ -0,0 +1,36 @@
/*
* 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 authors: Stefano D'Angelo
*/
#ifndef _CONFIG_DAISY_SEED_H
#define _CONFIG_DAISY_SEED_H
struct config_pin {
int param_index;
int pin;
};
#define NUM_PINS 2
static struct config_pin config_pins[NUM_PINS] = {
{ 0, 15 },
{ 1, 16 }
};
#endif

View File

@ -0,0 +1,62 @@
/*
* 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
*/
#include "bw_example_fxpp_satur.h"
void bw_example_fxpp_satur_init(bw_example_fxpp_satur *instance) {
(void)instance;
}
void bw_example_fxpp_satur_set_sample_rate(bw_example_fxpp_satur *instance, float sample_rate) {
instance->satur.setSampleRate(2.f * sample_rate);
}
void bw_example_fxpp_satur_reset(bw_example_fxpp_satur *instance) {
instance->satur.reset();
instance->srcUp.reset();
instance->srcDown.reset();
}
void bw_example_fxpp_satur_process(bw_example_fxpp_satur *instance, const float** x, float** y, int n_samples) {
int i = 0;
while (i < n_samples) {
int n = bw_mini32(n_samples - i, BUF_SIZE >> 1);
instance->srcUp.process({x[0] + i}, {instance->buf}, n);
instance->satur.process({instance->buf}, {instance->buf}, n << 1);
instance->srcDown.process({instance->buf}, {y[0] + i}, n << 1);
i += n;
}
}
void bw_example_fxpp_satur_set_parameter(bw_example_fxpp_satur *instance, int index, float value) {
instance->params[index] = value;
switch (index) {
case p_bias:
instance->satur.setBias(5.f * value - 2.5f);
break;
case p_gain:
instance->satur.setGain(0.1f + (10.f - 0.1f) * value * value * value);
break;
}
}
float bw_example_fxpp_satur_get_parameter(bw_example_fxpp_satur *instance, int index) {
return instance->params[index];
}

View File

@ -0,0 +1,64 @@
/*
* 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 _BW_EXAMPLE_FXPP_SATUR_H
#define _BW_EXAMPLE_FXPP_SATUR_H
#include <bwpp_satur.h>
#include <bwpp_src_int.h>
using namespace Brickworks;
extern "C" {
enum {
p_bias,
p_gain,
p_n
};
#define BUF_SIZE 32
struct _bw_example_fxpp_satur {
// Sub-components
Satur<1> satur;
SRCInt<1> srcUp;
SRCInt<1> srcDown;
// Parameters
float params[p_n];
// Buffers
float buf[BUF_SIZE];
_bw_example_fxpp_satur() : srcUp(2), srcDown(-2) {}
};
typedef struct _bw_example_fxpp_satur bw_example_fxpp_satur;
void bw_example_fxpp_satur_init(bw_example_fxpp_satur *instance);
void bw_example_fxpp_satur_set_sample_rate(bw_example_fxpp_satur *instance, float sample_rate);
void bw_example_fxpp_satur_reset(bw_example_fxpp_satur *instance);
void bw_example_fxpp_satur_process(bw_example_fxpp_satur *instance, const float** x, float** y, int n_samples);
void bw_example_fxpp_satur_set_parameter(bw_example_fxpp_satur *instance, int index, float value);
float bw_example_fxpp_satur_get_parameter(bw_example_fxpp_satur *instance, int index);
}
#endif

View File

@ -0,0 +1,88 @@
/*
* 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 authors: Stefano D'Angelo
*/
#ifndef _CONFIG_H
#define _CONFIG_H
// Definitions
#define IO_MONO 1
#define IO_STEREO (1<<1)
struct config_io_bus {
const char *name;
char out;
char aux;
char cv;
char configs;
};
struct config_parameter {
const char *name;
const char *shortName;
const char *units;
char out;
char bypass;
int steps;
float defaultValueUnmapped;
};
// Data
#define COMPANY_NAME "Orastron"
#define COMPANY_WEBSITE "https://www.orastron.com/"
#define COMPANY_MAILTO "mailto:info@orastron.com"
#define PLUGIN_NAME "bw_example_fxpp_satur"
#define PLUGIN_VERSION "0.5.0"
#define NUM_BUSES_IN 1
#define NUM_BUSES_OUT 1
#define NUM_CHANNELS_IN 1
#define NUM_CHANNELS_OUT 1
static struct config_io_bus config_buses_in[NUM_BUSES_IN] = {
{ "Audio in", 0, 0, 0, IO_MONO }
};
static struct config_io_bus config_buses_out[NUM_BUSES_OUT] = {
{ "Audio out", 1, 0, 0, IO_MONO }
};
#define NUM_PARAMETERS 2
static struct config_parameter config_parameters[NUM_PARAMETERS] = {
{ "Bias", "Bias", "", 0, 0, 0, 0.5f },
{ "Gain", "Gain", "", 0, 0, 0, 0.4641588833612779f }
};
// Internal API
#include "bw_example_fxpp_satur.h"
#define P_TYPE bw_example_fxpp_satur
#define P_INIT bw_example_fxpp_satur_init
#define P_SET_SAMPLE_RATE bw_example_fxpp_satur_set_sample_rate
#define P_RESET bw_example_fxpp_satur_reset
#define P_PROCESS bw_example_fxpp_satur_process
#define P_SET_PARAMETER bw_example_fxpp_satur_set_parameter
#define P_GET_PARAMETER bw_example_fxpp_satur_get_parameter
#endif

View File

@ -0,0 +1,6 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
NAME := bw_example_fxpp_satur
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fxpp_satur.cpp
include ${ROOT_DIR}/../../common/vst3/vst3.mk

View File

@ -0,0 +1,36 @@
/*
* 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 authors: Stefano D'Angelo, Paolo Marrone
*/
#ifndef _VST3_CONFIG_H
#define _VST3_CONFIG_H
#define PLUGIN_SUBCATEGORY "Fx|Distortion"
#define PLUGIN_GUID_1 0xf7465fb8
#define PLUGIN_GUID_2 0x8d284b9d
#define PLUGIN_GUID_3 0x842007fe
#define PLUGIN_GUID_4 0xc0301b51
#define CTRL_GUID_1 0xab9d28b9
#define CTRL_GUID_2 0x2cbe44f0
#define CTRL_GUID_3 0xbbf42db0
#define CTRL_GUID_4 0x8c0e30ed
#endif

107
include/bwpp_noise_gate.h Normal file
View File

@ -0,0 +1,107 @@
/*
* 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 {
template<BW_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);
private:
bw_noise_gate_coeffs coeffs;
bw_noise_gate_state states[N_CHANNELS];
bw_noise_gate_state *statesP[N_CHANNELS];
};
template<BW_SIZE_T N_CHANNELS>
NoiseGate<N_CHANNELS>::NoiseGate() {
bw_noise_gate_init(&coeffs);
for (unsigned int i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<BW_SIZE_T N_CHANNELS>
void NoiseGate<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_noise_gate_set_sample_rate(&coeffs, sampleRate);
}
template<BW_SIZE_T N_CHANNELS>
void NoiseGate<N_CHANNELS>::reset() {
bw_noise_gate_reset_coeffs(&coeffs);
for (unsigned int i = 0; i < N_CHANNELS; i++)
bw_noise_gate_reset_state(&coeffs, states + i);
}
template<BW_SIZE_T N_CHANNELS>
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<BW_SIZE_T N_CHANNELS>
void NoiseGate<N_CHANNELS>::setTreshLin(float value) {
bw_noise_gate_set_thresh_lin(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void NoiseGate<N_CHANNELS>::setTreshDBFS(float value) {
bw_noise_gate_set_thresh_dBFS(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void NoiseGate<N_CHANNELS>::setRatio(float value) {
bw_noise_gate_set_ratio(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void NoiseGate<N_CHANNELS>::setAttackTau(float value) {
bw_noise_gate_set_attack_tau(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void NoiseGate<N_CHANNELS>::setReleaseTau(float value) {
bw_noise_gate_set_release_tau(&coeffs, value);
}
}
#endif

75
include/bwpp_noise_gen.h Normal file
View File

@ -0,0 +1,75 @@
/*
* 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 {
template<BW_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();
private:
bw_noise_gen_coeffs coeffs;
};
template<BW_SIZE_T N_CHANNELS>
NoiseGen<N_CHANNELS>::NoiseGen(uint64_t *BW_RESTRICT state) {
bw_noise_gen_init(&coeffs, state);
}
template<BW_SIZE_T N_CHANNELS>
void NoiseGen<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_noise_gen_set_sample_rate(&coeffs, sampleRate);
}
template<BW_SIZE_T N_CHANNELS>
void NoiseGen<N_CHANNELS>::process(
std::array<float *, N_CHANNELS> y,
int nSamples) {
for (int i = 0; i < N_CHANNELS; i++)
bw_noise_gen_process(&coeffs, y.data()[i], nSamples);
}
template<BW_SIZE_T N_CHANNELS>
void NoiseGen<N_CHANNELS>::setSampleRateScaling(bool value) {
bw_noise_gen_set_sample_rate_scaling(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
float NoiseGen<N_CHANNELS>::getScalingK(float value) {
return bw_noise_gen_get_scaling_k(&coeffs);
}
}
#endif

93
include/bwpp_satur.h Normal file
View File

@ -0,0 +1,93 @@
/*
* 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_SATUR_H
#define BWPP_SATUR_H
#include <bw_satur.h>
#include <array>
namespace Brickworks {
template<BW_SIZE_T N_CHANNELS>
class Satur {
public:
Satur();
void setSampleRate(float sampleRate);
void reset();
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples);
void setBias(float value);
void setGain(float value);
void setGainCompensation(bool value);
private:
bw_satur_coeffs coeffs;
bw_satur_state states[N_CHANNELS];
bw_satur_state *statesP[N_CHANNELS];
};
template<BW_SIZE_T N_CHANNELS>
Satur<N_CHANNELS>::Satur() {
bw_satur_init(&coeffs);
for (unsigned int i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<BW_SIZE_T N_CHANNELS>
void Satur<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_satur_set_sample_rate(&coeffs, sampleRate);
}
template<BW_SIZE_T N_CHANNELS>
void Satur<N_CHANNELS>::reset() {
bw_satur_reset_coeffs(&coeffs);
for (unsigned int i = 0; i < N_CHANNELS; i++)
bw_satur_reset_state(&coeffs, states + i);
}
template<BW_SIZE_T N_CHANNELS>
void Satur<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_satur_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples);
}
template<BW_SIZE_T N_CHANNELS>
void Satur<N_CHANNELS>::setBias(float value) {
bw_satur_set_bias(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void Satur<N_CHANNELS>::setGain(float value) {
bw_satur_set_gain(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void Satur<N_CHANNELS>::setGainCompensation(bool value) {
bw_satur_set_gain_compensation(&coeffs, value);
}
}
#endif