new bwpp_{mm1,mm2,slew_lim}, fxpp_{mm1,mm2}

This commit is contained in:
Stefano D'Angelo 2023-06-21 17:02:32 +02:00
parent 65bc52b55e
commit 1092dc14af
17 changed files with 919 additions and 0 deletions

View File

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

View File

@ -0,0 +1,37 @@
/*
* 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 3
static struct config_pin config_pins[NUM_PINS] = {
{ 0, 15 },
{ 1, 16 },
{ 2, 17 }
};
#endif

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
*/
#include "bw_example_fxpp_mm1.h"
void bw_example_fxpp_mm1_init(bw_example_fxpp_mm1 *instance) {
(void)instance;
}
void bw_example_fxpp_mm1_set_sample_rate(bw_example_fxpp_mm1 *instance, float sample_rate) {
instance->mm1.setSampleRate(sample_rate);
}
void bw_example_fxpp_mm1_reset(bw_example_fxpp_mm1 *instance) {
instance->mm1.reset();
}
void bw_example_fxpp_mm1_process(bw_example_fxpp_mm1 *instance, const float** x, float** y, int n_samples) {
instance->mm1.process({x[0]}, {y[0]}, n_samples);
}
void bw_example_fxpp_mm1_set_parameter(bw_example_fxpp_mm1 *instance, int index, float value) {
instance->params[index] = value;
switch (index) {
case p_cutoff:
instance->mm1.setCutoff((20e3f - 20.f) * value * value * value + 20.f);
break;
case p_input_coeff:
instance->mm1.setCoeffX(2.f * value - 1.f);
break;
case p_lp_coeff:
instance->mm1.setCoeffLp(2.f * value - 1.f);
break;
}
}
float bw_example_fxpp_mm1_get_parameter(bw_example_fxpp_mm1 *instance, int index) {
return instance->params[index];
}

View File

@ -0,0 +1,55 @@
/*
* 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_MM1_H
#define _BW_EXAMPLE_FXPP_MM1_H
#include <bwpp_mm1.h>
using namespace Brickworks;
extern "C" {
enum {
p_cutoff,
p_input_coeff,
p_lp_coeff,
p_n
};
struct _bw_example_fxpp_mm1 {
// Sub-components
MM1<1> mm1;
// Parameters
float params[p_n];
};
typedef struct _bw_example_fxpp_mm1 bw_example_fxpp_mm1;
void bw_example_fxpp_mm1_init(bw_example_fxpp_mm1 *instance);
void bw_example_fxpp_mm1_set_sample_rate(bw_example_fxpp_mm1 *instance, float sample_rate);
void bw_example_fxpp_mm1_reset(bw_example_fxpp_mm1 *instance);
void bw_example_fxpp_mm1_process(bw_example_fxpp_mm1 *instance, const float** x, float** y, int n_samples);
void bw_example_fxpp_mm1_set_parameter(bw_example_fxpp_mm1 *instance, int index, float value);
float bw_example_fxpp_mm1_get_parameter(bw_example_fxpp_mm1 *instance, int index);
}
#endif

View File

@ -0,0 +1,89 @@
/*
* 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_mm1"
#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 3
static struct config_parameter config_parameters[NUM_PARAMETERS] = {
{ "Cutoff", "Cutoff", "Hz", 0, 0, 0, 0.5f },
{ "Input coefficient", "In coeff", "", 0, 0, 0, 1.f },
{ "Lowpass coefficient", "LP coeff", "", 0, 0, 0, 0.5f }
};
// Internal API
#include "bw_example_fxpp_mm1.h"
#define P_TYPE bw_example_fxpp_mm1
#define P_INIT bw_example_fxpp_mm1_init
#define P_SET_SAMPLE_RATE bw_example_fxpp_mm1_set_sample_rate
#define P_RESET bw_example_fxpp_mm1_reset
#define P_PROCESS bw_example_fxpp_mm1_process
#define P_SET_PARAMETER bw_example_fxpp_mm1_set_parameter
#define P_GET_PARAMETER bw_example_fxpp_mm1_get_parameter
#endif

View File

@ -0,0 +1,6 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
NAME := bw_example_fxpp_mm1
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fxpp_mm1.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|Filter"
#define PLUGIN_GUID_1 0xe5b68572
#define PLUGIN_GUID_2 0xe7ea4781
#define PLUGIN_GUID_3 0x8c4de64e
#define PLUGIN_GUID_4 0x061d63a3
#define CTRL_GUID_1 0x6763895a
#define CTRL_GUID_2 0x52224498
#define CTRL_GUID_3 0xa51e05e7
#define CTRL_GUID_4 0x972ed1bf
#endif

View File

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

View File

@ -0,0 +1,40 @@
/*
* 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 6
static struct config_pin config_pins[NUM_PINS] = {
{ 0, 15 },
{ 1, 16 },
{ 2, 17 },
{ 3, 18 },
{ 4, 19 },
{ 5, 20 }
};
#endif

View File

@ -0,0 +1,65 @@
/*
* 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_mm2.h"
void bw_example_fxpp_mm2_init(bw_example_fxpp_mm2 *instance) {
(void)instance;
}
void bw_example_fxpp_mm2_set_sample_rate(bw_example_fxpp_mm2 *instance, float sample_rate) {
instance->mm2.setSampleRate(sample_rate);
}
void bw_example_fxpp_mm2_reset(bw_example_fxpp_mm2 *instance) {
instance->mm2.reset();
}
void bw_example_fxpp_mm2_process(bw_example_fxpp_mm2 *instance, const float** x, float** y, int n_samples) {
instance->mm2.process({x[0]}, {y[0]}, n_samples);
}
void bw_example_fxpp_mm2_set_parameter(bw_example_fxpp_mm2 *instance, int index, float value) {
instance->params[index] = value;
switch (index) {
case p_cutoff:
instance->mm2.setCutoff((20e3f - 20.f) * value * value * value + 20.f);
break;
case p_Q:
instance->mm2.setQ(0.5f + 9.5f * value);
break;
case p_input_coeff:
instance->mm2.setCoeffX(2.f * value - 1.f);
break;
case p_lp_coeff:
instance->mm2.setCoeffLp(2.f * value - 1.f);
break;
case p_bp_coeff:
instance->mm2.setCoeffBp(2.f * value - 1.f);
break;
case p_hp_coeff:
instance->mm2.setCoeffHp(2.f * value - 1.f);
break;
}
}
float bw_example_fxpp_mm2_get_parameter(bw_example_fxpp_mm2 *instance, int index) {
return instance->params[index];
}

View File

@ -0,0 +1,58 @@
/*
* 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_MM2_H
#define _BW_EXAMPLE_FXPP_MM2_H
#include <bwpp_mm2.h>
using namespace Brickworks;
extern "C" {
enum {
p_cutoff,
p_Q,
p_input_coeff,
p_lp_coeff,
p_bp_coeff,
p_hp_coeff,
p_n
};
struct _bw_example_fxpp_mm2 {
// Sub-components
MM2<1> mm2;
// Parameters
float params[p_n];
};
typedef struct _bw_example_fxpp_mm2 bw_example_fxpp_mm2;
void bw_example_fxpp_mm2_init(bw_example_fxpp_mm2 *instance);
void bw_example_fxpp_mm2_set_sample_rate(bw_example_fxpp_mm2 *instance, float sample_rate);
void bw_example_fxpp_mm2_reset(bw_example_fxpp_mm2 *instance);
void bw_example_fxpp_mm2_process(bw_example_fxpp_mm2 *instance, const float** x, float** y, int n_samples);
void bw_example_fxpp_mm2_set_parameter(bw_example_fxpp_mm2 *instance, int index, float value);
float bw_example_fxpp_mm2_get_parameter(bw_example_fxpp_mm2 *instance, int index);
}
#endif

View File

@ -0,0 +1,92 @@
/*
* 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_mm2"
#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 6
static struct config_parameter config_parameters[NUM_PARAMETERS] = {
{ "Cutoff", "Cutoff", "Hz", 0, 0, 0, 0.5f },
{ "Q", "Q", "", 0, 0, 0, 0.f },
{ "Input coefficient", "In coeff", "", 0, 0, 0, 1.f },
{ "Lowpass coefficient", "LP coeff", "", 0, 0, 0, 0.5f },
{ "Bandpass coefficient", "BP coeff", "", 0, 0, 0, 0.5f },
{ "Highpass coefficient", "HP coeff", "", 0, 0, 0, 0.5f }
};
// Internal API
#include "bw_example_fxpp_mm2.h"
#define P_TYPE bw_example_fxpp_mm2
#define P_INIT bw_example_fxpp_mm2_init
#define P_SET_SAMPLE_RATE bw_example_fxpp_mm2_set_sample_rate
#define P_RESET bw_example_fxpp_mm2_reset
#define P_PROCESS bw_example_fxpp_mm2_process
#define P_SET_PARAMETER bw_example_fxpp_mm2_set_parameter
#define P_GET_PARAMETER bw_example_fxpp_mm2_get_parameter
#endif

View File

@ -0,0 +1,6 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
NAME := bw_example_fxpp_mm2
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fxpp_mm2.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|Filter"
#define PLUGIN_GUID_1 0x7f718015
#define PLUGIN_GUID_2 0x3b6740f5
#define PLUGIN_GUID_3 0xaef697a8
#define PLUGIN_GUID_4 0x1ede0a4e
#define CTRL_GUID_1 0x5c6c769d
#define CTRL_GUID_2 0xf77e4c79
#define CTRL_GUID_3 0x918b11a9
#define CTRL_GUID_4 0x27788f1e
#endif

105
include/bwpp_mm1.h Normal file
View File

@ -0,0 +1,105 @@
/*
* Brickworks
*
* Copyright (C) 2023 Orastron Srl unipersonale
*
* Brickworks is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* Brickworks is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Brickworks. If not, see <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#ifndef BWPP_MM1_H
#define BWPP_MM1_H
#include <bw_mm1.h>
#include <array>
namespace Brickworks {
template<BW_SIZE_T N_CHANNELS>
class MM1 {
public:
MM1();
void setSampleRate(float sampleRate);
void reset(float x0 = 0.f);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples);
void setCutoff(float value);
void setPrewarpAtCutoff(bool value);
void setPrewarpFreq(float value);
void setCoeffX(float value);
void setCoeffLp(float value);
private:
bw_mm1_coeffs coeffs;
bw_mm1_state states[N_CHANNELS];
bw_mm1_state *statesP[N_CHANNELS];
};
template<BW_SIZE_T N_CHANNELS>
MM1<N_CHANNELS>::MM1() {
bw_mm1_init(&coeffs);
for (unsigned int i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<BW_SIZE_T N_CHANNELS>
void MM1<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_mm1_set_sample_rate(&coeffs, sampleRate);
}
template<BW_SIZE_T N_CHANNELS>
void MM1<N_CHANNELS>::reset(float x0) {
bw_mm1_reset_coeffs(&coeffs);
for (unsigned int i = 0; i < N_CHANNELS; i++)
bw_mm1_reset_state(&coeffs, states + i, x0);
}
template<BW_SIZE_T N_CHANNELS>
void MM1<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_mm1_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples);
}
template<BW_SIZE_T N_CHANNELS>
void MM1<N_CHANNELS>::setCutoff(float value) {
bw_mm1_set_cutoff(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void MM1<N_CHANNELS>::setPrewarpAtCutoff(bool value) {
bw_mm1_set_prewarp_at_cutoff(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void MM1<N_CHANNELS>::setPrewarpFreq(float value) {
bw_mm1_set_prewarp_freq(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void MM1<N_CHANNELS>::setCoeffX(float value) {
bw_mm1_set_coeff_x(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void MM1<N_CHANNELS>::setCoeffLp(float value) {
bw_mm1_set_coeff_lp(&coeffs, value);
}
}
#endif

123
include/bwpp_mm2.h Normal file
View File

@ -0,0 +1,123 @@
/*
* Brickworks
*
* Copyright (C) 2023 Orastron Srl unipersonale
*
* Brickworks is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3 of the License.
*
* Brickworks is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Brickworks. If not, see <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#ifndef BWPP_MM2_H
#define BWPP_MM2_H
#include <bw_mm2.h>
#include <array>
namespace Brickworks {
template<BW_SIZE_T N_CHANNELS>
class MM2 {
public:
MM2();
void setSampleRate(float sampleRate);
void reset(float x0 = 0.f);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples);
void setCutoff(float value);
void setQ(float value);
void setPrewarpAtCutoff(bool value);
void setPrewarpFreq(float value);
void setCoeffX(float value);
void setCoeffLp(float value);
void setCoeffBp(float value);
void setCoeffHp(float value);
private:
bw_mm2_coeffs coeffs;
bw_mm2_state states[N_CHANNELS];
bw_mm2_state *statesP[N_CHANNELS];
};
template<BW_SIZE_T N_CHANNELS>
MM2<N_CHANNELS>::MM2() {
bw_mm2_init(&coeffs);
for (unsigned int i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<BW_SIZE_T N_CHANNELS>
void MM2<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_mm2_set_sample_rate(&coeffs, sampleRate);
}
template<BW_SIZE_T N_CHANNELS>
void MM2<N_CHANNELS>::reset(float x0) {
bw_mm2_reset_coeffs(&coeffs);
for (unsigned int i = 0; i < N_CHANNELS; i++)
bw_mm2_reset_state(&coeffs, states + i, x0);
}
template<BW_SIZE_T N_CHANNELS>
void MM2<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_mm2_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples);
}
template<BW_SIZE_T N_CHANNELS>
void MM2<N_CHANNELS>::setCutoff(float value) {
bw_mm2_set_cutoff(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void MM2<N_CHANNELS>::setQ(float value) {
bw_mm2_set_Q(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void MM2<N_CHANNELS>::setPrewarpAtCutoff(bool value) {
bw_mm2_set_prewarp_at_cutoff(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void MM2<N_CHANNELS>::setPrewarpFreq(float value) {
bw_mm2_set_prewarp_freq(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void MM2<N_CHANNELS>::setCoeffX(float value) {
bw_mm2_set_coeff_x(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void MM2<N_CHANNELS>::setCoeffLp(float value) {
bw_mm2_set_coeff_lp(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void MM2<N_CHANNELS>::setCoeffBp(float value) {
bw_mm2_set_coeff_bp(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void MM2<N_CHANNELS>::setCoeffHp(float value) {
bw_mm2_set_coeff_hp(&coeffs, value);
}
}
#endif

101
include/bwpp_slew_lim.h Normal file
View File

@ -0,0 +1,101 @@
/*
* 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_SLEW_LIM_H
#define BWPP_SLEW_LIM_H
#include <bw_slew_lim.h>
#include <array>
namespace Brickworks {
template<BW_SIZE_T N_CHANNELS>
class SlewLim {
public:
SlewLim();
void setSampleRate(float sampleRate);
void reset(float y_z1 = 0.f);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples);
void setMaxRate(float value);
void setMaxRateUp(float value);
void setMaxRateDown(float value);
void setStickyMode(bw_slew_lim_sticky_mode value);
float getYZ1(BW_SIZE_T channel);
private:
bw_slew_lim_coeffs coeffs;
bw_slew_lim_state states[N_CHANNELS];
bw_slew_lim_state *statesP[N_CHANNELS];
};
template<BW_SIZE_T N_CHANNELS>
SlewLim<N_CHANNELS>::SlewLim() {
bw_slew_lim_init(&coeffs);
for (unsigned int i = 0; i < N_CHANNELS; i++)
statesP[i] = states + i;
}
template<BW_SIZE_T N_CHANNELS>
void SlewLim<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_slew_lim_set_sample_rate(&coeffs, sampleRate);
}
template<BW_SIZE_T N_CHANNELS>
void SlewLim<N_CHANNELS>::reset(float y_z1) {
bw_slew_lim_reset_coeffs(&coeffs);
for (unsigned int i = 0; i < N_CHANNELS; i++)
bw_slew_lim_reset_state(&coeffs, states + i, y_z1);
}
template<BW_SIZE_T N_CHANNELS>
void SlewLim<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_slew_lim_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples);
}
template<BW_SIZE_T N_CHANNELS>
void SlewLim<N_CHANNELS>::setMaxRate(float value) {
bw_slew_lim_set_max_rate(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void SlewLim<N_CHANNELS>::setMaxRateUp(float value) {
bw_slew_lim_set_max_rate_up(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
void SlewLim<N_CHANNELS>::setMaxRateDown(float value) {
bw_slew_lim_set_max_rate_down(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
float SlewLim<N_CHANNELS>::getYZ1(BW_SIZE_T channel) {
return bw_slew_lim_get_y_z1(states + channel);
}
}
#endif