fx(pp)_satur + fixed bw_satur_process_multi gain compensation
This commit is contained in:
parent
c9c425e30e
commit
3dcfeaf9fa
@ -1,6 +0,0 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
NAME := bw_example_fx_satur
|
||||
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_satur.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/android/android.mk
|
@ -1,7 +0,0 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
TARGET = bw_example_fx_satur
|
||||
|
||||
C_SOURCES += ${ROOT_DIR}/../src/bw_example_fx_satur.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/daisy-seed/daisy-seed.mk
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* 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
|
@ -1,6 +0,0 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
NAME := bw_example_fx_satur
|
||||
SOURCE := ${NAME}.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/ios/ios.mk
|
5
examples/fx_satur/src/android.json
Normal file
5
examples/fx_satur/src/android.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"android": {
|
||||
"javaPackageName": "com.orastron.bw_example_fx_satur"
|
||||
}
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 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_satur.h"
|
||||
|
||||
void bw_example_fx_satur_init(bw_example_fx_satur *instance) {
|
||||
bw_satur_init(&instance->satur_coeffs);
|
||||
bw_src_int_init(&instance->src_up_coeffs, 2);
|
||||
bw_src_int_init(&instance->src_down_coeffs, -2);
|
||||
bw_satur_set_gain_compensation(&instance->satur_coeffs, 1);
|
||||
}
|
||||
|
||||
void bw_example_fx_satur_set_sample_rate(bw_example_fx_satur *instance, float sample_rate) {
|
||||
bw_satur_set_sample_rate(&instance->satur_coeffs, 2.f * sample_rate);
|
||||
}
|
||||
|
||||
void bw_example_fx_satur_reset(bw_example_fx_satur *instance) {
|
||||
bw_satur_reset_coeffs(&instance->satur_coeffs);
|
||||
bw_satur_reset_state(&instance->satur_coeffs, &instance->satur_state, 0.f);
|
||||
bw_src_int_reset_state(&instance->src_up_coeffs, &instance->src_up_state, 0.f);
|
||||
bw_src_int_reset_state(&instance->src_down_coeffs, &instance->src_down_state, 0.f);
|
||||
}
|
||||
|
||||
void bw_example_fx_satur_process(bw_example_fx_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);
|
||||
bw_src_int_process(&instance->src_up_coeffs, &instance->src_up_state, x[0] + i, instance->buf, n);
|
||||
bw_satur_process(&instance->satur_coeffs, &instance->satur_state, instance->buf, instance->buf, n << 1);
|
||||
bw_src_int_process(&instance->src_down_coeffs, &instance->src_down_state, instance->buf, y[0] + i, n << 1);
|
||||
i += n;
|
||||
}
|
||||
}
|
||||
|
||||
void bw_example_fx_satur_set_parameter(bw_example_fx_satur *instance, int index, float value) {
|
||||
instance->params[index] = value;
|
||||
switch (index) {
|
||||
case p_bias:
|
||||
bw_satur_set_bias(&instance->satur_coeffs, 5.f * value - 2.5f);
|
||||
break;
|
||||
case p_gain:
|
||||
bw_satur_set_gain(&instance->satur_coeffs, 0.1f + (10.f - 0.1f) * value * value * value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float bw_example_fx_satur_get_parameter(bw_example_fx_satur *instance, int index) {
|
||||
return instance->params[index];
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 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_SATUR_H
|
||||
#define _BW_EXAMPLE_FX_SATUR_H
|
||||
|
||||
#include "platform.h"
|
||||
|
||||
#include <bw_satur.h>
|
||||
#include <bw_src_int.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
enum {
|
||||
p_bias,
|
||||
p_gain,
|
||||
p_n
|
||||
};
|
||||
|
||||
#define BUF_SIZE 32
|
||||
|
||||
struct _bw_example_fx_satur {
|
||||
// Sub-components
|
||||
bw_satur_coeffs satur_coeffs;
|
||||
bw_satur_state satur_state;
|
||||
bw_src_int_coeffs src_up_coeffs;
|
||||
bw_src_int_state src_up_state;
|
||||
bw_src_int_coeffs src_down_coeffs;
|
||||
bw_src_int_state src_down_state;
|
||||
|
||||
// Parameters
|
||||
float params[p_n];
|
||||
|
||||
// Buffers
|
||||
float buf[BUF_SIZE];
|
||||
};
|
||||
typedef struct _bw_example_fx_satur bw_example_fx_satur;
|
||||
|
||||
void bw_example_fx_satur_init(bw_example_fx_satur *instance);
|
||||
void bw_example_fx_satur_set_sample_rate(bw_example_fx_satur *instance, float sample_rate);
|
||||
void bw_example_fx_satur_reset(bw_example_fx_satur *instance);
|
||||
void bw_example_fx_satur_process(bw_example_fx_satur *instance, const float** x, float** y, int n_samples);
|
||||
void bw_example_fx_satur_set_parameter(bw_example_fx_satur *instance, int index, float value);
|
||||
float bw_example_fx_satur_get_parameter(bw_example_fx_satur *instance, int index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
6
examples/fx_satur/src/cmd.json
Normal file
6
examples/fx_satur/src/cmd.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cmd": {
|
||||
"busIds": [ "input", "output" ],
|
||||
"parameterIds": [ "gain", "bias" ]
|
||||
}
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022, 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_satur"
|
||||
#define PLUGIN_VERSION "1.0.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_fx_satur.h"
|
||||
|
||||
#define P_TYPE bw_example_fx_satur
|
||||
#define P_INIT bw_example_fx_satur_init
|
||||
#define P_SET_SAMPLE_RATE bw_example_fx_satur_set_sample_rate
|
||||
#define P_RESET bw_example_fx_satur_reset
|
||||
#define P_PROCESS bw_example_fx_satur_process
|
||||
#define P_SET_PARAMETER bw_example_fx_satur_set_parameter
|
||||
#define P_GET_PARAMETER bw_example_fx_satur_get_parameter
|
||||
|
||||
#endif
|
@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022 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: "Bias",
|
||||
output: false,
|
||||
defaultValue: 0.5
|
||||
},
|
||||
{
|
||||
name: "Gain",
|
||||
output: false,
|
||||
defaultValue: 0.4641588833612779
|
||||
}
|
||||
];
|
5
examples/fx_satur/src/daisy-seed.json
Normal file
5
examples/fx_satur/src/daisy-seed.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"daisy_seed": {
|
||||
"parameterPins": [ 15, 16 ]
|
||||
}
|
||||
}
|
5
examples/fx_satur/src/ios.json
Normal file
5
examples/fx_satur/src/ios.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"ios": {
|
||||
"productBundleIdentifier": "com.orastron.bw_example_fx_satur"
|
||||
}
|
||||
}
|
12
examples/fx_satur/src/lv2.json
Normal file
12
examples/fx_satur/src/lv2.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"lv2": {
|
||||
"prefixes": {
|
||||
"bw_examples": "https://www.orastron.com/brickworks/examples/"
|
||||
},
|
||||
"uri": "@bw_examples:fx_satur",
|
||||
"types": [ "@lv2:WaveshaperPlugin" ],
|
||||
"version": "1.0",
|
||||
"busSymbols": [ "input", "output" ],
|
||||
"parameterSymbols": [ "gain", "bias" ]
|
||||
}
|
||||
}
|
76
examples/fx_satur/src/plugin.h
Normal file
76
examples/fx_satur/src/plugin.h
Normal file
@ -0,0 +1,76 @@
|
||||
#include "common.h"
|
||||
#include <bw_satur.h>
|
||||
#include <bw_src_int.h>
|
||||
|
||||
#define BUF_SIZE 32
|
||||
|
||||
typedef struct plugin {
|
||||
bw_satur_coeffs satur_coeffs;
|
||||
bw_satur_state satur_state;
|
||||
bw_src_int_coeffs src_up_coeffs;
|
||||
bw_src_int_state src_up_state;
|
||||
bw_src_int_coeffs src_down_coeffs;
|
||||
bw_src_int_state src_down_state;
|
||||
|
||||
float buf[BUF_SIZE];
|
||||
} plugin;
|
||||
|
||||
static void plugin_init(plugin *instance) {
|
||||
bw_satur_init(&instance->satur_coeffs);
|
||||
bw_src_int_init(&instance->src_up_coeffs, 2);
|
||||
bw_src_int_init(&instance->src_down_coeffs, -2);
|
||||
bw_satur_set_gain_compensation(&instance->satur_coeffs, 1);
|
||||
}
|
||||
|
||||
static void plugin_fini(plugin *instance) {
|
||||
(void)instance;
|
||||
}
|
||||
|
||||
static void plugin_set_sample_rate(plugin *instance, float sample_rate) {
|
||||
bw_satur_set_sample_rate(&instance->satur_coeffs, 2.f * sample_rate);
|
||||
}
|
||||
|
||||
static size_t plugin_mem_req(plugin *instance) {
|
||||
(void)instance;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void plugin_mem_set(plugin *instance, void *mem) {
|
||||
(void)instance;
|
||||
(void)mem;
|
||||
}
|
||||
|
||||
static void plugin_reset(plugin *instance) {
|
||||
bw_satur_reset_coeffs(&instance->satur_coeffs);
|
||||
bw_satur_reset_state(&instance->satur_coeffs, &instance->satur_state, 0.f);
|
||||
bw_src_int_reset_state(&instance->src_up_coeffs, &instance->src_up_state, 0.f);
|
||||
bw_src_int_reset_state(&instance->src_down_coeffs, &instance->src_down_state, 0.f);
|
||||
}
|
||||
|
||||
static void plugin_set_parameter(plugin *instance, size_t index, float value) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
bw_satur_set_gain(&instance->satur_coeffs, value);
|
||||
break;
|
||||
case 1:
|
||||
bw_satur_set_bias(&instance->satur_coeffs, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static float plugin_get_parameter(plugin *instance, size_t index) {
|
||||
(void)instance;
|
||||
(void)index;
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
static void plugin_process(plugin *instance, const float **inputs, float **outputs, size_t n_samples) {
|
||||
size_t i = 0;
|
||||
while (i < n_samples) {
|
||||
int n = bw_mini32(n_samples - i, BUF_SIZE >> 1);
|
||||
bw_src_int_process(&instance->src_up_coeffs, &instance->src_up_state, inputs[0] + i, instance->buf, n);
|
||||
bw_satur_process(&instance->satur_coeffs, &instance->satur_state, instance->buf, instance->buf, n << 1);
|
||||
bw_src_int_process(&instance->src_down_coeffs, &instance->src_down_state, instance->buf, outputs[0] + i, n << 1);
|
||||
i += n;
|
||||
}
|
||||
}
|
44
examples/fx_satur/src/product.json
Normal file
44
examples/fx_satur/src/product.json
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"product": {
|
||||
"name": "Brickworks saturation example",
|
||||
"version": "1.1.0",
|
||||
"buildVersion": "1",
|
||||
"bundleName": "bw_example_fx_satur",
|
||||
"buses": [
|
||||
{
|
||||
"type": "audio",
|
||||
"direction": "input",
|
||||
"channels": "mono",
|
||||
"name": "Input",
|
||||
"shortName": "Input"
|
||||
},
|
||||
{
|
||||
"type": "audio",
|
||||
"direction": "output",
|
||||
"channels": "mono",
|
||||
"name": "Output",
|
||||
"shortName": "Output"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Gain",
|
||||
"shortName": "Gain",
|
||||
"direction": "input",
|
||||
"defaultValue": 1.0,
|
||||
"minimum": 0.1,
|
||||
"maximum": 10.0,
|
||||
"map": "linear"
|
||||
},
|
||||
{
|
||||
"name": "Bias",
|
||||
"shortName": "Bias",
|
||||
"direction": "input",
|
||||
"defaultValue": 0.0,
|
||||
"minimum": -2.5,
|
||||
"maximum": 2.5,
|
||||
"map": "linear"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
11
examples/fx_satur/src/vst3.json
Normal file
11
examples/fx_satur/src/vst3.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"vst3": {
|
||||
"plugin": {
|
||||
"cid": "b03fc08061c64519b13bbe2c777b1015"
|
||||
},
|
||||
"controller": {
|
||||
"cid": "682d9ded1c1447a8b031a2a2844bf5dd"
|
||||
},
|
||||
"subCategory": "Fx|Distortion"
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
NAME := bw_example_fx_satur
|
||||
SOURCE := bw_example_fx_satur.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/vst3/vst3.mk
|
||||
|
||||
CXXFLAGS += -DRELEASE=1 -DNDEBUG -DBW_NO_DEBUG
|
||||
#CXXFLAGS += -DDEVELOPMENT=1 -DBW_DEBUG_DEEP
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Brickworks
|
||||
*
|
||||
* Copyright (C) 2022 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 0xb03fc080
|
||||
#define PLUGIN_GUID_2 0x61c64519
|
||||
#define PLUGIN_GUID_3 0xb13bbe2c
|
||||
#define PLUGIN_GUID_4 0x777b1015
|
||||
|
||||
#define CTRL_GUID_1 0x682d9ded
|
||||
#define CTRL_GUID_2 0x1c1447a8
|
||||
#define CTRL_GUID_3 0xb031a2a2
|
||||
#define CTRL_GUID_4 0x844bf5dd
|
||||
|
||||
#endif
|
@ -1,4 +0,0 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_satur.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/web/web.mk
|
5
examples/fxpp_satur/src/android.json
Normal file
5
examples/fxpp_satur/src/android.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"android": {
|
||||
"javaPackageName": "com.orastron.bw_example_fxpp_satur"
|
||||
}
|
||||
}
|
6
examples/fxpp_satur/src/cmd.json
Normal file
6
examples/fxpp_satur/src/cmd.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"cmd": {
|
||||
"busIds": [ "input", "output" ],
|
||||
"parameterIds": [ "gain", "bias" ]
|
||||
}
|
||||
}
|
5
examples/fxpp_satur/src/daisy-seed.json
Normal file
5
examples/fxpp_satur/src/daisy-seed.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"daisy_seed": {
|
||||
"parameterPins": [ 15, 16 ]
|
||||
}
|
||||
}
|
86
examples/fxpp_satur/src/impl.cpp
Normal file
86
examples/fxpp_satur/src/impl.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
#include "impl.h"
|
||||
|
||||
#include "common.h"
|
||||
#include <bw_satur.h>
|
||||
#include <bw_src_int.h>
|
||||
|
||||
using namespace Brickworks;
|
||||
|
||||
#define BUF_SIZE 32
|
||||
|
||||
class Engine {
|
||||
public:
|
||||
Engine() : srcUp(2), srcDown(-2) {}
|
||||
|
||||
Satur<1> satur;
|
||||
SRCInt<1> srcUp;
|
||||
SRCInt<1> srcDown;
|
||||
|
||||
float buf[BUF_SIZE];
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
||||
impl impl_new(void) {
|
||||
Engine *instance = new Engine();
|
||||
instance->satur.setGainCompensation(true);
|
||||
return reinterpret_cast<impl>(instance);
|
||||
}
|
||||
|
||||
void impl_free(impl handle) {
|
||||
Engine *instance = reinterpret_cast<Engine *>(handle);
|
||||
delete instance;
|
||||
}
|
||||
|
||||
void impl_set_sample_rate(impl handle, float sample_rate) {
|
||||
Engine *instance = reinterpret_cast<Engine *>(handle);
|
||||
instance->satur.setSampleRate(2.f * sample_rate);
|
||||
}
|
||||
|
||||
void impl_reset(impl handle) {
|
||||
Engine *instance = reinterpret_cast<Engine *>(handle);
|
||||
instance->satur.reset();
|
||||
instance->srcUp.reset();
|
||||
instance->srcDown.reset();
|
||||
}
|
||||
|
||||
void impl_set_parameter(impl handle, size_t index, float value) {
|
||||
Engine *instance = reinterpret_cast<Engine *>(handle);
|
||||
switch (index) {
|
||||
case 0:
|
||||
instance->satur.setGain(value);
|
||||
break;
|
||||
case 1:
|
||||
instance->satur.setBias(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float impl_get_parameter(impl handle, size_t index) {
|
||||
(void)handle;
|
||||
(void)index;
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
void impl_process(impl handle, const float **inputs, float **outputs, size_t n_samples) {
|
||||
Engine *instance = reinterpret_cast<Engine *>(handle);
|
||||
size_t i = 0;
|
||||
while (i < n_samples) {
|
||||
int n = bw_mini32(n_samples - i, BUF_SIZE >> 1);
|
||||
#ifdef WASM
|
||||
const float *x[1] = {inputs[0] + i};
|
||||
float *y[1] = {outputs[0] + i};
|
||||
float *b[1] = {instance->buf};
|
||||
instance->srcUp.process(x, b, n);
|
||||
instance->satur.process(b, b, n << 1);
|
||||
instance->srcDown.process(b, y, n << 1);
|
||||
#else
|
||||
instance->srcUp.process({inputs[0] + i}, {instance->buf}, n);
|
||||
instance->satur.process({instance->buf}, {instance->buf}, n << 1);
|
||||
instance->srcDown.process({instance->buf}, {outputs[0] + i}, n << 1);
|
||||
#endif
|
||||
i += n;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
5
examples/fxpp_satur/src/ios.json
Normal file
5
examples/fxpp_satur/src/ios.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"ios": {
|
||||
"productBundleIdentifier": "com.orastron.bw_example_fxpp_satur"
|
||||
}
|
||||
}
|
12
examples/fxpp_satur/src/lv2.json
Normal file
12
examples/fxpp_satur/src/lv2.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"lv2": {
|
||||
"prefixes": {
|
||||
"bw_examples": "https://www.orastron.com/brickworks/examples/"
|
||||
},
|
||||
"uri": "@bw_examples:fxpp_satur",
|
||||
"types": [ "@lv2:WaveshaperPlugin" ],
|
||||
"version": "1.0",
|
||||
"busSymbols": [ "input", "output" ],
|
||||
"parameterSymbols": [ "gain", "bias" ]
|
||||
}
|
||||
}
|
76
examples/fxpp_satur/src/plugin.h
Normal file
76
examples/fxpp_satur/src/plugin.h
Normal file
@ -0,0 +1,76 @@
|
||||
#include "common.h"
|
||||
#include <bw_satur.h>
|
||||
#include <bw_src_int.h>
|
||||
|
||||
#define BUF_SIZE 32
|
||||
|
||||
typedef struct plugin {
|
||||
bw_satur_coeffs satur_coeffs;
|
||||
bw_satur_state satur_state;
|
||||
bw_src_int_coeffs src_up_coeffs;
|
||||
bw_src_int_state src_up_state;
|
||||
bw_src_int_coeffs src_down_coeffs;
|
||||
bw_src_int_state src_down_state;
|
||||
|
||||
float buf[BUF_SIZE];
|
||||
} plugin;
|
||||
|
||||
static void plugin_init(plugin *instance) {
|
||||
bw_satur_init(&instance->satur_coeffs);
|
||||
bw_src_int_init(&instance->src_up_coeffs, 2);
|
||||
bw_src_int_init(&instance->src_down_coeffs, -2);
|
||||
bw_satur_set_gain_compensation(&instance->satur_coeffs, 1);
|
||||
}
|
||||
|
||||
static void plugin_fini(plugin *instance) {
|
||||
(void)instance;
|
||||
}
|
||||
|
||||
static void plugin_set_sample_rate(plugin *instance, float sample_rate) {
|
||||
bw_satur_set_sample_rate(&instance->satur_coeffs, 2.f * sample_rate);
|
||||
}
|
||||
|
||||
static size_t plugin_mem_req(plugin *instance) {
|
||||
(void)instance;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void plugin_mem_set(plugin *instance, void *mem) {
|
||||
(void)instance;
|
||||
(void)mem;
|
||||
}
|
||||
|
||||
static void plugin_reset(plugin *instance) {
|
||||
bw_satur_reset_coeffs(&instance->satur_coeffs);
|
||||
bw_satur_reset_state(&instance->satur_coeffs, &instance->satur_state, 0.f);
|
||||
bw_src_int_reset_state(&instance->src_up_coeffs, &instance->src_up_state, 0.f);
|
||||
bw_src_int_reset_state(&instance->src_down_coeffs, &instance->src_down_state, 0.f);
|
||||
}
|
||||
|
||||
static void plugin_set_parameter(plugin *instance, size_t index, float value) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
bw_satur_set_gain(&instance->satur_coeffs, value);
|
||||
break;
|
||||
case 1:
|
||||
bw_satur_set_bias(&instance->satur_coeffs, value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static float plugin_get_parameter(plugin *instance, size_t index) {
|
||||
(void)instance;
|
||||
(void)index;
|
||||
return 0.f;
|
||||
}
|
||||
|
||||
static void plugin_process(plugin *instance, const float **inputs, float **outputs, size_t n_samples) {
|
||||
size_t i = 0;
|
||||
while (i < n_samples) {
|
||||
int n = bw_mini32(n_samples - i, BUF_SIZE >> 1);
|
||||
bw_src_int_process(&instance->src_up_coeffs, &instance->src_up_state, inputs[0] + i, instance->buf, n);
|
||||
bw_satur_process(&instance->satur_coeffs, &instance->satur_state, instance->buf, instance->buf, n << 1);
|
||||
bw_src_int_process(&instance->src_down_coeffs, &instance->src_down_state, instance->buf, outputs[0] + i, n << 1);
|
||||
i += n;
|
||||
}
|
||||
}
|
44
examples/fxpp_satur/src/product.json
Normal file
44
examples/fxpp_satur/src/product.json
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"product": {
|
||||
"name": "Brickworks saturation example (C++)",
|
||||
"version": "1.1.0",
|
||||
"buildVersion": "1",
|
||||
"bundleName": "bw_example_fxpp_satur",
|
||||
"buses": [
|
||||
{
|
||||
"type": "audio",
|
||||
"direction": "input",
|
||||
"channels": "mono",
|
||||
"name": "Input",
|
||||
"shortName": "Input"
|
||||
},
|
||||
{
|
||||
"type": "audio",
|
||||
"direction": "output",
|
||||
"channels": "mono",
|
||||
"name": "Output",
|
||||
"shortName": "Output"
|
||||
}
|
||||
],
|
||||
"parameters": [
|
||||
{
|
||||
"name": "Gain",
|
||||
"shortName": "Gain",
|
||||
"direction": "input",
|
||||
"defaultValue": 1.0,
|
||||
"minimum": 0.1,
|
||||
"maximum": 10.0,
|
||||
"map": "linear"
|
||||
},
|
||||
{
|
||||
"name": "Bias",
|
||||
"shortName": "Bias",
|
||||
"direction": "input",
|
||||
"defaultValue": 0.0,
|
||||
"minimum": -2.5,
|
||||
"maximum": 2.5,
|
||||
"map": "linear"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
11
examples/fxpp_satur/src/vst3.json
Normal file
11
examples/fxpp_satur/src/vst3.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"vst3": {
|
||||
"plugin": {
|
||||
"cid": "f7465fb88d284b9d842007fec0301b51"
|
||||
},
|
||||
"controller": {
|
||||
"cid": "ab9d28b92cbe44f0bbf42db08c0e30ed"
|
||||
},
|
||||
"subCategory": "Fx|Distortion"
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ echo Removing common files
|
||||
|
||||
rm -fr common/cmd common/web common/daisy-seed common/lv2 common/vst3 common/android common/ios
|
||||
|
||||
dirs="fx_ap1 fx_ap2 fx_balance fx_bitcrush fx_cab fx_chorus fx_clip fx_comb fx_comp fx_delay fx_dist fx_drive fx_eq_3band fx_flanger fx_fuzz fx_hp1 fx_hs1 fx_lp1 fx_ls1 fx_mm1 fx_mm2 fx_noise_gate fx_notch fx_one_pole fx_pan fx_phaser fx_reverb fx_ring_mod synth_simple fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_chorus fxpp_clip fxpp_comb fxpp_comp fxpp_delay fxpp_dist fxpp_drive fxpp_eq_3band fxpp_flanger fxpp_fuzz fxpp_hp1 fxpp_hs1 fxpp_lp1 fxpp_ls1 fxpp_mm1 fxpp_mm2 fxpp_noise_gate fxpp_notch fxpp_one_pole fxpp_pan fxpp_phaser fxpp_reverb fxpp_ring_mod synthpp_simple"
|
||||
dirs="fx_ap1 fx_ap2 fx_balance fx_bitcrush fx_cab fx_chorus fx_clip fx_comb fx_comp fx_delay fx_dist fx_drive fx_eq_3band fx_flanger fx_fuzz fx_hp1 fx_hs1 fx_lp1 fx_ls1 fx_mm1 fx_mm2 fx_noise_gate fx_notch fx_one_pole fx_pan fx_phaser fx_reverb fx_ring_mod fx_satur synth_simple fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_chorus fxpp_clip fxpp_comb fxpp_comp fxpp_delay fxpp_dist fxpp_drive fxpp_eq_3band fxpp_flanger fxpp_fuzz fxpp_hp1 fxpp_hs1 fxpp_lp1 fxpp_ls1 fxpp_mm1 fxpp_mm2 fxpp_noise_gate fxpp_notch fxpp_one_pole fxpp_pan fxpp_phaser fxpp_reverb fxpp_ring_mod fxpp_satur synthpp_simple"
|
||||
|
||||
for d in $dirs; do
|
||||
echo Removing data files for $d
|
||||
|
@ -33,7 +33,7 @@ if [ "$1" = "common" ]; then
|
||||
fi
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
dirs="fx_ap1 fx_ap2 fx_balance fx_bitcrush fx_cab fx_chorus fx_clip fx_comb fx_comp fx_delay fx_dist fx_drive fx_eq_3band fx_flanger fx_fuzz fx_hp1 fx_hs1 fx_lp1 fx_ls1 fx_mm1 fx_mm2 fx_noise_gate fx_notch fx_one_pole fx_pan fx_phaser fx_reverb fx_ring_mod synth_simple fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_chorus fxpp_clip fxpp_comb fxpp_comp fxpp_delay fxpp_dist fxpp_drive fxpp_eq_3band fxpp_flanger fxpp_fuzz fxpp_hp1 fxpp_hs1 fxpp_lp1 fxpp_ls1 fxpp_mm1 fxpp_mm2 fxpp_noise_gate fxpp_notch fxpp_one_pole fxpp_pan fxpp_phaser fxpp_reverb fxpp_ring_mod synthpp_simple"
|
||||
dirs="fx_ap1 fx_ap2 fx_balance fx_bitcrush fx_cab fx_chorus fx_clip fx_comb fx_comp fx_delay fx_dist fx_drive fx_eq_3band fx_flanger fx_fuzz fx_hp1 fx_hs1 fx_lp1 fx_ls1 fx_mm1 fx_mm2 fx_noise_gate fx_notch fx_one_pole fx_pan fx_phaser fx_reverb fx_ring_mod fx_satur synth_simple fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_chorus fxpp_clip fxpp_comb fxpp_comp fxpp_delay fxpp_dist fxpp_drive fxpp_eq_3band fxpp_flanger fxpp_fuzz fxpp_hp1 fxpp_hs1 fxpp_lp1 fxpp_ls1 fxpp_mm1 fxpp_mm2 fxpp_noise_gate fxpp_notch fxpp_one_pole fxpp_pan fxpp_phaser fxpp_reverb fxpp_ring_mod fxpp_satur synthpp_simple"
|
||||
else
|
||||
dirs="$1"
|
||||
fi
|
||||
|
@ -47,6 +47,7 @@
|
||||
* <ul>
|
||||
* <li>Version <strong>1.1.0</strong>:
|
||||
* <ul>
|
||||
* <li>Fixed gain compensation in <code>bw_satur_process_multi().</li>
|
||||
* <li>Now using <code>BW_NULL</code> and
|
||||
* <code>BW_CXX_NO_ARRAY</code>.</li>
|
||||
* </ul>
|
||||
@ -623,11 +624,18 @@ static inline void bw_satur_process_multi(
|
||||
#endif
|
||||
|
||||
bw_satur_update_coeffs_ctrl(coeffs);
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
bw_satur_update_coeffs_audio(coeffs);
|
||||
for (size_t j = 0; j < n_channels; j++)
|
||||
y[j][i] = bw_satur_process1(coeffs, state[j], x[j][i]);
|
||||
}
|
||||
if (coeffs->gain_compensation)
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
bw_satur_update_coeffs_audio(coeffs);
|
||||
for (size_t j = 0; j < n_channels; j++)
|
||||
y[j][i] = bw_satur_process1_comp(coeffs, state[j], x[j][i]);
|
||||
}
|
||||
else
|
||||
for (size_t i = 0; i < n_samples; i++) {
|
||||
bw_satur_update_coeffs_audio(coeffs);
|
||||
for (size_t j = 0; j < n_channels; j++)
|
||||
y[j][i] = bw_satur_process1(coeffs, state[j], x[j][i]);
|
||||
}
|
||||
|
||||
BW_ASSERT_DEEP(bw_satur_coeffs_is_valid(coeffs));
|
||||
BW_ASSERT_DEEP(coeffs->state >= bw_satur_coeffs_state_reset_coeffs);
|
||||
|
Loading…
Reference in New Issue
Block a user