bwpp_{src,delay} + fxpp_delay

This commit is contained in:
Stefano D'Angelo 2023-07-01 07:33:21 +02:00
parent c3caa91f99
commit ebf1712e74
10 changed files with 459 additions and 1 deletions

2
TODO
View File

@ -63,7 +63,7 @@ code:
* allow nullptr in C++ wrappers where process_multi arg can be NULL
* src post filt?
* bw_env_gen process_multi gate const?
* c++ get coeffs/state? or public?
* c++ get coeffs/state? or public? src nIn/OutSamples case (array vs single value), delay read/write, process1? process single?
* bw_buf invert src dest order?
build system:

View File

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

View File

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

View File

@ -0,0 +1,50 @@
/*
* 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_delay.h"
void bw_example_fxpp_delay_init(bw_example_fxpp_delay *instance) {
(void)instance;
}
void bw_example_fxpp_delay_set_sample_rate(bw_example_fxpp_delay *instance, float sample_rate) {
instance->delay.setSampleRate(sample_rate);
}
void bw_example_fxpp_delay_reset(bw_example_fxpp_delay *instance) {
instance->delay.reset();
}
void bw_example_fxpp_delay_process(bw_example_fxpp_delay *instance, const float** x, float** y, int n_samples) {
instance->delay.process({x[0]}, {y[0]}, n_samples);
}
void bw_example_fxpp_delay_set_parameter(bw_example_fxpp_delay *instance, int index, float value) {
instance->params[index] = value;
switch (index) {
case p_delay:
instance->delay.setDelay(value);
break;
}
}
float bw_example_fxpp_delay_get_parameter(bw_example_fxpp_delay *instance, int index) {
return instance->params[index];
}

View File

@ -0,0 +1,53 @@
/*
* 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_WAH_H
#define _BW_EXAMPLE_FXPP_WAH_H
#include <bwpp_delay.h>
using namespace Brickworks;
extern "C" {
enum {
p_delay,
p_n
};
struct _bw_example_fxpp_delay {
// Sub-components
Delay<1> delay;
// Parameters
float params[p_n];
};
typedef struct _bw_example_fxpp_delay bw_example_fxpp_delay;
void bw_example_fxpp_delay_init(bw_example_fxpp_delay *instance);
void bw_example_fxpp_delay_set_sample_rate(bw_example_fxpp_delay *instance, float sample_rate);
void bw_example_fxpp_delay_reset(bw_example_fxpp_delay *instance);
void bw_example_fxpp_delay_process(bw_example_fxpp_delay *instance, const float** x, float** y, int n_samples);
void bw_example_fxpp_delay_set_parameter(bw_example_fxpp_delay *instance, int index, float value);
float bw_example_fxpp_delay_get_parameter(bw_example_fxpp_delay *instance, int index);
}
#endif

View File

@ -0,0 +1,87 @@
/*
* 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_delay"
#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 1
static struct config_parameter config_parameters[NUM_PARAMETERS] = {
{ "Delay", "Delay", "", 0, 0, 0, 0.f }
};
// Internal API
#include "bw_example_fxpp_delay.h"
#define P_TYPE bw_example_fxpp_delay
#define P_INIT bw_example_fxpp_delay_init
#define P_SET_SAMPLE_RATE bw_example_fxpp_delay_set_sample_rate
#define P_RESET bw_example_fxpp_delay_reset
#define P_PROCESS bw_example_fxpp_delay_process
#define P_SET_PARAMETER bw_example_fxpp_delay_set_parameter
#define P_GET_PARAMETER bw_example_fxpp_delay_get_parameter
#endif

View File

@ -0,0 +1,6 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
NAME := bw_example_fxpp_delay
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fxpp_delay.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|Delay"
#define PLUGIN_GUID_1 0x9564c53d
#define PLUGIN_GUID_2 0x84b84647
#define PLUGIN_GUID_3 0x81ad2327
#define PLUGIN_GUID_4 0xbf001432
#define CTRL_GUID_1 0x60813317
#define CTRL_GUID_2 0x015644cd
#define CTRL_GUID_3 0xb8c49142
#define CTRL_GUID_4 0x13b4a42b
#endif

117
include/bwpp_delay.h Normal file
View File

@ -0,0 +1,117 @@
/*
* 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_DELAY_H
#define BWPP_DELAY_H
#include <bw_delay.h>
#include <array>
namespace Brickworks {
template<BW_SIZE_T N_CHANNELS>
class Delay {
public:
Delay(float maxDelay = 1.f);
~Delay();
void setSampleRate(float sampleRate);
void reset();
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples);
float read(BW_SIZE_T channel, BW_SIZE_T di, float df);
void write(BW_SIZE_T channel, float x);
void setDelay(float value);
BW_SIZE_T getLength();
private:
bw_delay_coeffs coeffs;
bw_delay_state states[N_CHANNELS];
bw_delay_state *statesP[N_CHANNELS];
void *mem;
};
template<BW_SIZE_T N_CHANNELS>
inline Delay<N_CHANNELS>::Delay(float maxDelay) {
bw_delay_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 Delay<N_CHANNELS>::~Delay() {
if (mem != nullptr)
operator delete(mem);
}
template<BW_SIZE_T N_CHANNELS>
inline void Delay<N_CHANNELS>::setSampleRate(float sampleRate) {
bw_delay_set_sample_rate(&coeffs, sampleRate);
BW_SIZE_T req = bw_delay_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_delay_mem_set(&coeffs, states + i, m);
}
template<BW_SIZE_T N_CHANNELS>
inline void Delay<N_CHANNELS>::reset() {
bw_delay_reset_coeffs(&coeffs);
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
bw_delay_reset_state(&coeffs, states + i);
}
template<BW_SIZE_T N_CHANNELS>
inline void Delay<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
int nSamples) {
bw_delay_process_multi(&coeffs, statesP, x.data(), y.data(), N_CHANNELS, nSamples);
}
template<BW_SIZE_T N_CHANNELS>
inline float Delay<N_CHANNELS>::read(BW_SIZE_T channel, BW_SIZE_T di, float df) {
return bw_delay_read(&coeffs, states + channel, di, df);
}
template<BW_SIZE_T N_CHANNELS>
inline void Delay<N_CHANNELS>::write(BW_SIZE_T channel, float x) {
bw_delay_write(&coeffs, states + channel, x);
}
template<BW_SIZE_T N_CHANNELS>
inline void Delay<N_CHANNELS>::setDelay(float value) {
bw_delay_set_delay(&coeffs, value);
}
template<BW_SIZE_T N_CHANNELS>
inline BW_SIZE_T Delay<N_CHANNELS>::getLength() {
return bw_delay_get_length(&coeffs);
}
}
#endif

67
include/bwpp_src.h Normal file
View File

@ -0,0 +1,67 @@
/*
* 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_SRC_H
#define BWPP_SRC_H
#include <bw_src.h>
#include <array>
namespace Brickworks {
template<BW_SIZE_T N_CHANNELS>
class SRC {
public:
SRC(float ratio);
void reset(float x0 = 0.f);
void process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
std::array<int *, N_CHANNELS> nInSamples,
std::array<int *, N_CHANNELS> nOutSamples);
private:
bw_src_coeffs coeffs;
bw_src_state states[N_CHANNELS];
};
template<BW_SIZE_T N_CHANNELS>
inline SRC<N_CHANNELS>::SRC(float ratio) {
bw_src_init(&coeffs, ratio);
}
template<BW_SIZE_T N_CHANNELS>
inline void SRC<N_CHANNELS>::reset(float x0) {
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
bw_src_reset_state(&coeffs, states + i, x0);
}
template<BW_SIZE_T N_CHANNELS>
inline void SRC<N_CHANNELS>::process(
std::array<const float *, N_CHANNELS> x,
std::array<float *, N_CHANNELS> y,
std::array<int *, N_CHANNELS> nInSamples,
std::array<int *, N_CHANNELS> nOutSamples) {
for (BW_SIZE_T i = 0; i < N_CHANNELS; i++)
bw_src_process(&coeffs, states + i, x.data()[i], y.data()[i], nInSamples.data()[i], nOutSamples.data()[i]);
}
}
#endif