beginning of bw_dist and fx_dist + fix bw_peak doc and bw_fuzz init
This commit is contained in:
parent
f3911765f5
commit
b811796e35
1
TODO
1
TODO
@ -43,6 +43,7 @@ code:
|
||||
* bw_math: review types
|
||||
* src inside distortions? w/ control from outside?
|
||||
* bw_fuzz gain compensation?
|
||||
* check initial conditions (especially distorsions)
|
||||
|
||||
build system:
|
||||
* make makefiles handle paths with spaces etc
|
||||
|
7
examples/fx_dist/daisy-seed/Makefile
Normal file
7
examples/fx_dist/daisy-seed/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
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
|
37
examples/fx_dist/daisy-seed/config_daisy_seed.h
Normal file
37
examples/fx_dist/daisy-seed/config_daisy_seed.h
Normal file
@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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_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
|
68
examples/fx_dist/src/bw_example_fx_dist.c
Normal file
68
examples/fx_dist/src/bw_example_fx_dist.c
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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_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);
|
||||
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];
|
||||
}
|
68
examples/fx_dist/src/bw_example_fx_dist.h
Normal file
68
examples/fx_dist/src/bw_example_fx_dist.h
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* 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_DIST_H
|
||||
#define _BW_EXAMPLE_FX_DIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <bw_dist.h>
|
||||
#include <bw_src_int.h>
|
||||
|
||||
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
|
89
examples/fx_dist/src/config.h
Normal file
89
examples/fx_dist/src/config.h
Normal 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_dist"
|
||||
#define PLUGIN_VERSION "0.5.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
|
6
examples/fx_dist/vst3/Makefile
Normal file
6
examples/fx_dist/vst3/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
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/vst3/vst3.mk
|
36
examples/fx_dist/vst3/config_vst3.h
Normal file
36
examples/fx_dist/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|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
|
4
examples/fx_dist/web/Makefile
Normal file
4
examples/fx_dist/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_dist.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/web/web.mk
|
48
examples/fx_dist/web/config.js
Normal file
48
examples/fx_dist/web/config.js
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* 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: "Distortion",
|
||||
output: false,
|
||||
defaultValue: 0.0
|
||||
},
|
||||
{
|
||||
name: "Tone",
|
||||
output: false,
|
||||
defaultValue: 0.5
|
||||
},
|
||||
{
|
||||
name: "Volume",
|
||||
output: false,
|
||||
defaultValue: 1.0
|
||||
}
|
||||
];
|
262
include/bw_dist.h
Normal file
262
include/bw_dist.h
Normal file
@ -0,0 +1,262 @@
|
||||
/*
|
||||
* 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
|
||||
*/
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 0.5.0 }}}
|
||||
* requires {{{
|
||||
* bw_clip bw_config bw_common bw_gain bw_hp1 bw_lp1 bw_math bw_mm2 bw_peak
|
||||
* bw_one_pole bw_satur bw_svf
|
||||
* }}}
|
||||
* description {{{
|
||||
* Distortion effect.
|
||||
*
|
||||
* Loosely inspired to the "rodent" distortion pedal.
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>0.5.0</strong>:
|
||||
* <ul>
|
||||
* <li>First release.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* </ul>
|
||||
* }}}
|
||||
*/
|
||||
|
||||
#ifndef _BW_DIST_H
|
||||
#define _BW_DIST_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <bw_common.h>
|
||||
|
||||
/*! api {{{
|
||||
* #### bw_dist_coeffs
|
||||
* ```>>> */
|
||||
typedef struct _bw_dist_coeffs bw_dist_coeffs;
|
||||
/*! <<<```
|
||||
* Coefficients and related.
|
||||
*
|
||||
* #### bw_dist_state
|
||||
* ```>>> */
|
||||
typedef struct _bw_dist_state bw_dist_state;
|
||||
/*! <<<```
|
||||
* Internal state and related.
|
||||
*
|
||||
* #### bw_dist_init()
|
||||
* ```>>> */
|
||||
static inline void bw_dist_init(bw_dist_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Initializes input parameter values in `coeffs`.
|
||||
*
|
||||
* #### bw_dist_set_sample_rate()
|
||||
* ```>>> */
|
||||
static inline void bw_dist_set_sample_rate(bw_dist_coeffs *BW_RESTRICT coeffs, float sample_rate);
|
||||
/*! <<<```
|
||||
* Sets the `sample_rate` (Hz) value in `coeffs`.
|
||||
*
|
||||
* #### bw_dist_reset_coeffs()
|
||||
* ```>>> */
|
||||
static inline void bw_dist_reset_coeffs(bw_dist_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Resets coefficients in `coeffs` to assume their target values.
|
||||
*
|
||||
* #### bw_dist_reset_state()
|
||||
* ```>>> */
|
||||
static inline void bw_dist_reset_state(const bw_dist_coeffs *BW_RESTRICT coeffs, bw_dist_state *BW_RESTRICT state);
|
||||
/*! <<<```
|
||||
* Resets the given `state` to its initial values using the given `coeffs`.
|
||||
*
|
||||
* #### bw_dist_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
static inline void bw_dist_update_coeffs_ctrl(bw_dist_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Triggers control-rate update of coefficients in `coeffs`.
|
||||
*
|
||||
* #### bw_dist_update_coeffs_audio()
|
||||
* ```>>> */
|
||||
static inline void bw_dist_update_coeffs_audio(bw_dist_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Triggers audio-rate update of coefficients in `coeffs`.
|
||||
*
|
||||
* #### bw_dist_process1()
|
||||
* ```>>> */
|
||||
static inline float bw_dist_process1(const bw_dist_coeffs *BW_RESTRICT coeffs, bw_dist_state *BW_RESTRICT state, float x);
|
||||
/*! <<<```
|
||||
* Processes one input sample `x` using `coeffs`, while using and updating
|
||||
* `state`. Returns the corresponding output sample.
|
||||
*
|
||||
* #### bw_dist_process()
|
||||
* ```>>> */
|
||||
static inline void bw_dist_process(bw_dist_coeffs *BW_RESTRICT coeffs, bw_dist_state *BW_RESTRICT state, const float *x, float *y, int n_samples);
|
||||
/*! <<<```
|
||||
* Processes the first `n_samples` of the input buffer `x` and fills the
|
||||
* first `n_samples` of the output buffer `y`, while using and updating both
|
||||
* `coeffs` and `state` (control and audio rate).
|
||||
*
|
||||
* #### bw_dist_set_distortion()
|
||||
* ```>>> */
|
||||
static inline void bw_dist_set_distortion(bw_dist_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
* Sets the distortion (input gain, approximately) to the given `value` in
|
||||
* [`0.f`, `1.f`] in `coeffs`.
|
||||
*
|
||||
* Default value: `0.f`.
|
||||
*
|
||||
* #### bw_dist_set_tone()
|
||||
* ```>>> */
|
||||
static inline void bw_dist_set_tone(bw_dist_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
* Sets the tone (filter) to the given `value` in [`0.f`, `1.f`] in `coeffs`.
|
||||
*
|
||||
* Default value: `0.5f`.
|
||||
*
|
||||
* #### bw_dist_set_volume()
|
||||
* ```>>> */
|
||||
static inline void bw_dist_set_volume(bw_dist_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
* Sets the volume (output gain) to the given `value` in [`0.f`, `1.f`] in
|
||||
* `coeffs`.
|
||||
*
|
||||
* Default value: `1.f`.
|
||||
* }}} */
|
||||
|
||||
/*** Implementation ***/
|
||||
|
||||
/* WARNING: This part of the file is not part of the public API. Its content may
|
||||
* change at any time in future versions. Please, do not use it directly. */
|
||||
|
||||
#include <bw_hp1.h>
|
||||
#include <bw_peak.h>
|
||||
#include <bw_clip.h>
|
||||
#include <bw_satur.h>
|
||||
#include <bw_lp1.h>
|
||||
#include <bw_gain.h>
|
||||
|
||||
struct _bw_dist_coeffs {
|
||||
// Sub-components
|
||||
bw_hp1_coeffs hp1_coeffs;
|
||||
bw_peak_coeffs peak_coeffs;
|
||||
bw_clip_coeffs clip_coeffs;
|
||||
bw_satur_coeffs satur_coeffs;
|
||||
bw_lp1_coeffs lp1_coeffs;
|
||||
bw_gain_coeffs gain_coeffs;
|
||||
};
|
||||
|
||||
struct _bw_dist_state {
|
||||
// Sub-components
|
||||
bw_hp1_state hp1_state;
|
||||
bw_peak_state peak_state;
|
||||
bw_clip_state clip_state;
|
||||
bw_satur_state satur_state;
|
||||
bw_lp1_state lp1_state;
|
||||
};
|
||||
|
||||
static inline void bw_dist_init(bw_dist_coeffs *BW_RESTRICT coeffs) {
|
||||
bw_hp1_init(&coeffs->hp1_coeffs);
|
||||
bw_peak_init(&coeffs->peak_coeffs);
|
||||
bw_clip_init(&coeffs->clip_coeffs);
|
||||
bw_satur_init(&coeffs->satur_coeffs);
|
||||
bw_lp1_init(&coeffs->lp1_coeffs);
|
||||
bw_gain_init(&coeffs->gain_coeffs);
|
||||
bw_hp1_set_cutoff(&coeffs->hp1_coeffs, 7.f);
|
||||
bw_peak_set_cutoff(&coeffs->peak_coeffs, 600.f);
|
||||
bw_peak_set_bandwidth(&coeffs->peak_coeffs, 10.f);
|
||||
bw_clip_set_bias(&coeffs->clip_coeffs, 0.75f / 4.25f);
|
||||
bw_clip_set_gain(&coeffs->clip_coeffs, 1.f / 4.25f);
|
||||
bw_satur_set_gain(&coeffs->satur_coeffs, 1.f / 0.7f);
|
||||
bw_lp1_set_cutoff(&coeffs->lp1_coeffs, 475.f + (20e3f - 475.f) * 0.125f);
|
||||
}
|
||||
|
||||
static inline void bw_dist_set_sample_rate(bw_dist_coeffs *BW_RESTRICT coeffs, float sample_rate) {
|
||||
bw_hp1_set_sample_rate(&coeffs->hp1_coeffs, sample_rate);
|
||||
bw_peak_set_sample_rate(&coeffs->peak_coeffs, sample_rate);
|
||||
bw_clip_set_sample_rate(&coeffs->clip_coeffs, sample_rate);
|
||||
bw_satur_set_sample_rate(&coeffs->satur_coeffs, sample_rate);
|
||||
bw_lp1_set_sample_rate(&coeffs->lp1_coeffs, sample_rate);
|
||||
bw_gain_set_sample_rate(&coeffs->gain_coeffs, sample_rate);
|
||||
bw_hp1_reset_coeffs(&coeffs->hp1_coeffs);
|
||||
bw_clip_reset_coeffs(&coeffs->clip_coeffs);
|
||||
bw_satur_reset_coeffs(&coeffs->satur_coeffs);
|
||||
}
|
||||
|
||||
static inline void bw_dist_reset_coeffs(bw_dist_coeffs *BW_RESTRICT coeffs) {
|
||||
bw_peak_reset_coeffs(&coeffs->peak_coeffs);
|
||||
bw_lp1_reset_coeffs(&coeffs->lp1_coeffs);
|
||||
bw_gain_reset_coeffs(&coeffs->gain_coeffs);
|
||||
}
|
||||
|
||||
static inline void bw_dist_reset_state(const bw_dist_coeffs *BW_RESTRICT coeffs, bw_dist_state *BW_RESTRICT state) {
|
||||
bw_hp1_reset_state(&coeffs->hp1_coeffs, &state->hp1_state, 0.f);
|
||||
bw_peak_reset_state(&coeffs->peak_coeffs, &state->peak_state, 0.f);
|
||||
bw_clip_reset_state(&coeffs->clip_coeffs, &state->clip_state);
|
||||
bw_satur_reset_state(&coeffs->satur_coeffs, &state->satur_state);
|
||||
bw_lp1_reset_state(&coeffs->lp1_coeffs, &state->lp1_state, 0.f);
|
||||
}
|
||||
|
||||
static inline void bw_dist_update_coeffs_ctrl(bw_dist_coeffs *BW_RESTRICT coeffs) {
|
||||
bw_peak_update_coeffs_ctrl(&coeffs->peak_coeffs);
|
||||
bw_lp1_update_coeffs_ctrl(&coeffs->lp1_coeffs);
|
||||
bw_gain_update_coeffs_ctrl(&coeffs->gain_coeffs);
|
||||
}
|
||||
|
||||
static inline void bw_dist_update_coeffs_audio(bw_dist_coeffs *BW_RESTRICT coeffs) {
|
||||
bw_peak_update_coeffs_audio(&coeffs->peak_coeffs);
|
||||
bw_lp1_update_coeffs_audio(&coeffs->lp1_coeffs);
|
||||
bw_gain_update_coeffs_audio(&coeffs->gain_coeffs);
|
||||
}
|
||||
|
||||
static inline float bw_dist_process1(const bw_dist_coeffs *BW_RESTRICT coeffs, bw_dist_state *BW_RESTRICT state, float x) {
|
||||
float y = bw_lp1_process1(&coeffs->lp1_coeffs, &state->lp1_state, x);
|
||||
y = bw_peak_process1(&coeffs->peak_coeffs, &state->peak_state, y);
|
||||
y = bw_clip_process1_comp(&coeffs->clip_coeffs, &state->clip_state, y);
|
||||
y = bw_satur_process1_comp(&coeffs->satur_coeffs, &state->satur_state, y);
|
||||
y = bw_lp1_process1(&coeffs->lp1_coeffs, &state->lp1_state, y);
|
||||
return bw_gain_process1(&coeffs->gain_coeffs, y);
|
||||
}
|
||||
|
||||
static inline void bw_dist_process(bw_dist_coeffs *BW_RESTRICT coeffs, bw_dist_state *BW_RESTRICT state, const float *x, float *y, int n_samples) {
|
||||
bw_dist_update_coeffs_ctrl(coeffs);
|
||||
for (int i = 0; i < n_samples; i++) {
|
||||
bw_dist_update_coeffs_audio(coeffs);
|
||||
y[i] = bw_dist_process1(coeffs, state, x[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bw_dist_set_distortion(bw_dist_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
bw_peak_set_peak_gain_dB(&coeffs->peak_coeffs, 60.f * value);
|
||||
}
|
||||
|
||||
static inline void bw_dist_set_tone(bw_dist_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
bw_lp1_set_cutoff(&coeffs->lp1_coeffs, 475.f + (20e3f - 475.f) * value * value * value);
|
||||
}
|
||||
|
||||
static inline void bw_dist_set_volume(bw_dist_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
bw_gain_set_gain_lin(&coeffs->gain_coeffs, value * value * value);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -171,6 +171,7 @@ static inline void bw_fuzz_init(bw_fuzz_coeffs *BW_RESTRICT coeffs) {
|
||||
bw_svf_set_Q(&coeffs->svf_coeffs, 0.87f);
|
||||
bw_hs1_set_cutoff(&coeffs->hs1_coeffs, 50.f);
|
||||
bw_satur_set_bias(&coeffs->satur_coeffs, 0.11f);
|
||||
bw_satur_set_gain_compensation(&coeffs->satur_coeffs, 0);
|
||||
bw_hp1_set_cutoff(&coeffs->hp1_coeffs, 30.f);
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
/*!
|
||||
* module_type {{{ dsp }}}
|
||||
* version {{{ 0.4.0 }}}
|
||||
* version {{{ 0.5.0 }}}
|
||||
* requires {{{
|
||||
* bw_config bw_common bw_gain bw_math bw_mm2 bw_one_pole bw_svf
|
||||
* }}}
|
||||
@ -37,6 +37,12 @@
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>0.5.0</strong>:
|
||||
* <ul>
|
||||
* <li>Fixed documentation for <code>bw_peak_set_peak_gain_lin()</code>
|
||||
* and <code>bw_peak_set_gain_dB()</code>.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* <li>Version <strong>0.4.0</strong>:
|
||||
* <ul>
|
||||
* <li>Added initial input value to
|
||||
@ -144,7 +150,7 @@ static inline void bw_peak_set_Q(bw_peak_coeffs *BW_RESTRICT coeffs, float value
|
||||
*
|
||||
* Default value: `0.5f`.
|
||||
*
|
||||
* #### bw_peak_set_gain_lin()
|
||||
* #### bw_peak_set_peak_gain_lin()
|
||||
* ```>>> */
|
||||
static inline void bw_peak_set_peak_gain_lin(bw_peak_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
@ -153,7 +159,7 @@ static inline void bw_peak_set_peak_gain_lin(bw_peak_coeffs *BW_RESTRICT coeffs,
|
||||
*
|
||||
* Default value: `0.f`.
|
||||
*
|
||||
* #### bw_peak_set_dc_gain_dB()
|
||||
* #### bw_peak_set_peak_gain_dB()
|
||||
* ```>>> */
|
||||
static inline void bw_peak_set_peak_gain_dB(bw_peak_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
|
Loading…
Reference in New Issue
Block a user