bw_{hs2,ls2,mm2,peak} half-fixes + 3band eq example + fix svf ex. Makefile
This commit is contained in:
parent
f795e9520f
commit
1d4d715449
3
TODO
3
TODO
@ -24,12 +24,11 @@ code:
|
||||
* csch for bw_peak bandwidth -> Q
|
||||
* sample rate-constant coeffs? (pan case)
|
||||
* pan process with no out: should just reset coeffs?
|
||||
* trace calls (debug)
|
||||
|
||||
build system:
|
||||
* make makefiles handle paths with spaces etc
|
||||
* can run su on windows? (system-wide install)
|
||||
* make autodependencies (.d?)
|
||||
* make from... directories
|
||||
* order-only prerequisites to avoid multiple make updates? (https://interrupt.memfault.com/blog/gnu-make-guidelines#order-only-prerequisites)
|
||||
* put common parts of Makefiles together somewhere/somehow (DRY)
|
||||
* recursive make?
|
||||
|
129
examples/fx_eq_3band/src/bw_example_fx_eq_3band.c
Normal file
129
examples/fx_eq_3band/src/bw_example_fx_eq_3band.c
Normal file
@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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_eq_3band.h"
|
||||
|
||||
#include <bw_ls2.h>
|
||||
#include <bw_hs2.h>
|
||||
#include <bw_peak.h>
|
||||
#ifdef __WASM__
|
||||
# include "walloc.h"
|
||||
#else
|
||||
# include <stdlib.h>
|
||||
#endif
|
||||
|
||||
enum {
|
||||
p_ls_cutoff,
|
||||
p_ls_gain,
|
||||
p_ls_slope,
|
||||
p_peak_cutoff,
|
||||
p_peak_gain,
|
||||
p_peak_bw,
|
||||
p_hs_cutoff,
|
||||
p_hs_gain,
|
||||
p_hs_slope,
|
||||
p_n
|
||||
};
|
||||
|
||||
struct _bw_example_fx_eq_3band {
|
||||
// Sub-components
|
||||
bw_ls2_coeffs ls2_coeffs;
|
||||
bw_ls2_state ls2_state;
|
||||
bw_peak_coeffs peak_coeffs;
|
||||
bw_peak_state peak_state;
|
||||
bw_hs2_coeffs hs2_coeffs;
|
||||
bw_hs2_state hs2_state;
|
||||
|
||||
// Parameters
|
||||
float params[p_n];
|
||||
};
|
||||
|
||||
bw_example_fx_eq_3band bw_example_fx_eq_3band_new() {
|
||||
bw_example_fx_eq_3band instance = (bw_example_fx_eq_3band)malloc(sizeof(struct _bw_example_fx_eq_3band));
|
||||
if (instance == NULL)
|
||||
return NULL;
|
||||
bw_ls2_init(&instance->ls2_coeffs);
|
||||
bw_peak_init(&instance->peak_coeffs);
|
||||
bw_hs2_init(&instance->hs2_coeffs);
|
||||
bw_ls2_set_use_slope(&instance->ls2_coeffs, 0);
|
||||
bw_hs2_set_use_slope(&instance->hs2_coeffs, 0);
|
||||
return instance;
|
||||
}
|
||||
|
||||
void bw_example_fx_eq_3band_free(bw_example_fx_eq_3band instance) {
|
||||
free(instance);
|
||||
}
|
||||
|
||||
void bw_example_fx_eq_3band_set_sample_rate(bw_example_fx_eq_3band instance, float sample_rate) {
|
||||
bw_ls2_set_sample_rate(&instance->ls2_coeffs, sample_rate);
|
||||
bw_peak_set_sample_rate(&instance->peak_coeffs, sample_rate);
|
||||
bw_hs2_set_sample_rate(&instance->hs2_coeffs, sample_rate);
|
||||
}
|
||||
|
||||
void bw_example_fx_eq_3band_reset(bw_example_fx_eq_3band instance) {
|
||||
bw_ls2_reset_coeffs(&instance->ls2_coeffs);
|
||||
bw_ls2_reset_state(&instance->ls2_coeffs, &instance->ls2_state);
|
||||
bw_peak_reset_coeffs(&instance->peak_coeffs);
|
||||
bw_peak_reset_state(&instance->peak_coeffs, &instance->peak_state);
|
||||
bw_hs2_reset_coeffs(&instance->hs2_coeffs);
|
||||
bw_hs2_reset_state(&instance->hs2_coeffs, &instance->hs2_state);
|
||||
}
|
||||
|
||||
void bw_example_fx_eq_3band_process(bw_example_fx_eq_3band instance, const float** x, float** y, int n_samples) {
|
||||
bw_ls2_process(&instance->ls2_coeffs, &instance->ls2_state, x[0], y[0], n_samples);
|
||||
bw_peak_process(&instance->peak_coeffs, &instance->peak_state, y[0], y[0], n_samples);
|
||||
bw_hs2_process(&instance->hs2_coeffs, &instance->hs2_state, y[0], y[0], n_samples);
|
||||
//bw_peak_process(&instance->peak_coeffs, &instance->peak_state, x[0], y[0], n_samples);
|
||||
}
|
||||
|
||||
void bw_example_fx_eq_3band_set_parameter(bw_example_fx_eq_3band instance, int index, float value) {
|
||||
instance->params[index] = value;
|
||||
switch (index) {
|
||||
case p_ls_cutoff:
|
||||
bw_ls2_set_cutoff(&instance->ls2_coeffs, 20.f + (20e3f - 20.f) * value * value * value);
|
||||
break;
|
||||
case p_ls_gain:
|
||||
bw_ls2_set_dc_gain_dB(&instance->ls2_coeffs, -20.f + 40.f * value);
|
||||
break;
|
||||
case p_ls_slope:
|
||||
break;
|
||||
case p_peak_cutoff:
|
||||
bw_peak_set_cutoff(&instance->peak_coeffs, 20.f + (20e3f - 20.f) * value * value * value);
|
||||
break;
|
||||
case p_peak_gain:
|
||||
bw_peak_set_peak_gain_dB(&instance->peak_coeffs, -20.f + 40.f * value);
|
||||
break;
|
||||
case p_peak_bw:
|
||||
bw_peak_set_bandwidth(&instance->peak_coeffs, 0.5f + 3.9f * value);
|
||||
break;
|
||||
case p_hs_cutoff:
|
||||
bw_hs2_set_cutoff(&instance->hs2_coeffs, 20.f + (20e3f - 20.f) * value * value * value);
|
||||
break;
|
||||
case p_hs_gain:
|
||||
bw_hs2_set_high_gain_dB(&instance->hs2_coeffs, -20.f + 40.f * value);
|
||||
break;
|
||||
case p_hs_slope:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float bw_example_fx_eq_3band_get_parameter(bw_example_fx_eq_3band instance, int index) {
|
||||
return instance->params[index];
|
||||
}
|
42
examples/fx_eq_3band/src/bw_example_fx_eq_3band.h
Normal file
42
examples/fx_eq_3band/src/bw_example_fx_eq_3band.h
Normal 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_EQ_3BAND_H
|
||||
#define _BW_EXAMPLE_FX_EQ_3BAND_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _bw_example_fx_eq_3band* bw_example_fx_eq_3band;
|
||||
|
||||
bw_example_fx_eq_3band bw_example_fx_eq_3band_new();
|
||||
void bw_example_fx_eq_3band_free(bw_example_fx_eq_3band instance);
|
||||
void bw_example_fx_eq_3band_set_sample_rate(bw_example_fx_eq_3band instance, float sample_rate);
|
||||
void bw_example_fx_eq_3band_reset(bw_example_fx_eq_3band instance);
|
||||
void bw_example_fx_eq_3band_process(bw_example_fx_eq_3band instance, const float** x, float** y, int n_samples);
|
||||
void bw_example_fx_eq_3band_set_parameter(bw_example_fx_eq_3band instance, int index, float value);
|
||||
float bw_example_fx_eq_3band_get_parameter(bw_example_fx_eq_3band instance, int index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
96
examples/fx_eq_3band/src/config.h
Normal file
96
examples/fx_eq_3band/src/config.h
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#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_eq_3band"
|
||||
#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 9
|
||||
|
||||
static struct config_parameter config_parameters[NUM_PARAMETERS] = {
|
||||
{ "Low shelf cutoff", "LS cutoff", "Hz", 0, 0, 0, 0.2f },
|
||||
{ "Low shelf gain", "LS gain", "dB", 0, 0, 0, 0.5f },
|
||||
{ "Low shelf slope", "LS slope", "", 0, 0, 0, 0.f },
|
||||
{ "Peak cutoff", "Peak cutoff", "Hz", 0, 0, 0, 0.5f },
|
||||
{ "Peak gain", "Peak gain", "dB", 0, 0, 0, 0.5f },
|
||||
{ "Peak bandiwdth", "Peak BW", "", 0, 0, 0, 1.f },
|
||||
{ "High shelf cutoff", "HS cutoff", "Hz", 0, 0, 0, 0.2f },
|
||||
{ "High shelf gain", "HS gain", "dB", 0, 0, 0, 0.5f },
|
||||
{ "High shelf slope", "HS slope", "", 0, 0, 0, 0.f }
|
||||
};
|
||||
|
||||
// Internal API
|
||||
|
||||
#include "bw_example_fx_eq_3band.h"
|
||||
|
||||
#define P_TYPE bw_example_fx_eq_3band
|
||||
#define P_NEW bw_example_fx_eq_3band_new
|
||||
#define P_FREE bw_example_fx_eq_3band_free
|
||||
#define P_SET_SAMPLE_RATE bw_example_fx_eq_3band_set_sample_rate
|
||||
#define P_RESET bw_example_fx_eq_3band_reset
|
||||
#define P_PROCESS bw_example_fx_eq_3band_process
|
||||
#define P_SET_PARAMETER bw_example_fx_eq_3band_set_parameter
|
||||
#define P_GET_PARAMETER bw_example_fx_eq_3band_get_parameter
|
||||
|
||||
#endif
|
6
examples/fx_eq_3band/vst3/Makefile
Normal file
6
examples/fx_eq_3band/vst3/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
NAME := bw_example_fx_eq_3band
|
||||
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_eq_3band.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/vst3/vst3.mk
|
36
examples/fx_eq_3band/vst3/config_vst3.h
Normal file
36
examples/fx_eq_3band/vst3/config_vst3.h
Normal 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|EQ"
|
||||
|
||||
#define PLUGIN_GUID_1 0x8a205a6d
|
||||
#define PLUGIN_GUID_2 0xa64f4dda
|
||||
#define PLUGIN_GUID_3 0xade68f5d
|
||||
#define PLUGIN_GUID_4 0x60d1202d
|
||||
|
||||
#define CTRL_GUID_1 0x50164b4f
|
||||
#define CTRL_GUID_2 0xe5504647
|
||||
#define CTRL_GUID_3 0x9e0865ed
|
||||
#define CTRL_GUID_4 0x723341d8
|
||||
|
||||
#endif
|
4
examples/fx_eq_3band/web/Makefile
Normal file
4
examples/fx_eq_3band/web/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_eq_3band.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/web/web.mk
|
78
examples/fx_eq_3band/web/config.js
Normal file
78
examples/fx_eq_3band/web/config.js
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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: "Low shelf cutoff",
|
||||
output: false,
|
||||
defaultValue: 0.2
|
||||
},
|
||||
{
|
||||
name: "Low shelf gain",
|
||||
output: false,
|
||||
defaultValue: 0.5
|
||||
},
|
||||
{
|
||||
name: "Low shelf slope",
|
||||
output: false,
|
||||
defaultValue: 0.0
|
||||
},
|
||||
{
|
||||
name: "Peak cutoff",
|
||||
output: false,
|
||||
defaultValue: 0.5
|
||||
},
|
||||
{
|
||||
name: "Peak gain",
|
||||
output: false,
|
||||
defaultValue: 0.5
|
||||
},
|
||||
{
|
||||
name: "Peak bandwidth",
|
||||
output: false,
|
||||
defaultValue: 0.0
|
||||
},
|
||||
{
|
||||
name: "High shelf cutoff",
|
||||
output: false,
|
||||
defaultValue: 0.8
|
||||
},
|
||||
{
|
||||
name: "High shelf gain",
|
||||
output: false,
|
||||
defaultValue: 0.5
|
||||
},
|
||||
{
|
||||
name: "High shelf slope",
|
||||
output: false,
|
||||
defaultValue: 0.0
|
||||
}
|
||||
];
|
@ -1,56 +1,4 @@
|
||||
CC=clang
|
||||
CFLAGS= \
|
||||
-D__WASM__ \
|
||||
-I${ROOT_DIR}/../src \
|
||||
-I${ROOT_DIR}/../../common/web \
|
||||
-I${ROOT_DIR}/../../../include \
|
||||
--target=wasm32 \
|
||||
-flto \
|
||||
-fvisibility=hidden \
|
||||
-Ofast
|
||||
LDFLAGS= \
|
||||
-Wl,--allow-undefined \
|
||||
-Wl,--no-entry \
|
||||
-Wl,--lto-O3 \
|
||||
-Wl,-strip-all \
|
||||
-Wl,--export-table \
|
||||
-Wl,--export=wrapper_new \
|
||||
-Wl,--export=wrapper_free \
|
||||
-Wl,--export=wrapper_get_ins \
|
||||
-Wl,--export=wrapper_get_outs \
|
||||
-Wl,--export=wrapper_get_param_values \
|
||||
-Wl,--export=wrapper_process \
|
||||
-Wl,--export=wrapper_set_parameter \
|
||||
-Wl,-z,stack-size=$$((8*1024*1024)) \
|
||||
-nostdlib
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_svf.c
|
||||
|
||||
ROOT_DIR=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
SOURCES= \
|
||||
${ROOT_DIR}/../src/bw_example_fx_svf.c \
|
||||
${ROOT_DIR}/../../common/web/walloc.c \
|
||||
${ROOT_DIR}/../../common/web/wrapper.c
|
||||
|
||||
all: build/web/module.wasm build/web/index.html build/web/config.js build/web/processor.js build/web/cert.pem build/web/key.pem
|
||||
|
||||
build/web/module.wasm: build/web ${SOURCES}
|
||||
${CC} ${SOURCES} ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
build/web/index.html: build/web ${ROOT_DIR}/index.html
|
||||
cp ${ROOT_DIR}/index.html $@
|
||||
|
||||
build/web/processor.js: build/web ${ROOT_DIR}/config.js ${ROOT_DIR}/../../common/web/processor.js
|
||||
cat ${ROOT_DIR}/config.js ${ROOT_DIR}/../../common/web//processor.js > $@
|
||||
|
||||
build/web/config.js: build/web ${ROOT_DIR}/config.js
|
||||
cp ${ROOT_DIR}/config.js $@
|
||||
|
||||
build/web/key.pem: build/web/cert.pem
|
||||
|
||||
build/web/cert.pem: build/web
|
||||
yes "" | openssl req -x509 -newkey rsa:2048 -keyout build/web/key.pem -out build/web/cert.pem -days 365 -nodes 2>/dev/null
|
||||
|
||||
build/web:
|
||||
mkdir -p build/web
|
||||
|
||||
clean:
|
||||
rm -fr build/web
|
||||
include ${ROOT_DIR}/../../common/web/web.mk
|
||||
|
@ -127,7 +127,7 @@ static inline void bw_hs2_set_cutoff(bw_hs2_coeffs *BW_RESTRICT coeffs, float va
|
||||
*
|
||||
* #### bw_hs2_set_Q()
|
||||
* ```>>> */
|
||||
static inline void bw_hs2_set_Q(bw_mm2_coeffs *BW_RESTRICT coeffs, float value);
|
||||
static inline void bw_hs2_set_Q(bw_hs2_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
* Sets the quality factor to the given `value` in `coeffs`.
|
||||
*
|
||||
@ -163,7 +163,7 @@ static inline void bw_hs2_set_slope(bw_hs2_coeffs *BW_RESTRICT coeffs, float val
|
||||
*
|
||||
* #### bw_hs2_set_use_slope()
|
||||
* ```>>> */
|
||||
static inline void bw_hs2_set_use_slope(bw_mm2_coeffs *BW_RESTRICT coeffs, char value);
|
||||
static inline void bw_hs2_set_use_slope(bw_hs2_coeffs *BW_RESTRICT coeffs, char value);
|
||||
/*! <<<```
|
||||
* Sets whether the quality factor should be controlled via the slope
|
||||
* parameter (`value` non-`0`) or via the Q parameter (`0`).
|
||||
@ -220,10 +220,10 @@ static inline void bw_hs2_set_sample_rate(bw_hs2_coeffs *BW_RESTRICT coeffs, flo
|
||||
bw_mm2_set_sample_rate(&coeffs->mm2_coeffs, sample_rate);
|
||||
}
|
||||
|
||||
static inline void _bw_hs2_update_mm2_params(bw_ls1_coeffs *BW_RESTRICT coeffs) {
|
||||
static inline void _bw_hs2_update_mm2_params(bw_hs2_coeffs *BW_RESTRICT coeffs) {
|
||||
if (coeffs->param_changed) {
|
||||
if (coeffs->param_changed & (_BW_HS2_PARAM_DC_GAIN | _BW_HS2_PARAM_CUTOFF)) {
|
||||
if (coeffs->param_changed & _BW_HS2_PARAM_DC_GAIN) {
|
||||
if (coeffs->param_changed & (_BW_HS2_PARAM_HIGH_GAIN | _BW_HS2_PARAM_CUTOFF)) {
|
||||
if (coeffs->param_changed & _BW_HS2_PARAM_HIGH_GAIN) {
|
||||
coeffs->sg = bw_sqrtf_2(coeffs->high_gain);
|
||||
coeffs->isg = bw_rcpf_2(coeffs->sg);
|
||||
coeffs->ssg = bw_sqrtf_2(coeffs->sg);
|
||||
@ -236,7 +236,7 @@ static inline void _bw_hs2_update_mm2_params(bw_ls1_coeffs *BW_RESTRICT coeffs)
|
||||
bw_mm2_set_cutoff(&coeffs->mm2_coeffs, coeffs->cutoff * coeffs->ssg);
|
||||
}
|
||||
if (coeffs->use_slope) {
|
||||
if (coeffs->param_changed & (_BW_HS2_PARAM_DC_GAIN | _BW_HS2_PARAM_SLOPE)) {
|
||||
if (coeffs->param_changed & (_BW_HS2_PARAM_HIGH_GAIN | _BW_HS2_PARAM_SLOPE)) {
|
||||
const float k = coeffs->sg + coeffs->isg;
|
||||
bw_mm2_set_Q(&coeffs->mm2_coeffs, bw_sqrtf_2(coeffs->slope * bw_rcpf_2(coeffs->slope + coeffs->slope + k - k * coeffs->slope)));
|
||||
}
|
||||
@ -287,7 +287,7 @@ static inline void bw_hs2_set_cutoff(bw_hs2_coeffs *BW_RESTRICT coeffs, float va
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bw_hs2_set_Q(bw_mm2_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
static inline void bw_hs2_set_Q(bw_hs2_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
if (coeffs->Q != value) {
|
||||
coeffs->Q = value;
|
||||
coeffs->param_changed |= _BW_HS2_PARAM_Q;
|
||||
@ -312,7 +312,7 @@ static inline void bw_hs2_set_slope(bw_hs2_coeffs *BW_RESTRICT coeffs, float val
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bw_hs2_set_use_slope(bw_mm2_coeffs *BW_RESTRICT coeffs, char value) {
|
||||
static inline void bw_hs2_set_use_slope(bw_hs2_coeffs *BW_RESTRICT coeffs, char value) {
|
||||
if ((coeffs->use_slope && !value) || (!coeffs->use_slope && value)) {
|
||||
coeffs->use_slope = value;
|
||||
coeffs->param_changed |= _BW_HS2_PARAM_Q | _BW_HS2_PARAM_SLOPE;
|
||||
|
@ -128,7 +128,7 @@ static inline void bw_ls2_set_cutoff(bw_ls2_coeffs *BW_RESTRICT coeffs, float va
|
||||
*
|
||||
* #### bw_ls2_set_Q()
|
||||
* ```>>> */
|
||||
static inline void bw_ls2_set_Q(bw_mm2_coeffs *BW_RESTRICT coeffs, float value);
|
||||
static inline void bw_ls2_set_Q(bw_ls2_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
* Sets the quality factor to the given `value` in `coeffs`.
|
||||
*
|
||||
@ -162,7 +162,7 @@ static inline void bw_ls2_set_slope(bw_ls2_coeffs *BW_RESTRICT coeffs, float val
|
||||
*
|
||||
* #### bw_ls2_set_use_slope()
|
||||
* ```>>> */
|
||||
static inline void bw_ls2_set_use_slope(bw_mm2_coeffs *BW_RESTRICT coeffs, char value);
|
||||
static inline void bw_ls2_set_use_slope(bw_ls2_coeffs *BW_RESTRICT coeffs, char value);
|
||||
/*! <<<```
|
||||
* Sets whether the quality factor should be controlled via the slope
|
||||
* parameter (`value` non-`0`) or via the Q parameter (`0`).
|
||||
@ -219,7 +219,7 @@ static inline void bw_ls2_set_sample_rate(bw_ls2_coeffs *BW_RESTRICT coeffs, flo
|
||||
bw_mm2_set_sample_rate(&coeffs->mm2_coeffs, sample_rate);
|
||||
}
|
||||
|
||||
static inline void _bw_ls2_update_mm2_params(bw_ls1_coeffs *BW_RESTRICT coeffs) {
|
||||
static inline void _bw_ls2_update_mm2_params(bw_ls2_coeffs *BW_RESTRICT coeffs) {
|
||||
if (coeffs->param_changed) {
|
||||
if (coeffs->param_changed & (_BW_LS2_PARAM_DC_GAIN | _BW_LS2_PARAM_CUTOFF)) {
|
||||
if (coeffs->param_changed & _BW_LS2_PARAM_DC_GAIN) {
|
||||
@ -286,7 +286,7 @@ static inline void bw_ls2_set_cutoff(bw_ls2_coeffs *BW_RESTRICT coeffs, float va
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bw_ls2_set_Q(bw_mm2_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
static inline void bw_ls2_set_Q(bw_ls2_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
if (coeffs->Q != value) {
|
||||
coeffs->Q = value;
|
||||
coeffs->param_changed |= _BW_LS2_PARAM_Q;
|
||||
@ -311,7 +311,7 @@ static inline void bw_ls2_set_slope(bw_ls2_coeffs *BW_RESTRICT coeffs, float val
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bw_ls2_set_use_slope(bw_mm2_coeffs *BW_RESTRICT coeffs, char value) {
|
||||
static inline void bw_ls2_set_use_slope(bw_ls2_coeffs *BW_RESTRICT coeffs, char value) {
|
||||
if ((coeffs->use_slope && !value) || (!coeffs->use_slope && value)) {
|
||||
coeffs->use_slope = value;
|
||||
coeffs->param_changed |= _BW_LS2_PARAM_Q | _BW_LS2_PARAM_SLOPE;
|
||||
|
@ -295,7 +295,7 @@ static inline void bw_mm2_set_coeff_lp(bw_mm2_coeffs *BW_RESTRICT coeffs, float
|
||||
}
|
||||
|
||||
static inline void bw_mm2_set_coeff_bp(bw_mm2_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
bw_gain_set_gain_lin(&coeffs->gain_bp_coeffs, value);
|
||||
bw_gain_set_gain_lin(&coeffs->gain_bp_coeffs, -value);
|
||||
}
|
||||
|
||||
static inline void bw_mm2_set_coeff_hp(bw_mm2_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
|
@ -129,7 +129,7 @@ static inline void bw_peak_set_cutoff(bw_peak_coeffs *BW_RESTRICT coeffs, float
|
||||
*
|
||||
* #### bw_peak_set_Q()
|
||||
* ```>>> */
|
||||
static inline void bw_peak_set_Q(bw_mm2_coeffs *BW_RESTRICT coeffs, float value);
|
||||
static inline void bw_peak_set_Q(bw_peak_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
* Sets the quality factor to the given `value` in `coeffs`.
|
||||
*
|
||||
@ -164,7 +164,7 @@ static inline void bw_peak_set_bandwidth(bw_peak_coeffs *BW_RESTRICT coeffs, flo
|
||||
*
|
||||
* #### bw_peak_set_use_slope()
|
||||
* ```>>> */
|
||||
static inline void bw_peak_set_use_bandwidth(bw_mm2_coeffs *BW_RESTRICT coeffs, char value);
|
||||
static inline void bw_peak_set_use_bandwidth(bw_peak_coeffs *BW_RESTRICT coeffs, char value);
|
||||
/*! <<<```
|
||||
* Sets whether the quality factor should be controlled via the bandwidth
|
||||
* parameter (`value` non-`0`) or via the Q parameter (`0`).
|
||||
@ -185,7 +185,7 @@ struct _bw_peak_coeffs {
|
||||
bw_mm2_coeffs mm2_coeffs;
|
||||
|
||||
// Coefficients
|
||||
float bw_Q;
|
||||
float bw_k;
|
||||
|
||||
// Parameters
|
||||
float peak_gain;
|
||||
@ -215,19 +215,18 @@ static inline void bw_peak_set_sample_rate(bw_peak_coeffs *BW_RESTRICT coeffs, f
|
||||
bw_mm2_set_sample_rate(&coeffs->mm2_coeffs, sample_rate);
|
||||
}
|
||||
|
||||
static inline void _bw_ls2_update_mm2_params(bw_ls1_coeffs *BW_RESTRICT coeffs) {
|
||||
static inline void _bw_peak_update_mm2_params(bw_peak_coeffs *BW_RESTRICT coeffs) {
|
||||
if (coeffs->param_changed) {
|
||||
if (coeffs->use_bandwidth) {
|
||||
if (coeffs->param_changed & (_BW_PEAK_PARAM_PEAK_GAIN | _BW_PEAK_PARAM_BANDWIDTH)) {
|
||||
if (coeffs->param_changed & _BW_PEAK_PARAM_BANDWIDTH) {
|
||||
const float k = bw_pow2f_3(coeffs->bandiwdth);
|
||||
coeffs->bw_Q = bw_sqrtf_2(k * coeffs->peak_gain) * bw_rcpf_2(k - 1.f);
|
||||
bw_mm2_set_Q(&coeffs->mm2_coeffs, coeffs->bw_Q);
|
||||
}
|
||||
bw_mm2_set_coeff_bp(&coeffs->mm2_coeffs, (coeffs->peak_gain - 1.f) * bw_rcpf_2(coeffs->bw_Q));
|
||||
if (coeffs->param_changed & _BW_PEAK_PARAM_BANDWIDTH)
|
||||
coeffs->bw_k = bw_pow2f_3(coeffs->bandwidth);
|
||||
const float Q = bw_sqrtf_2(coeffs->bw_k * coeffs->peak_gain) * bw_rcpf_2(coeffs->bw_k - 1.f);
|
||||
bw_mm2_set_Q(&coeffs->mm2_coeffs, Q);
|
||||
bw_mm2_set_coeff_bp(&coeffs->mm2_coeffs, (coeffs->peak_gain - 1.f) * bw_rcpf_2(Q));
|
||||
}
|
||||
} else {
|
||||
if (coeffs->param_changed & (_BW_PEAK_PARAM_PEAK_GAIN | _BW_PEAK_PARAM_Q) {
|
||||
if (coeffs->param_changed & (_BW_PEAK_PARAM_PEAK_GAIN | _BW_PEAK_PARAM_Q)) {
|
||||
if (coeffs->param_changed & _BW_PEAK_PARAM_Q)
|
||||
bw_mm2_set_Q(&coeffs->mm2_coeffs, coeffs->Q);
|
||||
bw_mm2_set_coeff_bp(&coeffs->mm2_coeffs, (coeffs->peak_gain - 1.f) * bw_rcpf_2(coeffs->Q));
|
||||
@ -272,7 +271,7 @@ static inline void bw_peak_set_cutoff(bw_peak_coeffs *BW_RESTRICT coeffs, float
|
||||
bw_mm2_set_cutoff(&coeffs->mm2_coeffs, value);
|
||||
}
|
||||
|
||||
static inline void bw_peak_set_Q(bw_mm2_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
static inline void bw_peak_set_Q(bw_peak_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
if (coeffs->Q != value) {
|
||||
coeffs->Q = value;
|
||||
coeffs->param_changed |= _BW_PEAK_PARAM_Q;
|
||||
@ -297,7 +296,7 @@ static inline void bw_peak_set_bandwidth(bw_peak_coeffs *BW_RESTRICT coeffs, flo
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bw_peak_set_use_bandwidth(bw_mm2_coeffs *BW_RESTRICT coeffs, char value) {
|
||||
static inline void bw_peak_set_use_bandwidth(bw_peak_coeffs *BW_RESTRICT coeffs, char value) {
|
||||
if ((coeffs->use_bandwidth && !value) || (!coeffs->use_bandwidth && value)) {
|
||||
coeffs->use_bandwidth = value;
|
||||
coeffs->param_changed |= _BW_PEAK_PARAM_Q | _BW_PEAK_PARAM_BANDWIDTH;
|
||||
|
Loading…
Reference in New Issue
Block a user