From 20bb3a8193209bceed85cefcb8bcd5555269cc79 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Tue, 28 Jan 2025 10:22:55 +0100 Subject: [PATCH] new examples fxpp_iir{1,2} --- examples/fxpp_iir1/src/android.json | 5 ++ examples/fxpp_iir1/src/daisy-seed.json | 5 ++ examples/fxpp_iir1/src/impl.cpp | 94 +++++++++++++++++++++ examples/fxpp_iir1/src/ios.json | 5 ++ examples/fxpp_iir1/src/lv2.json | 10 +++ examples/fxpp_iir1/src/product.json | 59 +++++++++++++ examples/fxpp_iir1/src/vst3.json | 11 +++ examples/fxpp_iir2/src/android.json | 5 ++ examples/fxpp_iir2/src/daisy-seed.json | 5 ++ examples/fxpp_iir2/src/impl.cpp | 112 +++++++++++++++++++++++++ examples/fxpp_iir2/src/ios.json | 5 ++ examples/fxpp_iir2/src/lv2.json | 10 +++ examples/fxpp_iir2/src/product.json | 89 ++++++++++++++++++++ examples/fxpp_iir2/src/vst3.json | 11 +++ 14 files changed, 426 insertions(+) create mode 100644 examples/fxpp_iir1/src/android.json create mode 100644 examples/fxpp_iir1/src/daisy-seed.json create mode 100644 examples/fxpp_iir1/src/impl.cpp create mode 100644 examples/fxpp_iir1/src/ios.json create mode 100644 examples/fxpp_iir1/src/lv2.json create mode 100644 examples/fxpp_iir1/src/product.json create mode 100644 examples/fxpp_iir1/src/vst3.json create mode 100644 examples/fxpp_iir2/src/android.json create mode 100644 examples/fxpp_iir2/src/daisy-seed.json create mode 100644 examples/fxpp_iir2/src/impl.cpp create mode 100644 examples/fxpp_iir2/src/ios.json create mode 100644 examples/fxpp_iir2/src/lv2.json create mode 100644 examples/fxpp_iir2/src/product.json create mode 100644 examples/fxpp_iir2/src/vst3.json diff --git a/examples/fxpp_iir1/src/android.json b/examples/fxpp_iir1/src/android.json new file mode 100644 index 0000000..a5c13a4 --- /dev/null +++ b/examples/fxpp_iir1/src/android.json @@ -0,0 +1,5 @@ +{ + "android": { + "javaPackageName": "com.orastron.bw_example_fxpp_iir1" + } +} diff --git a/examples/fxpp_iir1/src/daisy-seed.json b/examples/fxpp_iir1/src/daisy-seed.json new file mode 100644 index 0000000..fd02e95 --- /dev/null +++ b/examples/fxpp_iir1/src/daisy-seed.json @@ -0,0 +1,5 @@ +{ + "daisy_seed": { + "parameterPins": [ 15, 16, 17 ] + } +} diff --git a/examples/fxpp_iir1/src/impl.cpp b/examples/fxpp_iir1/src/impl.cpp new file mode 100644 index 0000000..e091684 --- /dev/null +++ b/examples/fxpp_iir1/src/impl.cpp @@ -0,0 +1,94 @@ +/* + * Brickworks + * + * Copyright (C) 2025 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 "impl.h" + +#include "common.h" +#include + +using namespace Brickworks; + +extern "C" { + +typedef struct plugin { + float sample_rate; + float cutoff; + float coeff_x; + float coeff_lp; + float s; + float b0; + float b1; + float a1; + char to_reset; +} plugin; + +impl impl_new(void) { + return reinterpret_cast(new plugin); +} + +void impl_free(impl handle) { + delete reinterpret_cast(handle); +} + +void impl_set_sample_rate(impl handle, float sample_rate) { + plugin *instance = reinterpret_cast(handle); + instance->sample_rate = sample_rate; +} + +void impl_reset(impl handle) { + plugin *instance = reinterpret_cast(handle); + bw_iir1_coeffs_mm1(instance->sample_rate, instance->cutoff, instance->cutoff, instance->coeff_x, instance->coeff_lp, &instance->b0, &instance->b1, &instance->a1); + float x0[1] = { 0.f }; + iir1Reset<1>(x0, BW_NULL, &instance->s, instance->b0, instance->b1, instance->a1); + instance->to_reset = 0; +} + +void impl_set_parameter(impl handle, size_t index, float value) { + plugin *instance = reinterpret_cast(handle); + switch (index) { + case plugin_parameter_cutoff: + instance->cutoff = value; + instance->to_reset = 1; + break; + case plugin_parameter_in: + instance->coeff_x = value; + instance->to_reset = 1; + break; + case plugin_parameter_lp: + instance->coeff_lp = value; + instance->to_reset = 1; + 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) { + plugin *instance = reinterpret_cast(handle); + if (instance->to_reset) + impl_reset(instance); + iir1Process<1>(inputs, outputs, &instance->s, instance->b0, instance->b1, instance->a1, n_samples); +} + +} diff --git a/examples/fxpp_iir1/src/ios.json b/examples/fxpp_iir1/src/ios.json new file mode 100644 index 0000000..069c51b --- /dev/null +++ b/examples/fxpp_iir1/src/ios.json @@ -0,0 +1,5 @@ +{ + "ios": { + "productBundleIdentifier": "com.orastron.bw_example_fxpp_iir1" + } +} diff --git a/examples/fxpp_iir1/src/lv2.json b/examples/fxpp_iir1/src/lv2.json new file mode 100644 index 0000000..e4c2165 --- /dev/null +++ b/examples/fxpp_iir1/src/lv2.json @@ -0,0 +1,10 @@ +{ + "lv2": { + "prefixes": { + "bw_examples": "https://www.orastron.com/brickworks/examples/" + }, + "uri": "@bw_examples:fxpp_iir1", + "types": [ "@lv2:FilterPlugin" ], + "version": "0.0" + } +} diff --git a/examples/fxpp_iir1/src/product.json b/examples/fxpp_iir1/src/product.json new file mode 100644 index 0000000..ba4dbf9 --- /dev/null +++ b/examples/fxpp_iir1/src/product.json @@ -0,0 +1,59 @@ +{ + "product": { + "name": "Brickworks 1st-order IIR filter example (C++)", + "version": "1.0.0", + "buildVersion": "1", + "bundleName": "bw_example_fxpp_iir1", + "buses": [ + { + "type": "audio", + "direction": "input", + "channels": "mono", + "name": "Input", + "shortName": "Input", + "id": "input" + }, + { + "type": "audio", + "direction": "output", + "channels": "mono", + "name": "Output", + "shortName": "Output", + "id": "output" + } + ], + "parameters": [ + { + "name": "Cutoff", + "shortName": "Cutoff", + "id": "cutoff", + "direction": "input", + "defaultValue": 1000.0, + "minimum": 20.0, + "maximum": 20000.0, + "unit": "hz", + "map": "logarithmic" + }, + { + "name": "Input coefficient", + "shortName": "In coeff", + "id": "in", + "direction": "input", + "defaultValue": 1.0, + "minimum": -1.0, + "maximum": 1.0, + "map": "linear" + }, + { + "name": "Lowpass coefficient", + "shortName": "LP coeff", + "id": "lp", + "direction": "input", + "defaultValue": 0.0, + "minimum": -1.0, + "maximum": 1.0, + "map": "linear" + } + ] + } +} diff --git a/examples/fxpp_iir1/src/vst3.json b/examples/fxpp_iir1/src/vst3.json new file mode 100644 index 0000000..6621400 --- /dev/null +++ b/examples/fxpp_iir1/src/vst3.json @@ -0,0 +1,11 @@ +{ + "vst3": { + "plugin": { + "cid": "ebef712c02ad4f579ab633d473a18894" + }, + "controller": { + "cid": "9c81c2d835fa457c9d393ef081e8f1f4" + }, + "subCategory": "Fx|Filter" + } +} diff --git a/examples/fxpp_iir2/src/android.json b/examples/fxpp_iir2/src/android.json new file mode 100644 index 0000000..a1fb136 --- /dev/null +++ b/examples/fxpp_iir2/src/android.json @@ -0,0 +1,5 @@ +{ + "android": { + "javaPackageName": "com.orastron.bw_example_fxpp_iir2" + } +} diff --git a/examples/fxpp_iir2/src/daisy-seed.json b/examples/fxpp_iir2/src/daisy-seed.json new file mode 100644 index 0000000..bc8d28b --- /dev/null +++ b/examples/fxpp_iir2/src/daisy-seed.json @@ -0,0 +1,5 @@ +{ + "daisy_seed": { + "parameterPins": [ 15, 16, 17, 18, 19, 20 ] + } +} diff --git a/examples/fxpp_iir2/src/impl.cpp b/examples/fxpp_iir2/src/impl.cpp new file mode 100644 index 0000000..1de66df --- /dev/null +++ b/examples/fxpp_iir2/src/impl.cpp @@ -0,0 +1,112 @@ +/* + * Brickworks + * + * Copyright (C) 2025 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 "impl.h" + +#include "common.h" +#include + +using namespace Brickworks; + +extern "C" { + +typedef struct plugin { + float sample_rate; + float cutoff; + float q; + float coeff_x; + float coeff_lp; + float coeff_bp; + float coeff_hp; + float s1; + float s2; + float b0; + float b1; + float b2; + float a1; + float a2; + char to_reset; +} plugin; + +impl impl_new(void) { + return reinterpret_cast(new plugin); +} + +void impl_free(impl handle) { + delete reinterpret_cast(handle); +} + +void impl_set_sample_rate(impl handle, float sample_rate) { + plugin *instance = reinterpret_cast(handle); + instance->sample_rate = sample_rate; +} + +void impl_reset(impl handle) { + plugin *instance = reinterpret_cast(handle); + bw_iir2_coeffs_mm2(instance->sample_rate, instance->cutoff, instance->q, instance->cutoff, instance->coeff_x, instance->coeff_lp, instance->coeff_bp, instance->coeff_hp, &instance->b0, &instance->b1, &instance->b2, &instance->a1, &instance->a2); + float x0[1] = { 0.f }; + iir2Reset<1>(x0, BW_NULL, &instance->s1, &instance->s2, instance->b0, instance->b1, instance->b2, instance->a1, instance->a2); + instance->to_reset = 0; +} + +void impl_set_parameter(impl handle, size_t index, float value) { + plugin *instance = reinterpret_cast(handle); + switch (index) { + case plugin_parameter_cutoff: + instance->cutoff = value; + instance->to_reset = 1; + break; + case plugin_parameter_q: + instance->q = value; + instance->to_reset = 1; + break; + case plugin_parameter_in: + instance->coeff_x = value; + instance->to_reset = 1; + break; + case plugin_parameter_lp: + instance->coeff_lp = value; + instance->to_reset = 1; + break; + case plugin_parameter_bp: + instance->coeff_bp = value; + instance->to_reset = 1; + break; + case plugin_parameter_hp: + instance->coeff_hp = value; + instance->to_reset = 1; + 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) { + plugin *instance = reinterpret_cast(handle); + if (instance->to_reset) + impl_reset(instance); + iir2Process<1>(inputs, outputs, &instance->s1, &instance->s2, instance->b0, instance->b1, instance->b2, instance->a1, instance->a2, n_samples); +} + +} diff --git a/examples/fxpp_iir2/src/ios.json b/examples/fxpp_iir2/src/ios.json new file mode 100644 index 0000000..fafda40 --- /dev/null +++ b/examples/fxpp_iir2/src/ios.json @@ -0,0 +1,5 @@ +{ + "ios": { + "productBundleIdentifier": "com.orastron.bw_example_fxpp_iir2" + } +} diff --git a/examples/fxpp_iir2/src/lv2.json b/examples/fxpp_iir2/src/lv2.json new file mode 100644 index 0000000..d962df5 --- /dev/null +++ b/examples/fxpp_iir2/src/lv2.json @@ -0,0 +1,10 @@ +{ + "lv2": { + "prefixes": { + "bw_examples": "https://www.orastron.com/brickworks/examples/" + }, + "uri": "@bw_examples:fxpp_iir2", + "types": [ "@lv2:FilterPlugin" ], + "version": "0.0" + } +} diff --git a/examples/fxpp_iir2/src/product.json b/examples/fxpp_iir2/src/product.json new file mode 100644 index 0000000..d5ba6bd --- /dev/null +++ b/examples/fxpp_iir2/src/product.json @@ -0,0 +1,89 @@ +{ + "product": { + "name": "Brickworks 2nd-order IIR filter example (C++)", + "version": "1.0.0", + "buildVersion": "1", + "bundleName": "bw_example_fxpp_iir2", + "buses": [ + { + "type": "audio", + "direction": "input", + "channels": "mono", + "name": "Input", + "shortName": "Input", + "id": "input" + }, + { + "type": "audio", + "direction": "output", + "channels": "mono", + "name": "Output", + "shortName": "Output", + "id": "output" + } + ], + "parameters": [ + { + "name": "Cutoff", + "shortName": "Cutoff", + "id": "cutoff", + "direction": "input", + "defaultValue": 1000.0, + "minimum": 20.0, + "maximum": 20000.0, + "unit": "hz", + "map": "logarithmic" + }, + { + "name": "Q", + "shortName": "Q", + "id": "q", + "direction": "input", + "defaultValue": 0.5, + "minimum": 0.5, + "maximum": 10.0, + "map": "linear" + }, + { + "name": "Input coefficient", + "shortName": "In coeff", + "id": "in", + "direction": "input", + "defaultValue": 1.0, + "minimum": -1.0, + "maximum": 1.0, + "map": "linear" + }, + { + "name": "Lowpass coefficient", + "shortName": "LP coeff", + "id": "lp", + "direction": "input", + "defaultValue": 0.0, + "minimum": -1.0, + "maximum": 1.0, + "map": "linear" + }, + { + "name": "Bandpass coefficient", + "shortName": "BP coeff", + "id": "bp", + "direction": "input", + "defaultValue": 0.0, + "minimum": -1.0, + "maximum": 1.0, + "map": "linear" + }, + { + "name": "Highpass coefficient", + "shortName": "HP coeff", + "id": "hp", + "direction": "input", + "defaultValue": 0.0, + "minimum": -1.0, + "maximum": 1.0, + "map": "linear" + } + ] + } +} diff --git a/examples/fxpp_iir2/src/vst3.json b/examples/fxpp_iir2/src/vst3.json new file mode 100644 index 0000000..1c7cd7c --- /dev/null +++ b/examples/fxpp_iir2/src/vst3.json @@ -0,0 +1,11 @@ +{ + "vst3": { + "plugin": { + "cid": "5daf6226848c4b85a83563377a27ecaf" + }, + "controller": { + "cid": "ef53040c87b34e37b288476cdb90cc77" + }, + "subCategory": "Fx|Filter" + } +}