bw_trem fix doc + rename param + new bw_/fx_phaser tentative
This commit is contained in:
parent
a20678a409
commit
7e855aac96
7
examples/fx_phaser/daisy-seed/Makefile
Normal file
7
examples/fx_phaser/daisy-seed/Makefile
Normal file
@ -0,0 +1,7 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
TARGET = bw_example_fx_phaser
|
||||
|
||||
C_SOURCES += ${ROOT_DIR}/../src/bw_example_fx_phaser.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/daisy-seed/daisy-seed.mk
|
37
examples/fx_phaser/daisy-seed/config_daisy_seed.h
Normal file
37
examples/fx_phaser/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
|
57
examples/fx_phaser/src/bw_example_fx_phaser.c
Normal file
57
examples/fx_phaser/src/bw_example_fx_phaser.c
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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_phaser.h"
|
||||
|
||||
void bw_example_fx_phaser_init(bw_example_fx_phaser *instance) {
|
||||
bw_phaser_init(&instance->phaser_coeffs);
|
||||
}
|
||||
|
||||
void bw_example_fx_phaser_set_sample_rate(bw_example_fx_phaser *instance, float sample_rate) {
|
||||
bw_phaser_set_sample_rate(&instance->phaser_coeffs, sample_rate);
|
||||
}
|
||||
|
||||
void bw_example_fx_phaser_reset(bw_example_fx_phaser *instance) {
|
||||
bw_phaser_reset_coeffs(&instance->phaser_coeffs);
|
||||
bw_phaser_reset_state(&instance->phaser_coeffs, &instance->phaser_state);
|
||||
}
|
||||
|
||||
void bw_example_fx_phaser_process(bw_example_fx_phaser *instance, const float** x, float** y, int n_samples) {
|
||||
bw_phaser_process(&instance->phaser_coeffs, &instance->phaser_state, x[0], y[0], n_samples);
|
||||
}
|
||||
|
||||
void bw_example_fx_phaser_set_parameter(bw_example_fx_phaser *instance, int index, float value) {
|
||||
instance->params[index] = value;
|
||||
switch (index) {
|
||||
case p_rate:
|
||||
bw_phaser_set_rate(&instance->phaser_coeffs, (5.f - 0.1f) * value * value * value + 0.1f);
|
||||
break;
|
||||
case p_center:
|
||||
bw_phaser_set_center(&instance->phaser_coeffs, (10e3f - 100.f) * value * value * value + 100.f);
|
||||
break;
|
||||
case p_amount:
|
||||
bw_phaser_set_amount(&instance->phaser_coeffs, 4.f * value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float bw_example_fx_phaser_get_parameter(bw_example_fx_phaser *instance, int index) {
|
||||
return instance->params[index];
|
||||
}
|
58
examples/fx_phaser/src/bw_example_fx_phaser.h
Normal file
58
examples/fx_phaser/src/bw_example_fx_phaser.h
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* 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_PHASER_H
|
||||
#define _BW_EXAMPLE_FX_PHASER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <bw_phaser.h>
|
||||
|
||||
enum {
|
||||
p_rate,
|
||||
p_center,
|
||||
p_amount,
|
||||
p_n
|
||||
};
|
||||
|
||||
struct _bw_example_fx_phaser {
|
||||
// Sub-components
|
||||
bw_phaser_coeffs phaser_coeffs;
|
||||
bw_phaser_state phaser_state;
|
||||
|
||||
// Parameters
|
||||
float params[p_n];
|
||||
};
|
||||
typedef struct _bw_example_fx_phaser bw_example_fx_phaser;
|
||||
|
||||
void bw_example_fx_phaser_init(bw_example_fx_phaser *instance);
|
||||
void bw_example_fx_phaser_set_sample_rate(bw_example_fx_phaser *instance, float sample_rate);
|
||||
void bw_example_fx_phaser_reset(bw_example_fx_phaser *instance);
|
||||
void bw_example_fx_phaser_process(bw_example_fx_phaser *instance, const float** x, float** y, int n_samples);
|
||||
void bw_example_fx_phaser_set_parameter(bw_example_fx_phaser *instance, int index, float value);
|
||||
float bw_example_fx_phaser_get_parameter(bw_example_fx_phaser *instance, int index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
89
examples/fx_phaser/src/config.h
Normal file
89
examples/fx_phaser/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_phaser"
|
||||
#define PLUGIN_VERSION "0.4.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] = {
|
||||
{ "Modulation rate", "Rate", "", 0, 0, 0, 0.5f },
|
||||
{ "Center frequency", "Center", "", 0, 0, 0, 0.5f },
|
||||
{ "Modulation amount", "Amount", "", 0, 0, 0, 0.5f }
|
||||
};
|
||||
|
||||
// Internal API
|
||||
|
||||
#include "bw_example_fx_phaser.h"
|
||||
|
||||
#define P_TYPE bw_example_fx_phaser
|
||||
#define P_INIT bw_example_fx_phaser_init
|
||||
#define P_SET_SAMPLE_RATE bw_example_fx_phaser_set_sample_rate
|
||||
#define P_RESET bw_example_fx_phaser_reset
|
||||
#define P_PROCESS bw_example_fx_phaser_process
|
||||
#define P_SET_PARAMETER bw_example_fx_phaser_set_parameter
|
||||
#define P_GET_PARAMETER bw_example_fx_phaser_get_parameter
|
||||
|
||||
#endif
|
6
examples/fx_phaser/vst3/Makefile
Normal file
6
examples/fx_phaser/vst3/Makefile
Normal file
@ -0,0 +1,6 @@
|
||||
ROOT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
|
||||
NAME := bw_example_fx_phaser
|
||||
SOURCES = ${SOURCES_COMMON} ${ROOT_DIR}/../src/bw_example_fx_phaser.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/vst3/vst3.mk
|
36
examples/fx_phaser/vst3/config_vst3.h
Normal file
36
examples/fx_phaser/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|Modulation"
|
||||
|
||||
#define PLUGIN_GUID_1 0x7be03bdd
|
||||
#define PLUGIN_GUID_2 0x49d746b8
|
||||
#define PLUGIN_GUID_3 0xa6cd129d
|
||||
#define PLUGIN_GUID_4 0xdaa551d1
|
||||
|
||||
#define CTRL_GUID_1 0xb0f47f98
|
||||
#define CTRL_GUID_2 0x51b64cbe
|
||||
#define CTRL_GUID_3 0x9079e44a
|
||||
#define CTRL_GUID_4 0xdad925e3
|
||||
|
||||
#endif
|
4
examples/fx_phaser/web/Makefile
Normal file
4
examples/fx_phaser/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_phaser.c
|
||||
|
||||
include ${ROOT_DIR}/../../common/web/web.mk
|
48
examples/fx_phaser/web/config.js
Normal file
48
examples/fx_phaser/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: "Modulation rate",
|
||||
output: false,
|
||||
defaultValue: 0.5
|
||||
},
|
||||
{
|
||||
name: "Center frequency",
|
||||
output: false,
|
||||
defaultValue: 0.5
|
||||
},
|
||||
{
|
||||
name: "Modulation amount",
|
||||
output: false,
|
||||
defaultValue: 0.5
|
||||
}
|
||||
];
|
@ -40,8 +40,8 @@ void bw_example_fx_trem_process(bw_example_fx_trem *instance, const float** x, f
|
||||
void bw_example_fx_trem_set_parameter(bw_example_fx_trem *instance, int index, float value) {
|
||||
instance->params[index] = value;
|
||||
switch (index) {
|
||||
case p_speed:
|
||||
bw_trem_set_frequency(&instance->trem_coeffs, (20.f - 1.f) * value * value * value + 1.f);
|
||||
case p_rate:
|
||||
bw_trem_set_rate(&instance->trem_coeffs, (20.f - 1.f) * value * value * value + 1.f);
|
||||
break;
|
||||
case p_amount:
|
||||
bw_trem_set_amount(&instance->trem_coeffs, value);
|
||||
|
@ -28,7 +28,7 @@ extern "C" {
|
||||
#include <bw_trem.h>
|
||||
|
||||
enum {
|
||||
p_speed,
|
||||
p_rate,
|
||||
p_amount,
|
||||
p_n
|
||||
};
|
||||
|
@ -51,7 +51,7 @@ struct config_parameter {
|
||||
#define COMPANY_MAILTO "mailto:info@orastron.com"
|
||||
|
||||
#define PLUGIN_NAME "bw_example_fx_trem"
|
||||
#define PLUGIN_VERSION "0.3.0"
|
||||
#define PLUGIN_VERSION "0.4.0"
|
||||
|
||||
#define NUM_BUSES_IN 1
|
||||
#define NUM_BUSES_OUT 1
|
||||
@ -69,7 +69,7 @@ static struct config_io_bus config_buses_out[NUM_BUSES_OUT] = {
|
||||
#define NUM_PARAMETERS 2
|
||||
|
||||
static struct config_parameter config_parameters[NUM_PARAMETERS] = {
|
||||
{ "Speed", "Speed", "", 0, 0, 0, 0.5f },
|
||||
{ "Rate", "Rate", "", 0, 0, 0, 0.5f },
|
||||
{ "Amount", "Amount", "", 0, 0, 0, 0.5f }
|
||||
};
|
||||
|
||||
|
@ -31,7 +31,7 @@ var buses = [
|
||||
|
||||
var parameters = [
|
||||
{
|
||||
name: "Speed",
|
||||
name: "Rate",
|
||||
output: false,
|
||||
defaultValue: 0.5
|
||||
},
|
||||
|
241
include/bw_phaser.h
Normal file
241
include/bw_phaser.h
Normal file
@ -0,0 +1,241 @@
|
||||
/*
|
||||
* 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.4.0 }}}
|
||||
* requires {{{
|
||||
* bw_ap1 bw_config bw_common bw_lp1 bw_math bw_one_pole bw_osc_sin
|
||||
* bw_phase_gen
|
||||
* }}}
|
||||
* description {{{
|
||||
* Phaser containing 4 1st-order allpass filters modulated by a sinusoidal
|
||||
* LFO.
|
||||
* }}}
|
||||
* changelog {{{
|
||||
* <ul>
|
||||
* <li>Version <strong>0.4.0</strong>:
|
||||
* <ul>
|
||||
* <li>First release.</li>
|
||||
* </ul>
|
||||
* </li>
|
||||
* </ul>
|
||||
* }}}
|
||||
*/
|
||||
|
||||
#ifndef _BW_PHASER_H
|
||||
#define _BW_PHASER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <bw_common.h>
|
||||
|
||||
/*! api {{{
|
||||
* #### bw_phaser_coeffs
|
||||
* ```>>> */
|
||||
typedef struct _bw_phaser_coeffs bw_phaser_coeffs;
|
||||
/*! <<<```
|
||||
* Coefficients and related.
|
||||
*
|
||||
* #### bw_phaser_state
|
||||
* ```>>> */
|
||||
typedef struct _bw_phaser_state bw_phaser_state;
|
||||
/*! <<<```
|
||||
* Internal state and related.
|
||||
*
|
||||
* #### bw_phaser_init()
|
||||
* ```>>> */
|
||||
static inline void bw_phaser_init(bw_phaser_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Initializes input parameter values in `coeffs`.
|
||||
*
|
||||
* #### bw_phaser_set_sample_rate()
|
||||
* ```>>> */
|
||||
static inline void bw_phaser_set_sample_rate(bw_phaser_coeffs *BW_RESTRICT coeffs, float sample_rate);
|
||||
/*! <<<```
|
||||
* Sets the `sample_rate` (Hz) value in `coeffs`.
|
||||
*
|
||||
* #### bw_phaser_reset_coeffs()
|
||||
* ```>>> */
|
||||
static inline void bw_phaser_reset_coeffs(bw_phaser_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Resets coefficients in `coeffs` to assume their target values.
|
||||
*
|
||||
* #### bw_phaser_reset_state()
|
||||
* ```>>> */
|
||||
static inline void bw_phaser_reset_state(const bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state *BW_RESTRICT state);
|
||||
/*! <<<```
|
||||
* Resets the given `state` to its initial values using the given `coeffs`.
|
||||
*
|
||||
* #### bw_phaser_update_coeffs_ctrl()
|
||||
* ```>>> */
|
||||
static inline void bw_phaser_update_coeffs_ctrl(bw_phaser_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Triggers control-rate update of coefficients in `coeffs`.
|
||||
*
|
||||
* #### bw_phaser_update_coeffs_audio()
|
||||
* ```>>> */
|
||||
static inline void bw_phaser_update_coeffs_audio(bw_phaser_coeffs *BW_RESTRICT coeffs);
|
||||
/*! <<<```
|
||||
* Triggers audio-rate update of coefficients in `coeffs`.
|
||||
*
|
||||
* #### bw_phaser_process1()
|
||||
* ```>>> */
|
||||
//XXXXXXXXXXXXXXX const
|
||||
static inline float bw_phaser_process1(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state *BW_RESTRICT state, float x);
|
||||
/*! <<<```
|
||||
* Processes one input sample `x` using `coeffs`, while using and updating
|
||||
* `state`. Returns the corresponding output sample.
|
||||
*
|
||||
* #### bw_phaser_process()
|
||||
* ```>>> */
|
||||
static inline void bw_phaser_process(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_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_phaser_set_rate()
|
||||
* ```>>> */
|
||||
static inline void bw_phaser_set_rate(bw_phaser_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
* Sets the modulation rate `value` (Hz) in `coeffs`.
|
||||
*
|
||||
* Default value: `1.f`.
|
||||
*
|
||||
* #### bw_phaser_set_center()
|
||||
* ```>>> */
|
||||
static inline void bw_phaser_set_center(bw_phaser_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
* Sets the center frequency `value` (Hz) in `coeffs`.
|
||||
*
|
||||
* Default value: `1e3f`.
|
||||
*
|
||||
* #### bw_phaser_set_amount()
|
||||
* ```>>> */
|
||||
static inline void bw_phaser_set_amount(bw_phaser_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
* Sets the modulation amount `value` (octaves) 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_phase_gen.h>
|
||||
#include <bw_osc_sin.h>
|
||||
#include <bw_ap1.h>
|
||||
#include <bw_math.h>
|
||||
|
||||
struct _bw_phaser_coeffs {
|
||||
// Sub-components
|
||||
bw_phase_gen_coeffs phase_gen_coeffs;
|
||||
bw_ap1_coeffs ap1_coeffs;
|
||||
|
||||
// Coefficients
|
||||
float cutoff_max;
|
||||
|
||||
// Parameters
|
||||
float center;
|
||||
float amount;
|
||||
};
|
||||
|
||||
struct _bw_phaser_state {
|
||||
bw_phase_gen_state phase_gen_state;
|
||||
bw_ap1_state ap1_state[4];
|
||||
};
|
||||
|
||||
static inline void bw_phaser_init(bw_phaser_coeffs *BW_RESTRICT coeffs) {
|
||||
bw_phase_gen_init(&coeffs->phase_gen_coeffs);
|
||||
bw_ap1_init(&coeffs->ap1_coeffs);
|
||||
coeffs->center = 1e3f;
|
||||
coeffs->amount = 1.f;
|
||||
}
|
||||
|
||||
static inline void bw_phaser_set_sample_rate(bw_phaser_coeffs *BW_RESTRICT coeffs, float sample_rate) {
|
||||
bw_phase_gen_set_sample_rate(&coeffs->phase_gen_coeffs, sample_rate);
|
||||
bw_ap1_set_sample_rate(&coeffs->ap1_coeffs, sample_rate);
|
||||
coeffs->cutoff_max = 0.48f * sample_rate;
|
||||
}
|
||||
|
||||
static inline void bw_phaser_reset_coeffs(bw_phaser_coeffs *BW_RESTRICT coeffs) {
|
||||
bw_phase_gen_reset_coeffs(&coeffs->phase_gen_coeffs);
|
||||
bw_ap1_reset_coeffs(&coeffs->ap1_coeffs);
|
||||
}
|
||||
|
||||
static inline void bw_phaser_reset_state(const bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state *BW_RESTRICT state) {
|
||||
bw_phase_gen_reset_state(&coeffs->phase_gen_coeffs, &state->phase_gen_state, 0.f);
|
||||
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[0]);
|
||||
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[1]);
|
||||
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[2]);
|
||||
bw_ap1_reset_state(&coeffs->ap1_coeffs, &state->ap1_state[3]);
|
||||
}
|
||||
|
||||
static inline void bw_phaser_update_coeffs_ctrl(bw_phaser_coeffs *BW_RESTRICT coeffs) {
|
||||
bw_phase_gen_update_coeffs_ctrl(&coeffs->phase_gen_coeffs);
|
||||
}
|
||||
|
||||
static inline void bw_phaser_update_coeffs_audio(bw_phaser_coeffs *BW_RESTRICT coeffs) {
|
||||
bw_phase_gen_update_coeffs_audio(&coeffs->phase_gen_coeffs);
|
||||
}
|
||||
|
||||
static inline float bw_phaser_process1(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state *BW_RESTRICT state, float x) {
|
||||
float p, pi;
|
||||
bw_phase_gen_process1(&coeffs->phase_gen_coeffs, &state->phase_gen_state, &p, &pi);
|
||||
const float m = coeffs->amount * bw_osc_sin_process1(p);
|
||||
bw_ap1_set_cutoff(&coeffs->ap1_coeffs, bw_clipf(coeffs->center * bw_pow2f_3(m), 1.f, coeffs->cutoff_max));
|
||||
bw_ap1_update_coeffs_ctrl(&coeffs->ap1_coeffs);
|
||||
bw_ap1_update_coeffs_audio(&coeffs->ap1_coeffs);
|
||||
float y = bw_ap1_process1(&coeffs->ap1_coeffs, &state->ap1_state[0], x);
|
||||
y = bw_ap1_process1(&coeffs->ap1_coeffs, &state->ap1_state[1], y);
|
||||
y = bw_ap1_process1(&coeffs->ap1_coeffs, &state->ap1_state[2], y);
|
||||
return x + bw_ap1_process1(&coeffs->ap1_coeffs, &state->ap1_state[3], y);
|
||||
}
|
||||
|
||||
static inline void bw_phaser_process(bw_phaser_coeffs *BW_RESTRICT coeffs, bw_phaser_state *BW_RESTRICT state, const float *x, float *y, int n_samples) {
|
||||
bw_phaser_update_coeffs_ctrl(coeffs);
|
||||
for (int i = 0; i < n_samples; i++) {
|
||||
bw_phaser_update_coeffs_audio(coeffs);
|
||||
y[i] = bw_phaser_process1(coeffs, state, x[i]);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bw_phaser_set_rate(bw_phaser_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
bw_phase_gen_set_frequency(&coeffs->phase_gen_coeffs, value);
|
||||
}
|
||||
|
||||
static inline void bw_phaser_set_center(bw_phaser_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
coeffs->center = value;
|
||||
}
|
||||
|
||||
static inline void bw_phaser_set_amount(bw_phaser_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
coeffs->amount = value;
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -111,15 +111,15 @@ static inline void bw_trem_process(bw_trem_coeffs *BW_RESTRICT coeffs, bw_trem_s
|
||||
* first `n_samples` of the output buffer `y`, while using and updating both
|
||||
* `coeffs` and `state` (control and audio rate).
|
||||
*
|
||||
* #### bw_trem_set_speed()
|
||||
* #### bw_trem_set_rate()
|
||||
* ```>>> */
|
||||
static inline void bw_trem_set_frequency(bw_trem_coeffs *BW_RESTRICT coeffs, float value);
|
||||
static inline void bw_trem_set_rate(bw_trem_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
* Sets the modulation frequency (speed) `value` (Hz) in `coeffs`.
|
||||
* Sets the modulation rate `value` (Hz) in `coeffs`.
|
||||
*
|
||||
* Default value: `1.f`.
|
||||
*
|
||||
* #### bw_trem_set_thresh_dBFS()
|
||||
* #### bw_trem_set_amount()
|
||||
* ```>>> */
|
||||
static inline void bw_trem_set_amount(bw_trem_coeffs *BW_RESTRICT coeffs, float value);
|
||||
/*! <<<```
|
||||
@ -142,10 +142,6 @@ struct _bw_trem_coeffs {
|
||||
// Sub-components
|
||||
bw_phase_gen_coeffs phase_gen_coeffs;
|
||||
bw_ringmod_coeffs ringmod_coeffs;
|
||||
|
||||
// Coefficients
|
||||
|
||||
// Parameters
|
||||
};
|
||||
|
||||
struct _bw_trem_state {
|
||||
@ -196,7 +192,7 @@ static inline void bw_trem_process(bw_trem_coeffs *BW_RESTRICT coeffs, bw_trem_s
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bw_trem_set_frequency(bw_trem_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
static inline void bw_trem_set_rate(bw_trem_coeffs *BW_RESTRICT coeffs, float value) {
|
||||
bw_phase_gen_set_frequency(&coeffs->phase_gen_coeffs, value);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user