fix bw_balance + new fx_balance example + fix daisy seed synth simple

This commit is contained in:
Stefano D'Angelo 2023-02-14 10:14:37 +01:00
parent e4d2d984c8
commit 0db0e1b42d
13 changed files with 397 additions and 24 deletions

View File

@ -92,7 +92,7 @@ int main() {
#endif
for (int i = 0; i < NUM_CCS; i++)
if (v.control_number == config_ccs[i].cc)
P_SET_PARAMETER(&instance, config_ccs[i].param_index, v.value);
P_SET_PARAMETER(&instance, config_ccs[i].param_index, (1.f / 127.f) * v.value);
#ifdef P_MOD_WHEEL
}
#endif

View File

@ -0,0 +1,7 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
TARGET = bw_example_fx_balance
C_SOURCES += ${ROOT_DIR}/../src/bw_example_fx_balance.c
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,79 @@
/*
* 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_balance.h"
void bw_example_fx_balance_init(bw_example_fx_balance *instance) {
bw_balance_init(&instance->balance_coeffs);
bw_ppm_init(&instance->ppm_coeffs);
}
void bw_example_fx_balance_set_sample_rate(bw_example_fx_balance *instance, float sample_rate) {
bw_balance_set_sample_rate(&instance->balance_coeffs, sample_rate);
bw_ppm_set_sample_rate(&instance->ppm_coeffs, sample_rate);
}
void bw_example_fx_balance_reset(bw_example_fx_balance *instance) {
bw_balance_reset_coeffs(&instance->balance_coeffs);
bw_ppm_reset_coeffs(&instance->ppm_coeffs);
bw_ppm_reset_state(&instance->ppm_coeffs, &instance->ppm_l_state);
bw_ppm_reset_state(&instance->ppm_coeffs, &instance->ppm_r_state);
}
void bw_example_fx_balance_process(bw_example_fx_balance *instance, const float** x, float** y, int n_samples) {
bw_balance_process(&instance->balance_coeffs, x[0], x[1], y[0], y[1], n_samples);
bw_ppm_update_coeffs_ctrl(&instance->ppm_coeffs);
for (int i = 0; i < n_samples; i++) {
bw_ppm_update_coeffs_audio(&instance->ppm_coeffs);
bw_ppm_process1(&instance->ppm_coeffs, &instance->ppm_l_state, y[0][i]);
bw_ppm_process1(&instance->ppm_coeffs, &instance->ppm_r_state, y[1][i]);
}
}
void bw_example_fx_balance_set_parameter(bw_example_fx_balance *instance, int index, float value) {
instance->params[index] = value;
switch (index) {
case p_balance:
bw_balance_set_balance(&instance->balance_coeffs, value + value - 1.f);
break;
}
}
float bw_example_fx_balance_get_parameter(bw_example_fx_balance *instance, int index) {
float r = 0.f;
switch (index) {
case p_balance:
r = instance->params[p_balance];
break;
case p_balance + 1:
{
const float v = bw_ppm_get_y_z1(&instance->ppm_l_state);
r = v < -200.f ? 0.f : bw_clipf(0.01666666666666667f * v + 1.f, 0.f, 1.f);
break;
}
case p_balance + 2:
{
const float v = bw_ppm_get_y_z1(&instance->ppm_r_state);
r = v < -200.f ? 0.f : bw_clipf(0.01666666666666667f * v + 1.f, 0.f, 1.f);
break;
}
}
return r;
}

View File

@ -0,0 +1,60 @@
/*
* 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_BALANCE_H
#define _BW_EXAMPLE_FX_BALANCE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <bw_balance.h>
#include <bw_ppm.h>
#include <bw_math.h>
enum {
p_balance,
p_n
};
struct _bw_example_fx_balance {
// Sub-components
bw_balance_coeffs balance_coeffs;
bw_ppm_coeffs ppm_coeffs;
bw_ppm_state ppm_l_state;
bw_ppm_state ppm_r_state;
// Parameters
float params[p_n];
};
typedef struct _bw_example_fx_balance bw_example_fx_balance;
void bw_example_fx_balance_init(bw_example_fx_balance *instance);
void bw_example_fx_balance_set_sample_rate(bw_example_fx_balance *instance, float sample_rate);
void bw_example_fx_balance_reset(bw_example_fx_balance *instance);
void bw_example_fx_balance_process(bw_example_fx_balance *instance, const float** x, float** y, int n_samples);
void bw_example_fx_balance_set_parameter(bw_example_fx_balance *instance, int index, float value);
float bw_example_fx_balance_get_parameter(bw_example_fx_balance *instance, int index);
#ifdef __cplusplus
}
#endif
#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_fx_balance"
#define PLUGIN_VERSION "0.3.0"
#define NUM_BUSES_IN 1
#define NUM_BUSES_OUT 1
#define NUM_CHANNELS_IN 2
#define NUM_CHANNELS_OUT 2
static struct config_io_bus config_buses_in[NUM_BUSES_IN] = {
{ "Audio in", 0, 0, 0, IO_STEREO }
};
static struct config_io_bus config_buses_out[NUM_BUSES_OUT] = {
{ "Audio out", 1, 0, 0, IO_STEREO }
};
#define NUM_PARAMETERS 3
static struct config_parameter config_parameters[NUM_PARAMETERS] = {
{ "Balance", "Balance", "", 0, 0, 0, 0.5f },
{ "Left level", "L Level", "", 1, 0, 0, 0.f },
{ "Right level", "R Level", "", 1, 0, 0, 0.f }
};
// Internal API
#include "bw_example_fx_balance.h"
#define P_TYPE bw_example_fx_balance
#define P_INIT bw_example_fx_balance_init
#define P_SET_SAMPLE_RATE bw_example_fx_balance_set_sample_rate
#define P_RESET bw_example_fx_balance_reset
#define P_PROCESS bw_example_fx_balance_process
#define P_SET_PARAMETER bw_example_fx_balance_set_parameter
#define P_GET_PARAMETER bw_example_fx_balance_get_parameter
#endif

View File

@ -0,0 +1,6 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
NAME := bw_example_fx_balance
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_balance.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|Spatial"
#define PLUGIN_GUID_1 0xffe1e17f
#define PLUGIN_GUID_2 0x3c4b492c
#define PLUGIN_GUID_3 0x8d882912
#define PLUGIN_GUID_4 0xf93c1e95
#define CTRL_GUID_1 0x68133a09
#define CTRL_GUID_2 0xd70b4a46
#define CTRL_GUID_3 0x81f2808f
#define CTRL_GUID_4 0x9790b266
#endif

View File

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

View File

@ -0,0 +1,48 @@
/*
* 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: true,
output: true
}
];
var parameters = [
{
name: "Balance",
output: false,
defaultValue: 0.5
},
{
name: "Left level",
output: true,
defaultValue: 0.0
},
{
name: "Right level",
output: true,
defaultValue: 0.0
}
];

View File

@ -21,15 +21,24 @@
#ifndef _CONFIG_DAISY_SEED_H
#define _CONFIG_DAISY_SEED_H
struct config_pin {
int param_index;
int pin;
struct config_cc {
int param_index;
unsigned char cc;
};
#define NUM_PINS 1
#define NUM_CCS 10
static struct config_pin config_pins[NUM_PINS] = {
{ 0, 15 }
static struct config_cc config_ccs[NUM_CCS] = {
{ 0, 20 },
{ 1, 21 },
{ 2, 22 },
{ 3, 23 },
{ 4, 24 },
{ 5, 25 },
{ 6, 26 },
{ 7, 27 },
{ 8, 52 },
{ 9, 53 }
};
#endif

View File

@ -29,16 +29,16 @@ struct config_cc {
#define NUM_CCS 10
static struct config_cc config_ccs[NUM_CCS] = {
{ 0, 32 },
{ 1, 33 },
{ 2, 34 },
{ 3, 35 },
{ 4, 36 },
{ 5, 37 },
{ 6, 38 },
{ 7, 39 },
{ 8, 40 },
{ 9, 41 }
{ 0, 20 },
{ 1, 21 },
{ 2, 22 },
{ 3, 23 },
{ 4, 24 },
{ 5, 25 },
{ 6, 26 },
{ 7, 27 },
{ 8, 52 },
{ 9, 53 }
};
#endif

View File

@ -84,7 +84,7 @@ static inline void bw_balance_update_coeffs_audio(bw_balance_coeffs *BW_RESTRICT
*
* #### bw_balance_process1()
* ```>>> */
static inline float bw_balance_process1(const bw_balance_coeffs *BW_RESTRICT coeffs, float x_l, float x_r, float *BW_RESTRICT y_l, float *BW_RESTRICT y_r);
static inline void bw_balance_process1(const bw_balance_coeffs *BW_RESTRICT coeffs, float x_l, float x_r, float *BW_RESTRICT y_l, float *BW_RESTRICT y_r);
/*! <<<```
* Processes one set of input samples `x_l` (left) and `x_r` (right) using
* `coeffs`, while using and updating `state`. The left and right output
@ -138,7 +138,7 @@ static inline void bw_balance_set_sample_rate(bw_balance_coeffs *BW_RESTRICT coe
bw_gain_set_sample_rate(&coeffs->r_coeffs, sample_rate);
}
static inline void _bw_balance_do_update_coeffs(bw_gain_coeffs *BW_RESTRICT coeffs, char force) {
static inline void _bw_balance_do_update_coeffs(bw_balance_coeffs *BW_RESTRICT coeffs, char force) {
if (force || coeffs->balance != coeffs->balance_prev) {
bw_gain_set_gain_lin(&coeffs->l_coeffs, bw_minf(1.f - coeffs->balance, 1.f));
bw_gain_set_gain_lin(&coeffs->r_coeffs, bw_minf(1.f + coeffs->balance, 1.f));
@ -163,7 +163,7 @@ static inline void bw_balance_update_coeffs_audio(bw_balance_coeffs *BW_RESTRICT
bw_gain_update_coeffs_audio(&coeffs->r_coeffs);
}
static inline float bw_balance_process1(const bw_balance_coeffs *BW_RESTRICT coeffs, float x_l, float x_r, float *BW_RESTRICT y_l, float *BW_RESTRICT y_r) {
static inline void bw_balance_process1(const bw_balance_coeffs *BW_RESTRICT coeffs, float x_l, float x_r, float *BW_RESTRICT y_l, float *BW_RESTRICT y_r) {
*y_l = bw_gain_process1(&coeffs->l_coeffs, x_l);
*y_r = bw_gain_process1(&coeffs->r_coeffs, x_r);
}
@ -174,13 +174,13 @@ static inline void bw_balance_process(bw_balance_coeffs *BW_RESTRICT coeffs, con
if (y_r != NULL) {
for (int i = 0; i < n_samples; i++) {
bw_balance_update_coeffs_audio(coeffs);
bw_balance_process1(coeffs, state, x_l[i], x_r[i], y_l + i, y_r + i);
bw_balance_process1(coeffs, x_l[i], x_r[i], y_l + i, y_r + i);
}
} else {
for (int i = 0; i < n_samples; i++) {
bw_balance_update_coeffs_audio(coeffs);
float r;
bw_balance_process1(coeffs, state, x_l[i], x_r[i], y_l + i, &r);
bw_balance_process1(coeffs, x_l[i], x_r[i], y_l + i, &r);
}
}
} else {
@ -188,13 +188,13 @@ static inline void bw_balance_process(bw_balance_coeffs *BW_RESTRICT coeffs, con
for (int i = 0; i < n_samples; i++) {
bw_balance_update_coeffs_audio(coeffs);
float l;
bw_balance_process1(coeffs, state, x_l[i], x_r[i], &l, y_r + i);
bw_balance_process1(coeffs, x_l[i], x_r[i], &l, y_r + i);
}
} else {
for (int i = 0; i < n_samples; i++) {
bw_balance_update_coeffs_audio(coeffs);
float l, r;
bw_balance_process1(coeffs, state, x_l[i], x_r[i], &l, &r);
bw_balance_process1(coeffs, x_l[i], x_r[i], &l, &r);
}
}
}