fixed bw_delay and bw_comb, cleaned fx_delay, added fx_comb

This commit is contained in:
Stefano D'Angelo 2023-04-05 12:46:22 +02:00
parent 7f8198b00e
commit 8db29e8bec
12 changed files with 404 additions and 29 deletions

View File

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

View File

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

View File

@ -0,0 +1,71 @@
/*
* 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_fx_comb.h"
void bw_example_fx_comb_init(bw_example_fx_comb *instance) {
bw_comb_init(&instance->comb_coeffs, 1.f);
}
void bw_example_fx_comb_set_sample_rate(bw_example_fx_comb *instance, float sample_rate) {
bw_comb_set_sample_rate(&instance->comb_coeffs, sample_rate);
}
BW_SIZE_T bw_example_fx_comb_mem_req(bw_example_fx_comb *instance) {
return bw_comb_mem_req(&instance->comb_coeffs);
}
void bw_example_fx_comb_mem_set(bw_example_fx_comb *instance, void *mem) {
bw_comb_mem_set(&instance->comb_state, mem);
}
void bw_example_fx_comb_reset(bw_example_fx_comb *instance) {
bw_comb_reset_coeffs(&instance->comb_coeffs);
bw_comb_reset_state(&instance->comb_coeffs, &instance->comb_state);
}
void bw_example_fx_comb_process(bw_example_fx_comb *instance, const float** x, float** y, int n_samples) {
bw_comb_process(&instance->comb_coeffs, &instance->comb_state, x[0], NULL, y[0], n_samples);
}
void bw_example_fx_comb_set_parameter(bw_example_fx_comb *instance, int index, float value) {
instance->params[index] = value;
switch (index) {
case p_ff_delay:
bw_comb_set_delay_ff(&instance->comb_coeffs, value);
break;
case p_fb_delay:
bw_comb_set_delay_fb(&instance->comb_coeffs, value);
break;
case p_blend:
bw_comb_set_coeff_blend(&instance->comb_coeffs, value);
break;
case p_ff:
bw_comb_set_coeff_ff(&instance->comb_coeffs, value + value - 1.f);
break;
case p_fb:
bw_comb_set_coeff_fb(&instance->comb_coeffs, 1.99f * value - 0.995f);
break;
}
}
float bw_example_fx_comb_get_parameter(bw_example_fx_comb *instance, int index) {
return instance->params[index];
}

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
*/
#ifndef _BW_EXAMPLE_FX_COMB_H
#define _BW_EXAMPLE_FX_COMB_H
#ifdef __cplusplus
extern "C" {
#endif
#include <bw_comb.h>
enum {
p_ff_delay,
p_fb_delay,
p_blend,
p_ff,
p_fb,
p_n
};
struct _bw_example_fx_comb {
// Sub-components
bw_comb_coeffs comb_coeffs;
bw_comb_state comb_state;
// Parameters
float params[p_n];
};
typedef struct _bw_example_fx_comb bw_example_fx_comb;
void bw_example_fx_comb_init(bw_example_fx_comb *instance);
void bw_example_fx_comb_set_sample_rate(bw_example_fx_comb *instance, float sample_rate);
BW_SIZE_T bw_example_fx_comb_mem_req(bw_example_fx_comb *instance);
void bw_example_fx_comb_mem_set(bw_example_fx_comb *instance, void *mem);
void bw_example_fx_comb_reset(bw_example_fx_comb *instance);
void bw_example_fx_comb_process(bw_example_fx_comb *instance, const float** x, float** y, int n_samples);
void bw_example_fx_comb_set_parameter(bw_example_fx_comb *instance, int index, float value);
float bw_example_fx_comb_get_parameter(bw_example_fx_comb *instance, int index);
#ifdef __cplusplus
}
#endif
#endif

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 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_fx_comb"
#define PLUGIN_VERSION "0.4.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 5
static struct config_parameter config_parameters[NUM_PARAMETERS] = {
{ "Feedforward delay", "FF delay", "", 0, 0, 0, 0.f },
{ "Feedback delay", "FB delay", "", 0, 0, 0, 0.f },
{ "Blend", "Blend", "", 0, 0, 0, 1.f },
{ "Feedforward", "FF", "", 0, 0, 0, 0.5f },
{ "Feedback", "FB", "", 0, 0, 0, 0.5f },
};
// Internal API
#include "bw_example_fx_comb.h"
#define P_TYPE bw_example_fx_comb
#define P_INIT bw_example_fx_comb_init
#define P_SET_SAMPLE_RATE bw_example_fx_comb_set_sample_rate
#define P_MEM_REQ bw_example_fx_comb_mem_req
#define P_MEM_SET bw_example_fx_comb_mem_set
#define P_RESET bw_example_fx_comb_reset
#define P_PROCESS bw_example_fx_comb_process
#define P_SET_PARAMETER bw_example_fx_comb_set_parameter
#define P_GET_PARAMETER bw_example_fx_comb_get_parameter
#endif

View File

@ -0,0 +1,6 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
NAME := bw_example_fx_comb
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_comb.c
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 0x8b647180
#define PLUGIN_GUID_2 0x32e14de2
#define PLUGIN_GUID_3 0x8e15ad4c
#define PLUGIN_GUID_4 0x5b9dab92
#define CTRL_GUID_1 0xf692427b
#define CTRL_GUID_2 0xcd9c46bf
#define CTRL_GUID_3 0x81b42ae0
#define CTRL_GUID_4 0x46afbea1
#endif

View File

@ -0,0 +1,5 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_comb.c
NEEDS_MEMSET := yes
include ${ROOT_DIR}/../../common/web/web.mk

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
*/
var buses = [
{
stereo: false,
output: false
},
{
stereo: false,
output: true
}
];
var parameters = [
{
name: "Feedforward delay",
output: false,
defaultValue: 0.0
},
{
name: "Feedback delay",
output: false,
defaultValue: 0.0
},
{
name: "Blend",
output: false,
defaultValue: 1.0
},
{
name: "Feedforward",
output: false,
defaultValue: 0.5
},
{
name: "Feedback",
output: false,
defaultValue: 0.5
}
];

View File

@ -39,9 +39,6 @@ struct _bw_example_fx_delay {
// Parameters
float params[p_n];
// Memory
void *mem;
};
typedef struct _bw_example_fx_delay bw_example_fx_delay;

View File

@ -80,16 +80,16 @@ static inline void bw_comb_set_sample_rate(bw_comb_coeffs *BW_RESTRICT coeffs, f
/*! <<<```
* Sets the `sample_rate` (Hz) value in `coeffs`.
*
* ### bw_delay_mem_req()
* ### bw_comb_mem_req()
* ```>>> */
static inline BW_SIZE_T bw_delay_mem_req(bw_delay_coeffs *BW_RESTRICT coeffs);
static inline BW_SIZE_T bw_comb_mem_req(bw_comb_coeffs *BW_RESTRICT coeffs);
/*! <<<```
* Returns the size, in bytes, of contiguous memory to be supplied to
* `bw_delay_mem_set()` using `coeffs`.
*
* ### bw_delay_mem_set()
* ### bw_comb_mem_set()
* ```>>> */
static inline void bw_delay_mem_set(bw_delay_state *BW_RESTRICT state, void *mem);
static inline void bw_comb_mem_set(bw_comb_state *BW_RESTRICT state, void *mem);
/*! <<<```
* Associates the contiguous memory block `mem` to the given `state`.
*
@ -153,9 +153,9 @@ static inline void bw_comb_set_delay_fb(bw_comb_coeffs *BW_RESTRICT coeffs, floa
*
* Default value: `0.f`.
*
* #### bw_comb_set_blend()
* #### bw_comb_set_coeff_blend()
* ```>>> */
static inline void bw_mm1_set_coeff_blend(bw_mm1_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_comb_set_coeff_blend(bw_comb_coeffs *BW_RESTRICT coeffs, float value);
/*! <<<```
* Sets the blend coefficient `value` in `coeffs`.
*
@ -163,7 +163,7 @@ static inline void bw_mm1_set_coeff_blend(bw_mm1_coeffs *BW_RESTRICT coeffs, flo
*
* #### bw_comb_set_coeff_ff()
* ```>>> */
static inline void bw_mm1_set_coeff_ff(bw_mm1_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_comb_set_coeff_ff(bw_comb_coeffs *BW_RESTRICT coeffs, float value);
/*! <<<```
* Sets the feedforward coefficient `value` in `coeffs`.
*
@ -171,7 +171,7 @@ static inline void bw_mm1_set_coeff_ff(bw_mm1_coeffs *BW_RESTRICT coeffs, float
*
* #### bw_comb_set_coeff_fb()
* ```>>> */
static inline void bw_mm1_set_coeff_fb(bw_mm1_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_comb_set_coeff_fb(bw_comb_coeffs *BW_RESTRICT coeffs, float value);
/*! <<<```
* Sets the feedback coefficient `value` in `coeffs`.
*
@ -185,17 +185,18 @@ static inline void bw_mm1_set_coeff_fb(bw_mm1_coeffs *BW_RESTRICT coeffs, float
#include <bw_delay.h>
#include <bw_gain.h>
#include <bw_one_pole.h>
#include <bw_math.h>
struct _bw_comb_coeffs {
// Sub-components
bw_delay_coeffs delay_coeffs;
bw_gain_coeffs blend_coeffs;
bw_gain_coeffs ff_coeffs;
bw_gain_coeffs fb_coeffs;
bw_one_pole smooth_coeffs;
bw_one_pole smooth_delay_ff_state;
bw_one_pole smooth_delay_fb_state;
bw_delay_coeffs delay_coeffs;
bw_gain_coeffs blend_coeffs;
bw_gain_coeffs ff_coeffs;
bw_gain_coeffs fb_coeffs;
bw_one_pole_coeffs smooth_coeffs;
bw_one_pole_state smooth_delay_ff_state;
bw_one_pole_state smooth_delay_fb_state;
// Coefficients
float fs;
@ -219,7 +220,7 @@ static inline void bw_comb_init(bw_comb_coeffs *BW_RESTRICT coeffs, float max_de
bw_gain_init(&coeffs->ff_coeffs);
bw_gain_init(&coeffs->fb_coeffs);
bw_one_pole_init(&coeffs->smooth_coeffs);
bw_one_pole_set_tau(&coeffs->smooth_coeffs, 0.005f);
bw_one_pole_set_tau(&coeffs->smooth_coeffs, 0.05f);
bw_gain_set_gain_lin(&coeffs->ff_coeffs, 0.f);
bw_gain_set_gain_lin(&coeffs->fb_coeffs, 0.f);
coeffs->delay_ff = 0.f;
@ -236,11 +237,11 @@ static inline void bw_comb_set_sample_rate(bw_comb_coeffs *BW_RESTRICT coeffs, f
coeffs->fs = sample_rate;
}
static inline BW_SIZE_T bw_delay_mem_req(bw_delay_coeffs *BW_RESTRICT coeffs) {
static inline BW_SIZE_T bw_comb_mem_req(bw_comb_coeffs *BW_RESTRICT coeffs) {
return bw_delay_mem_req(&coeffs->delay_coeffs);
}
static inline void bw_delay_mem_set(bw_delay_state *BW_RESTRICT state, void *mem) {
static inline void bw_comb_mem_set(bw_comb_state *BW_RESTRICT state, void *mem) {
bw_delay_mem_set(&state->delay_state, mem);
}
@ -292,8 +293,8 @@ static inline float bw_comb_process1(const bw_comb_coeffs *BW_RESTRICT coeffs, b
dffi = len;
dfff = 0.f;
}
const float fb = bw_delay_read(&coeffs->delay_coeffs, &state->delay_state, dfbi, dfbf);
const float v = x + fb;
const float fb = bw_delay_read(&coeffs->delay_coeffs, &state->delay_state, coeffs->dfbi, coeffs->dfbf);
const float v = x + bw_gain_process1(&coeffs->fb_coeffs, fb);
bw_delay_write(&coeffs->delay_coeffs, &state->delay_state, v);
const float ff = bw_delay_read(&coeffs->delay_coeffs, &state->delay_state, dffi, dfff);
return bw_gain_process1(&coeffs->blend_coeffs, v) + bw_gain_process1(&coeffs->ff_coeffs, ff);
@ -321,15 +322,15 @@ static inline void bw_comb_set_delay_fb(bw_comb_coeffs *BW_RESTRICT coeffs, floa
coeffs->delay_fb = value;
}
static inline void bw_mm1_set_coeff_blend(bw_mm1_coeffs *BW_RESTRICT coeffs, float value) {
static inline void bw_comb_set_coeff_blend(bw_comb_coeffs *BW_RESTRICT coeffs, float value) {
bw_gain_set_gain_lin(&coeffs->blend_coeffs, value);
}
static inline void bw_mm1_set_coeff_ff(bw_mm1_coeffs *BW_RESTRICT coeffs, float value) {
static inline void bw_comb_set_coeff_ff(bw_comb_coeffs *BW_RESTRICT coeffs, float value) {
bw_gain_set_gain_lin(&coeffs->ff_coeffs, value);
}
static inline void bw_mm1_set_coeff_fb(bw_mm1_coeffs *BW_RESTRICT coeffs, float value) {
static inline void bw_comb_set_coeff_fb(bw_comb_coeffs *BW_RESTRICT coeffs, float value) {
bw_gain_set_gain_lin(&coeffs->fb_coeffs, value);
}

View File

@ -153,7 +153,7 @@ static inline void bw_delay_set_delay(bw_delay_coeffs *BW_RESTRICT coeffs, float
*
* #### bw_delay_get_length()
* ```>>> */
static inline BW_SIZE_T bw_delay_get_length(bw_delay_coeffs *BW_RESTRICT coeffs);
static inline BW_SIZE_T bw_delay_get_length(const bw_delay_coeffs *BW_RESTRICT coeffs);
/*! <<<```
* Returns the length of the delay line in samples.
* }}} */
@ -220,9 +220,9 @@ static float bw_delay_read(const bw_delay_coeffs *BW_RESTRICT coeffs, const bw_d
}
static void bw_delay_write(const bw_delay_coeffs *BW_RESTRICT coeffs, bw_delay_state *BW_RESTRICT state, float x) {
state->buf[state->idx] = x;
state->idx++;
state->idx = state->idx == coeffs->len ? 0 : state->idx;
state->buf[state->idx] = x;
}
static inline void bw_delay_update_coeffs_ctrl(bw_delay_coeffs *BW_RESTRICT coeffs) {
@ -256,7 +256,7 @@ static inline void bw_delay_set_delay(bw_delay_coeffs *BW_RESTRICT coeffs, float
}
}
static inline BW_SIZE_T bw_delay_get_length(bw_delay_coeffs *BW_RESTRICT coeffs) {
static inline BW_SIZE_T bw_delay_get_length(const bw_delay_coeffs *BW_RESTRICT coeffs) {
return coeffs->len;
}