fix bw_notch + notch fx example

This commit is contained in:
Stefano D'Angelo 2023-01-24 00:27:42 +01:00
parent bc26c9ed74
commit 720e02e857
9 changed files with 306 additions and 2 deletions

1
TODO
View File

@ -25,6 +25,7 @@ code:
* sample rate-constant coeffs? (pan case)
* pan process with no out: should just reset coeffs?
* trace calls (debug)
* svf bandpass out polarity too confusing?
build system:
* make makefiles handle paths with spaces etc

View File

@ -0,0 +1,83 @@
/*
* 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_notch.h"
#include <bw_notch.h>
#ifdef __WASM__
# include "walloc.h"
#else
# include <stdlib.h>
#endif
enum {
p_cutoff,
p_Q,
p_n
};
struct _bw_example_fx_notch {
// Sub-components
bw_notch_coeffs notch_coeffs;
bw_notch_state notch_state;
// Parameters
float params[p_n];
};
bw_example_fx_notch bw_example_fx_notch_new() {
bw_example_fx_notch instance = (bw_example_fx_notch)malloc(sizeof(struct _bw_example_fx_notch));
if (instance != NULL)
bw_notch_init(&instance->notch_coeffs);
return instance;
}
void bw_example_fx_notch_free(bw_example_fx_notch instance) {
free(instance);
}
void bw_example_fx_notch_set_sample_rate(bw_example_fx_notch instance, float sample_rate) {
bw_notch_set_sample_rate(&instance->notch_coeffs, sample_rate);
}
void bw_example_fx_notch_reset(bw_example_fx_notch instance) {
bw_notch_reset_coeffs(&instance->notch_coeffs);
bw_notch_reset_state(&instance->notch_coeffs, &instance->notch_state);
}
void bw_example_fx_notch_process(bw_example_fx_notch instance, const float** x, float** y, int n_samples) {
bw_notch_process(&instance->notch_coeffs, &instance->notch_state, x[0], y[0], n_samples);
}
void bw_example_fx_notch_set_parameter(bw_example_fx_notch instance, int index, float value) {
instance->params[index] = value;
switch (index) {
case p_cutoff:
bw_notch_set_cutoff(&instance->notch_coeffs, (20e3f - 20.f) * value * value * value + 20.f);
break;
case p_Q:
bw_notch_set_Q(&instance->notch_coeffs, 0.5f + 9.5f * value);
break;
}
}
float bw_example_fx_notch_get_parameter(bw_example_fx_notch instance, int index) {
return instance->params[index];
}

View File

@ -0,0 +1,42 @@
/*
* 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_NOTCH_H
#define _BW_EXAMPLE_FX_NOTCH_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _bw_example_fx_notch* bw_example_fx_notch;
bw_example_fx_notch bw_example_fx_notch_new();
void bw_example_fx_notch_free(bw_example_fx_notch instance);
void bw_example_fx_notch_set_sample_rate(bw_example_fx_notch instance, float sample_rate);
void bw_example_fx_notch_reset(bw_example_fx_notch instance);
void bw_example_fx_notch_process(bw_example_fx_notch instance, const float** x, float** y, int n_samples);
void bw_example_fx_notch_set_parameter(bw_example_fx_notch instance, int index, float value);
float bw_example_fx_notch_get_parameter(bw_example_fx_notch 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_notch"
#define PLUGIN_VERSION "0.3.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] = {
{ "Cutoff", "Cutoff", "", 0, 0, 0, 0.5f },
{ "Q", "Q", "", 0, 0, 0, 0.f }
};
// Internal API
#include "bw_example_fx_notch.h"
#define P_TYPE bw_example_fx_notch
#define P_NEW bw_example_fx_notch_new
#define P_FREE bw_example_fx_notch_free
#define P_SET_SAMPLE_RATE bw_example_fx_notch_set_sample_rate
#define P_RESET bw_example_fx_notch_reset
#define P_PROCESS bw_example_fx_notch_process
#define P_SET_PARAMETER bw_example_fx_notch_set_parameter
#define P_GET_PARAMETER bw_example_fx_notch_get_parameter
#endif

View File

@ -0,0 +1,6 @@
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
NAME := bw_example_fx_notch
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_notch.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|Filter"
#define PLUGIN_GUID_1 0x3270185c
#define PLUGIN_GUID_2 0xbd574bbf
#define PLUGIN_GUID_3 0xb7656faa
#define PLUGIN_GUID_4 0xf126fa47
#define CTRL_GUID_1 0xdb7187e4
#define CTRL_GUID_2 0xcc5a49b3
#define CTRL_GUID_3 0xa734736a
#define CTRL_GUID_4 0xcf5f8fec
#endif

View File

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

View File

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

View File

@ -120,7 +120,7 @@ static inline void bw_notch_set_cutoff(bw_notch_coeffs *BW_RESTRICT coeffs, floa
*
* #### bw_notch_set_Q()
* ```>>> */
static inline void bw_notch_set_Q(bw_svf_coeffs *BW_RESTRICT coeffs, float value);
static inline void bw_notch_set_Q(bw_notch_coeffs *BW_RESTRICT coeffs, float value);
/*! <<<```
* Sets the quality factor to the given `value` in `coeffs`.
*
@ -187,7 +187,7 @@ static inline void bw_notch_set_cutoff(bw_notch_coeffs *BW_RESTRICT coeffs, floa
bw_svf_set_cutoff(&coeffs->svf_coeffs, value);
}
static inline void bw_notch_set_Q(bw_svf_coeffs *BW_RESTRICT coeffs, float value) {
static inline void bw_notch_set_Q(bw_notch_coeffs *BW_RESTRICT coeffs, float value) {
bw_svf_set_Q(&coeffs->svf_coeffs, value);
}