new examples fxpp_iir{1,2}

This commit is contained in:
Stefano D'Angelo 2025-01-28 10:22:55 +01:00
parent fb3ab23599
commit 20bb3a8193
14 changed files with 426 additions and 0 deletions

View File

@ -0,0 +1,5 @@
{
"android": {
"javaPackageName": "com.orastron.bw_example_fxpp_iir1"
}
}

View File

@ -0,0 +1,5 @@
{
"daisy_seed": {
"parameterPins": [ 15, 16, 17 ]
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#include "impl.h"
#include "common.h"
#include <bw_iir1.h>
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<impl>(new plugin);
}
void impl_free(impl handle) {
delete reinterpret_cast<plugin *>(handle);
}
void impl_set_sample_rate(impl handle, float sample_rate) {
plugin *instance = reinterpret_cast<plugin *>(handle);
instance->sample_rate = sample_rate;
}
void impl_reset(impl handle) {
plugin *instance = reinterpret_cast<plugin *>(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<plugin *>(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<plugin *>(handle);
if (instance->to_reset)
impl_reset(instance);
iir1Process<1>(inputs, outputs, &instance->s, instance->b0, instance->b1, instance->a1, n_samples);
}
}

View File

@ -0,0 +1,5 @@
{
"ios": {
"productBundleIdentifier": "com.orastron.bw_example_fxpp_iir1"
}
}

View File

@ -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"
}
}

View File

@ -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"
}
]
}
}

View File

@ -0,0 +1,11 @@
{
"vst3": {
"plugin": {
"cid": "ebef712c02ad4f579ab633d473a18894"
},
"controller": {
"cid": "9c81c2d835fa457c9d393ef081e8f1f4"
},
"subCategory": "Fx|Filter"
}
}

View File

@ -0,0 +1,5 @@
{
"android": {
"javaPackageName": "com.orastron.bw_example_fxpp_iir2"
}
}

View File

@ -0,0 +1,5 @@
{
"daisy_seed": {
"parameterPins": [ 15, 16, 17, 18, 19, 20 ]
}
}

View File

@ -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 <http://www.gnu.org/licenses/>.
*
* File author: Stefano D'Angelo
*/
#include "impl.h"
#include "common.h"
#include <bw_iir2.h>
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<impl>(new plugin);
}
void impl_free(impl handle) {
delete reinterpret_cast<plugin *>(handle);
}
void impl_set_sample_rate(impl handle, float sample_rate) {
plugin *instance = reinterpret_cast<plugin *>(handle);
instance->sample_rate = sample_rate;
}
void impl_reset(impl handle) {
plugin *instance = reinterpret_cast<plugin *>(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<plugin *>(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<plugin *>(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);
}
}

View File

@ -0,0 +1,5 @@
{
"ios": {
"productBundleIdentifier": "com.orastron.bw_example_fxpp_iir2"
}
}

View File

@ -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"
}
}

View File

@ -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"
}
]
}
}

View File

@ -0,0 +1,11 @@
{
"vst3": {
"plugin": {
"cid": "5daf6226848c4b85a83563377a27ecaf"
},
"controller": {
"cid": "ef53040c87b34e37b288476cdb90cc77"
},
"subCategory": "Fx|Filter"
}
}