diff --git a/examples/fx_dist/android/Makefile b/examples/fx_dist/android/Makefile
deleted file mode 100644
index a9508b2..0000000
--- a/examples/fx_dist/android/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
-
-NAME := bw_example_fx_dist
-SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_dist.c
-
-include ${ROOT_DIR}/../../common/android/android.mk
diff --git a/examples/fx_dist/daisy-seed/Makefile b/examples/fx_dist/daisy-seed/Makefile
deleted file mode 100644
index d01034f..0000000
--- a/examples/fx_dist/daisy-seed/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
-
-TARGET = bw_example_fx_dist
-
-C_SOURCES += ${ROOT_DIR}/../src/bw_example_fx_dist.c
-
-include ${ROOT_DIR}/../../common/daisy-seed/daisy-seed.mk
diff --git a/examples/fx_dist/daisy-seed/config_daisy_seed.h b/examples/fx_dist/daisy-seed/config_daisy_seed.h
deleted file mode 100644
index 8aa4923..0000000
--- a/examples/fx_dist/daisy-seed/config_daisy_seed.h
+++ /dev/null
@@ -1,37 +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 .
- *
- * 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
diff --git a/examples/fx_dist/ios/Makefile b/examples/fx_dist/ios/Makefile
deleted file mode 100644
index a19583f..0000000
--- a/examples/fx_dist/ios/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
-
-NAME := bw_example_fx_dist
-SOURCE := ${NAME}.c
-
-include ${ROOT_DIR}/../../common/ios/ios.mk
diff --git a/examples/fx_dist/src/android.json b/examples/fx_dist/src/android.json
new file mode 100644
index 0000000..3fa0e3c
--- /dev/null
+++ b/examples/fx_dist/src/android.json
@@ -0,0 +1,5 @@
+{
+ "android": {
+ "javaPackageName": "com.orastron.bw_example_fx_dist"
+ }
+}
diff --git a/examples/fx_dist/src/bw_example_fx_dist.c b/examples/fx_dist/src/bw_example_fx_dist.c
deleted file mode 100644
index e6be37c..0000000
--- a/examples/fx_dist/src/bw_example_fx_dist.c
+++ /dev/null
@@ -1,68 +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 .
- *
- * File author: Stefano D'Angelo
- */
-
-#include "bw_example_fx_dist.h"
-
-void bw_example_fx_dist_init(bw_example_fx_dist *instance) {
- bw_dist_init(&instance->dist_coeffs);
- bw_src_int_init(&instance->src_up_coeffs, 2);
- bw_src_int_init(&instance->src_down_coeffs, -2);
-}
-
-void bw_example_fx_dist_set_sample_rate(bw_example_fx_dist *instance, float sample_rate) {
- bw_dist_set_sample_rate(&instance->dist_coeffs, 2.f * sample_rate);
-}
-
-void bw_example_fx_dist_reset(bw_example_fx_dist *instance) {
- bw_dist_reset_coeffs(&instance->dist_coeffs);
- bw_dist_reset_state(&instance->dist_coeffs, &instance->dist_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_dist_process(bw_example_fx_dist *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_dist_process(&instance->dist_coeffs, &instance->dist_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_dist_set_parameter(bw_example_fx_dist *instance, int index, float value) {
- instance->params[index] = value;
- switch (index) {
- case p_dist:
- bw_dist_set_distortion(&instance->dist_coeffs, value);
- break;
- case p_tone:
- bw_dist_set_tone(&instance->dist_coeffs, value);
- break;
- case p_volume:
- bw_dist_set_volume(&instance->dist_coeffs, value);
- break;
- }
-}
-
-float bw_example_fx_dist_get_parameter(bw_example_fx_dist *instance, int index) {
- return instance->params[index];
-}
diff --git a/examples/fx_dist/src/bw_example_fx_dist.h b/examples/fx_dist/src/bw_example_fx_dist.h
deleted file mode 100644
index 20cd312..0000000
--- a/examples/fx_dist/src/bw_example_fx_dist.h
+++ /dev/null
@@ -1,70 +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 .
- *
- * File author: Stefano D'Angelo
- */
-
-#ifndef _BW_EXAMPLE_FX_DIST_H
-#define _BW_EXAMPLE_FX_DIST_H
-
-#include "platform.h"
-
-#include
-#include
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-enum {
- p_dist,
- p_tone,
- p_volume,
- p_n
-};
-
-#define BUF_SIZE 32
-
-struct _bw_example_fx_dist {
- // Sub-components
- bw_dist_coeffs dist_coeffs;
- bw_dist_state dist_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_dist bw_example_fx_dist;
-
-void bw_example_fx_dist_init(bw_example_fx_dist *instance);
-void bw_example_fx_dist_set_sample_rate(bw_example_fx_dist *instance, float sample_rate);
-void bw_example_fx_dist_reset(bw_example_fx_dist *instance);
-void bw_example_fx_dist_process(bw_example_fx_dist *instance, const float** x, float** y, int n_samples);
-void bw_example_fx_dist_set_parameter(bw_example_fx_dist *instance, int index, float value);
-float bw_example_fx_dist_get_parameter(bw_example_fx_dist *instance, int index);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/examples/fx_dist/src/cmd.json b/examples/fx_dist/src/cmd.json
new file mode 100644
index 0000000..524cdd7
--- /dev/null
+++ b/examples/fx_dist/src/cmd.json
@@ -0,0 +1,6 @@
+{
+ "cmd": {
+ "busIds": [ "input", "output" ],
+ "parameterIds": [ "distortion", "tone", "volume" ]
+ }
+}
diff --git a/examples/fx_dist/src/config.h b/examples/fx_dist/src/config.h
deleted file mode 100644
index d87b827..0000000
--- a/examples/fx_dist/src/config.h
+++ /dev/null
@@ -1,89 +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 .
- *
- * 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_dist"
-#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 3
-
-static struct config_parameter config_parameters[NUM_PARAMETERS] = {
- { "Distortion", "Distortion", "", 0, 0, 0, 0.f },
- { "Tone", "Tone", "", 0, 0, 0, 0.5f },
- { "Volume", "Volume", "", 0, 0, 0, 1.f }
-};
-
-// Internal API
-
-#include "bw_example_fx_dist.h"
-
-#define P_TYPE bw_example_fx_dist
-#define P_INIT bw_example_fx_dist_init
-#define P_SET_SAMPLE_RATE bw_example_fx_dist_set_sample_rate
-#define P_RESET bw_example_fx_dist_reset
-#define P_PROCESS bw_example_fx_dist_process
-#define P_SET_PARAMETER bw_example_fx_dist_set_parameter
-#define P_GET_PARAMETER bw_example_fx_dist_get_parameter
-
-#endif
diff --git a/examples/fx_dist/src/config.js b/examples/fx_dist/src/config.js
deleted file mode 100644
index 03b8df5..0000000
--- a/examples/fx_dist/src/config.js
+++ /dev/null
@@ -1,48 +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 .
- *
- * File author: Stefano D'Angelo
- */
-
-var buses = [
- {
- stereo: false,
- output: false
- },
- {
- stereo: false,
- output: true
- }
-];
-
-var parameters = [
- {
- name: "Distortion",
- output: false,
- defaultValue: 0.0
- },
- {
- name: "Tone",
- output: false,
- defaultValue: 0.5
- },
- {
- name: "Volume",
- output: false,
- defaultValue: 1.0
- }
-];
diff --git a/examples/fx_dist/src/daisy-seed.json b/examples/fx_dist/src/daisy-seed.json
new file mode 100644
index 0000000..fd02e95
--- /dev/null
+++ b/examples/fx_dist/src/daisy-seed.json
@@ -0,0 +1,5 @@
+{
+ "daisy_seed": {
+ "parameterPins": [ 15, 16, 17 ]
+ }
+}
diff --git a/examples/fx_dist/src/ios.json b/examples/fx_dist/src/ios.json
new file mode 100644
index 0000000..72507a1
--- /dev/null
+++ b/examples/fx_dist/src/ios.json
@@ -0,0 +1,5 @@
+{
+ "ios": {
+ "productBundleIdentifier": "com.orastron.bw_example_fx_dist"
+ }
+}
diff --git a/examples/fx_dist/src/lv2.json b/examples/fx_dist/src/lv2.json
new file mode 100644
index 0000000..5985a63
--- /dev/null
+++ b/examples/fx_dist/src/lv2.json
@@ -0,0 +1,12 @@
+{
+ "lv2": {
+ "prefixes": {
+ "bw_examples": "https://www.orastron.com/brickworks/examples/"
+ },
+ "uri": "@bw_examples:fx_dist",
+ "types": [ "@lv2:DistortionPlugin" ],
+ "version": "1.0",
+ "busSymbols": [ "input", "output" ],
+ "parameterSymbols": [ "distortion", "tone", "volume" ]
+ }
+}
diff --git a/examples/fxpp_clip/src/plugin.h b/examples/fx_dist/src/plugin.h
similarity index 74%
rename from examples/fxpp_clip/src/plugin.h
rename to examples/fx_dist/src/plugin.h
index 3c3d7ef..0c42338 100644
--- a/examples/fxpp_clip/src/plugin.h
+++ b/examples/fx_dist/src/plugin.h
@@ -1,12 +1,12 @@
#include "common.h"
-#include
+#include
#include
#define BUF_SIZE 32
typedef struct plugin {
- bw_clip_coeffs clip_coeffs;
- bw_clip_state clip_state;
+ bw_dist_coeffs dist_coeffs;
+ bw_dist_state dist_state;
bw_src_int_coeffs src_up_coeffs;
bw_src_int_state src_up_state;
bw_src_int_coeffs src_down_coeffs;
@@ -16,10 +16,9 @@ typedef struct plugin {
} plugin;
static void plugin_init(plugin *instance) {
- bw_clip_init(&instance->clip_coeffs);
+ bw_dist_init(&instance->dist_coeffs);
bw_src_int_init(&instance->src_up_coeffs, 2);
bw_src_int_init(&instance->src_down_coeffs, -2);
- bw_clip_set_gain_compensation(&instance->clip_coeffs, 1);
}
static void plugin_fini(plugin *instance) {
@@ -27,7 +26,7 @@ static void plugin_fini(plugin *instance) {
}
static void plugin_set_sample_rate(plugin *instance, float sample_rate) {
- bw_clip_set_sample_rate(&instance->clip_coeffs, 2.f * sample_rate);
+ bw_dist_set_sample_rate(&instance->dist_coeffs, 2.f * sample_rate);
}
static size_t plugin_mem_req(plugin *instance) {
@@ -41,8 +40,8 @@ static void plugin_mem_set(plugin *instance, void *mem) {
}
static void plugin_reset(plugin *instance) {
- bw_clip_reset_coeffs(&instance->clip_coeffs);
- bw_clip_reset_state(&instance->clip_coeffs, &instance->clip_state, 0.f);
+ bw_dist_reset_coeffs(&instance->dist_coeffs);
+ bw_dist_reset_state(&instance->dist_coeffs, &instance->dist_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);
}
@@ -50,10 +49,13 @@ static void plugin_reset(plugin *instance) {
static void plugin_set_parameter(plugin *instance, size_t index, float value) {
switch (index) {
case 0:
- bw_clip_set_gain(&instance->clip_coeffs, value);
+ bw_dist_set_distortion(&instance->dist_coeffs, 0.01f * value);
break;
case 1:
- bw_clip_set_bias(&instance->clip_coeffs, value);
+ bw_dist_set_tone(&instance->dist_coeffs, 0.01f * value);
+ break;
+ case 2:
+ bw_dist_set_volume(&instance->dist_coeffs, 0.01f * value);
break;
}
}
@@ -69,7 +71,7 @@ static void plugin_process(plugin *instance, const float **inputs, float **outpu
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_clip_process(&instance->clip_coeffs, &instance->clip_state, instance->buf, instance->buf, n << 1);
+ bw_dist_process(&instance->dist_coeffs, &instance->dist_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;
}
diff --git a/examples/fx_dist/src/product.json b/examples/fx_dist/src/product.json
new file mode 100644
index 0000000..54e5abf
--- /dev/null
+++ b/examples/fx_dist/src/product.json
@@ -0,0 +1,56 @@
+{
+ "product": {
+ "name": "Brickworks distortion example",
+ "version": "1.1.0",
+ "buildVersion": "1",
+ "bundleName": "bw_example_fx_dist",
+ "buses": [
+ {
+ "type": "audio",
+ "direction": "input",
+ "channels": "mono",
+ "name": "Input",
+ "shortName": "Input"
+ },
+ {
+ "type": "audio",
+ "direction": "output",
+ "channels": "mono",
+ "name": "Output",
+ "shortName": "Output"
+ }
+ ],
+ "parameters": [
+ {
+ "name": "Distortion",
+ "shortName": "Distortion",
+ "direction": "input",
+ "defaultValue": 0.0,
+ "minimum": 0.0,
+ "maximum": 100.0,
+ "unit": "pc",
+ "map": "linear"
+ },
+ {
+ "name": "Tone",
+ "shortName": "Tone",
+ "direction": "input",
+ "defaultValue": 50.0,
+ "minimum": 0.0,
+ "maximum": 100.0,
+ "unit": "pc",
+ "map": "linear"
+ },
+ {
+ "name": "Volume",
+ "shortName": "Volume",
+ "direction": "input",
+ "defaultValue": 100.0,
+ "minimum": 0.0,
+ "maximum": 100.0,
+ "unit": "pc",
+ "map": "linear"
+ }
+ ]
+ }
+}
diff --git a/examples/fx_dist/src/vst3.json b/examples/fx_dist/src/vst3.json
new file mode 100644
index 0000000..4dd5146
--- /dev/null
+++ b/examples/fx_dist/src/vst3.json
@@ -0,0 +1,11 @@
+{
+ "vst3": {
+ "plugin": {
+ "cid": "bac1c7b44345410692c56a1f880800c7"
+ },
+ "controller": {
+ "cid": "d32efa43204a4ef4bb232ad71dfbaecd"
+ },
+ "subCategory": "Fx|Distortion"
+ }
+}
diff --git a/examples/fx_dist/vst3/Makefile b/examples/fx_dist/vst3/Makefile
deleted file mode 100644
index bb172ee..0000000
--- a/examples/fx_dist/vst3/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
-
-NAME := bw_example_fx_dist
-SOURCE := bw_example_fx_dist.c
-
-include ${ROOT_DIR}/../../common/vst3/vst3.mk
-
-CXXFLAGS += -DRELEASE=1 -DNDEBUG -DBW_NO_DEBUG
-#CXXFLAGS += -DDEVELOPMENT=1 -DBW_DEBUG_DEEP
diff --git a/examples/fx_dist/vst3/config_vst3.h b/examples/fx_dist/vst3/config_vst3.h
deleted file mode 100644
index deb9013..0000000
--- a/examples/fx_dist/vst3/config_vst3.h
+++ /dev/null
@@ -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 .
- *
- * File authors: Stefano D'Angelo, Paolo Marrone
- */
-
-#ifndef _VST3_CONFIG_H
-#define _VST3_CONFIG_H
-
-#define PLUGIN_SUBCATEGORY "Fx|Distortion"
-
-#define PLUGIN_GUID_1 0xbac1c7b4
-#define PLUGIN_GUID_2 0x43454106
-#define PLUGIN_GUID_3 0x92c56a1f
-#define PLUGIN_GUID_4 0x880800c7
-
-#define CTRL_GUID_1 0xd32efa43
-#define CTRL_GUID_2 0x204a4ef4
-#define CTRL_GUID_3 0xbb232ad7
-#define CTRL_GUID_4 0x1dfbaecd
-
-#endif
diff --git a/examples/fx_dist/web/Makefile b/examples/fx_dist/web/Makefile
deleted file mode 100644
index 2cd2000..0000000
--- a/examples/fx_dist/web/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
-SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_dist.c
-
-include ${ROOT_DIR}/../../common/web/web.mk
diff --git a/examples/fxpp_comb/src/plugin.h b/examples/fxpp_comb/src/plugin.h
deleted file mode 100644
index 01d6fc6..0000000
--- a/examples/fxpp_comb/src/plugin.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#include "common.h"
-#include
-
-typedef struct plugin {
- bw_comb_coeffs comb_coeffs;
- bw_comb_state comb_state;
-} plugin;
-
-static void plugin_init(plugin*instance) {
- bw_comb_init(&instance->comb_coeffs, 1.f);
-}
-
-static void plugin_fini(plugin *instance) {
- (void)instance;
-}
-
-static void plugin_set_sample_rate(plugin *instance, float sample_rate) {
- bw_comb_set_sample_rate(&instance->comb_coeffs, sample_rate);
-}
-
-static size_t plugin_mem_req(plugin *instance) {
- return bw_comb_mem_req(&instance->comb_coeffs);
-}
-
-static void plugin_mem_set(plugin *instance, void *mem) {
- bw_comb_mem_set(&instance->comb_coeffs, &instance->comb_state, mem);
-}
-
-static void plugin_reset(plugin *instance) {
- bw_comb_reset_coeffs(&instance->comb_coeffs);
- bw_comb_reset_state(&instance->comb_coeffs, &instance->comb_state, 0.f);
-}
-
-static void plugin_set_parameter(plugin *instance, size_t index, float value) {
- switch (index) {
- case 0:
- bw_comb_set_delay_ff(&instance->comb_coeffs, 0.001f * value);
- break;
- case 1:
- bw_comb_set_delay_fb(&instance->comb_coeffs, 0.001f * value);
- break;
- case 2:
- bw_comb_set_coeff_blend(&instance->comb_coeffs, value);
- break;
- case 3:
- bw_comb_set_coeff_ff(&instance->comb_coeffs, value);
- break;
- case 4:
- bw_comb_set_coeff_fb(&instance->comb_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) {
- bw_comb_process(&instance->comb_coeffs, &instance->comb_state, inputs[0], outputs[0], n_samples);
-}
diff --git a/examples/fxpp_delay/src/plugin.h b/examples/fxpp_delay/src/plugin.h
deleted file mode 100644
index f853209..0000000
--- a/examples/fxpp_delay/src/plugin.h
+++ /dev/null
@@ -1,47 +0,0 @@
-#include "common.h"
-#include
-
-typedef struct plugin {
- bw_delay_coeffs delay_coeffs;
- bw_delay_state delay_state;
-} plugin;
-
-static void plugin_init(plugin *instance) {
- bw_delay_init(&instance->delay_coeffs, 1.f);
-}
-
-static void plugin_fini(plugin *instance) {
- (void)instance;
-}
-
-static void plugin_set_sample_rate(plugin *instance, float sample_rate) {
- bw_delay_set_sample_rate(&instance->delay_coeffs, sample_rate);
-}
-
-static size_t plugin_mem_req(plugin *instance) {
- return bw_delay_mem_req(&instance->delay_coeffs);
-}
-
-static void plugin_mem_set(plugin *instance, void *mem) {
- bw_delay_mem_set(&instance->delay_coeffs, &instance->delay_state, mem);
-}
-
-static void plugin_reset(plugin *instance) {
- bw_delay_reset_coeffs(&instance->delay_coeffs);
- bw_delay_reset_state(&instance->delay_coeffs, &instance->delay_state, 0.f);
-}
-
-static void plugin_set_parameter(plugin *instance, size_t index, float value) {
- (void)index;
- bw_delay_set_delay(&instance->delay_coeffs, 0.001f * value);
-}
-
-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) {
- bw_delay_process(&instance->delay_coeffs, &instance->delay_state, inputs[0], outputs[0], n_samples);
-}
diff --git a/examples/fxpp_dist/src/android.json b/examples/fxpp_dist/src/android.json
new file mode 100644
index 0000000..bb44a3b
--- /dev/null
+++ b/examples/fxpp_dist/src/android.json
@@ -0,0 +1,5 @@
+{
+ "android": {
+ "javaPackageName": "com.orastron.bw_example_fxpp_dist"
+ }
+}
diff --git a/examples/fxpp_dist/src/cmd.json b/examples/fxpp_dist/src/cmd.json
new file mode 100644
index 0000000..524cdd7
--- /dev/null
+++ b/examples/fxpp_dist/src/cmd.json
@@ -0,0 +1,6 @@
+{
+ "cmd": {
+ "busIds": [ "input", "output" ],
+ "parameterIds": [ "distortion", "tone", "volume" ]
+ }
+}
diff --git a/examples/fxpp_dist/src/daisy-seed.json b/examples/fxpp_dist/src/daisy-seed.json
new file mode 100644
index 0000000..fd02e95
--- /dev/null
+++ b/examples/fxpp_dist/src/daisy-seed.json
@@ -0,0 +1,5 @@
+{
+ "daisy_seed": {
+ "parameterPins": [ 15, 16, 17 ]
+ }
+}
diff --git a/examples/fxpp_dist/src/impl.cpp b/examples/fxpp_dist/src/impl.cpp
new file mode 100644
index 0000000..9bf29fd
--- /dev/null
+++ b/examples/fxpp_dist/src/impl.cpp
@@ -0,0 +1,88 @@
+#include "impl.h"
+
+#include "common.h"
+#include
+#include
+
+using namespace Brickworks;
+
+#define BUF_SIZE 32
+
+class Engine {
+public:
+ Engine() : srcUp(2), srcDown(-2) {}
+
+ Dist<1> dist;
+ SRCInt<1> srcUp;
+ SRCInt<1> srcDown;
+
+ float buf[BUF_SIZE];
+};
+
+extern "C" {
+
+impl impl_new(void) {
+ Engine *instance = new Engine();
+ return reinterpret_cast(instance);
+}
+
+void impl_free(impl handle) {
+ Engine *instance = reinterpret_cast(handle);
+ delete instance;
+}
+
+void impl_set_sample_rate(impl handle, float sample_rate) {
+ Engine *instance = reinterpret_cast(handle);
+ instance->dist.setSampleRate(2.f * sample_rate);
+}
+
+void impl_reset(impl handle) {
+ Engine *instance = reinterpret_cast(handle);
+ instance->dist.reset();
+ instance->srcUp.reset();
+ instance->srcDown.reset();
+}
+
+void impl_set_parameter(impl handle, size_t index, float value) {
+ Engine *instance = reinterpret_cast(handle);
+ switch (index) {
+ case 0:
+ instance->dist.setDistortion(0.01f * value);
+ break;
+ case 1:
+ instance->dist.setTone(0.01f * value);
+ break;
+ case 2:
+ instance->dist.setVolume(0.01f * 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(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->dist.process(b, b, n << 1);
+ instance->srcDown.process(b, y, n << 1);
+#else
+ instance->srcUp.process({inputs[0] + i}, {instance->buf}, n);
+ instance->dist.process({instance->buf}, {instance->buf}, n << 1);
+ instance->srcDown.process({instance->buf}, {outputs[0] + i}, n << 1);
+#endif
+ i += n;
+ }
+}
+
+}
diff --git a/examples/fxpp_dist/src/ios.json b/examples/fxpp_dist/src/ios.json
new file mode 100644
index 0000000..85f4c87
--- /dev/null
+++ b/examples/fxpp_dist/src/ios.json
@@ -0,0 +1,5 @@
+{
+ "ios": {
+ "productBundleIdentifier": "com.orastron.bw_example_fxpp_dist"
+ }
+}
diff --git a/examples/fxpp_dist/src/lv2.json b/examples/fxpp_dist/src/lv2.json
new file mode 100644
index 0000000..37e3b72
--- /dev/null
+++ b/examples/fxpp_dist/src/lv2.json
@@ -0,0 +1,12 @@
+{
+ "lv2": {
+ "prefixes": {
+ "bw_examples": "https://www.orastron.com/brickworks/examples/"
+ },
+ "uri": "@bw_examples:fxpp_dist",
+ "types": [ "@lv2:DistortionPlugin" ],
+ "version": "1.0",
+ "busSymbols": [ "input", "output" ],
+ "parameterSymbols": [ "distortion", "tone", "volume" ]
+ }
+}
diff --git a/examples/fxpp_dist/src/plugin.h b/examples/fxpp_dist/src/plugin.h
new file mode 100644
index 0000000..0c42338
--- /dev/null
+++ b/examples/fxpp_dist/src/plugin.h
@@ -0,0 +1,78 @@
+#include "common.h"
+#include
+#include
+
+#define BUF_SIZE 32
+
+typedef struct plugin {
+ bw_dist_coeffs dist_coeffs;
+ bw_dist_state dist_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_dist_init(&instance->dist_coeffs);
+ bw_src_int_init(&instance->src_up_coeffs, 2);
+ bw_src_int_init(&instance->src_down_coeffs, -2);
+}
+
+static void plugin_fini(plugin *instance) {
+ (void)instance;
+}
+
+static void plugin_set_sample_rate(plugin *instance, float sample_rate) {
+ bw_dist_set_sample_rate(&instance->dist_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_dist_reset_coeffs(&instance->dist_coeffs);
+ bw_dist_reset_state(&instance->dist_coeffs, &instance->dist_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_dist_set_distortion(&instance->dist_coeffs, 0.01f * value);
+ break;
+ case 1:
+ bw_dist_set_tone(&instance->dist_coeffs, 0.01f * value);
+ break;
+ case 2:
+ bw_dist_set_volume(&instance->dist_coeffs, 0.01f * 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_dist_process(&instance->dist_coeffs, &instance->dist_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;
+ }
+}
diff --git a/examples/fxpp_dist/src/product.json b/examples/fxpp_dist/src/product.json
new file mode 100644
index 0000000..a5d2f70
--- /dev/null
+++ b/examples/fxpp_dist/src/product.json
@@ -0,0 +1,56 @@
+{
+ "product": {
+ "name": "Brickworks distortion example (C++)",
+ "version": "1.1.0",
+ "buildVersion": "1",
+ "bundleName": "bw_example_fxpp_dist",
+ "buses": [
+ {
+ "type": "audio",
+ "direction": "input",
+ "channels": "mono",
+ "name": "Input",
+ "shortName": "Input"
+ },
+ {
+ "type": "audio",
+ "direction": "output",
+ "channels": "mono",
+ "name": "Output",
+ "shortName": "Output"
+ }
+ ],
+ "parameters": [
+ {
+ "name": "Distortion",
+ "shortName": "Distortion",
+ "direction": "input",
+ "defaultValue": 0.0,
+ "minimum": 0.0,
+ "maximum": 100.0,
+ "unit": "pc",
+ "map": "linear"
+ },
+ {
+ "name": "Tone",
+ "shortName": "Tone",
+ "direction": "input",
+ "defaultValue": 50.0,
+ "minimum": 0.0,
+ "maximum": 100.0,
+ "unit": "pc",
+ "map": "linear"
+ },
+ {
+ "name": "Volume",
+ "shortName": "Volume",
+ "direction": "input",
+ "defaultValue": 100.0,
+ "minimum": 0.0,
+ "maximum": 100.0,
+ "unit": "pc",
+ "map": "linear"
+ }
+ ]
+ }
+}
diff --git a/examples/fxpp_dist/src/vst3.json b/examples/fxpp_dist/src/vst3.json
new file mode 100644
index 0000000..850e2e5
--- /dev/null
+++ b/examples/fxpp_dist/src/vst3.json
@@ -0,0 +1,11 @@
+{
+ "vst3": {
+ "plugin": {
+ "cid": "2e8f9a399e364b2286b3700ce45f087f"
+ },
+ "controller": {
+ "cid": "eaedaadf47f24b9aba44a3f5e2381a56"
+ },
+ "subCategory": "Fx|Distortion"
+ }
+}
diff --git a/examples/tibia_clean.sh b/examples/tibia_clean.sh
index abf92c3..a573b9a 100755
--- a/examples/tibia_clean.sh
+++ b/examples/tibia_clean.sh
@@ -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 synth_simple fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_chorus fxpp_clip fxpp_comb fxpp_comp fxpp_delay 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 synth_simple fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_chorus fxpp_clip fxpp_comb fxpp_comp fxpp_delay fxpp_dist synthpp_simple"
for d in $dirs; do
echo Removing data files for $d
diff --git a/examples/tibia_gen.sh b/examples/tibia_gen.sh
index 2f5dd8f..f18d0c1 100755
--- a/examples/tibia_gen.sh
+++ b/examples/tibia_gen.sh
@@ -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 synth_simple fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_chorus fxpp_clip fxpp_comb fxpp_comp fxpp_delay 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 synth_simple fxpp_ap1 fxpp_ap2 fxpp_balance fxpp_bitcrush fxpp_cab fxpp_chorus fxpp_clip fxpp_comb fxpp_comp fxpp_delay fxpp_dist synthpp_simple"
else
dirs="$1"
fi