From 98db248b5b410dc7f0da979213ee175a0e29a92e Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Sat, 8 Apr 2023 08:25:05 +0200 Subject: [PATCH] improved bw_comb and bw_chorus, simplified fx_chorus --- .../fx_chorus/daisy-seed/config_daisy_seed.h | 7 ++--- examples/fx_chorus/src/bw_example_fx_chorus.c | 17 ++++------- examples/fx_chorus/src/bw_example_fx_chorus.h | 3 -- examples/fx_chorus/src/config.h | 9 ++---- examples/fx_chorus/web/config.js | 19 ++----------- include/bw_chorus.h | 28 ++++++++++++++----- include/bw_comb.h | 2 +- 7 files changed, 35 insertions(+), 50 deletions(-) diff --git a/examples/fx_chorus/daisy-seed/config_daisy_seed.h b/examples/fx_chorus/daisy-seed/config_daisy_seed.h index 0e5825d..c56c264 100644 --- a/examples/fx_chorus/daisy-seed/config_daisy_seed.h +++ b/examples/fx_chorus/daisy-seed/config_daisy_seed.h @@ -26,14 +26,11 @@ struct config_pin { int pin; }; -#define NUM_PINS 5 +#define NUM_PINS 2 static struct config_pin config_pins[NUM_PINS] = { { 0, 15 }, - { 1, 16 }, - { 2, 17 }, - { 3, 18 }, - { 4, 19 }, + { 1, 16 } }; #endif diff --git a/examples/fx_chorus/src/bw_example_fx_chorus.c b/examples/fx_chorus/src/bw_example_fx_chorus.c index 6080c0e..9ddb7ce 100644 --- a/examples/fx_chorus/src/bw_example_fx_chorus.c +++ b/examples/fx_chorus/src/bw_example_fx_chorus.c @@ -22,6 +22,10 @@ void bw_example_fx_chorus_init(bw_example_fx_chorus *instance) { bw_chorus_init(&instance->chorus_coeffs, 0.1f); + bw_chorus_set_delay(&instance->chorus_coeffs, 0.005f); + bw_chorus_set_coeff_x(&instance->chorus_coeffs, 0.7071f); + bw_chorus_set_coeff_mod(&instance->chorus_coeffs, 1.f); + bw_chorus_set_coeff_fb(&instance->chorus_coeffs, -0.7071f); } void bw_example_fx_chorus_set_sample_rate(bw_example_fx_chorus *instance, float sample_rate) { @@ -49,19 +53,10 @@ void bw_example_fx_chorus_set_parameter(bw_example_fx_chorus *instance, int inde instance->params[index] = value; switch (index) { case p_rate: - bw_chorus_set_rate(&instance->chorus_coeffs, value); - break; - case p_delay: - bw_chorus_set_delay(&instance->chorus_coeffs, 0.1f * value); + bw_chorus_set_rate(&instance->chorus_coeffs, 0.01f + 1.99f * value * value * value); break; case p_amount: - bw_chorus_set_amount(&instance->chorus_coeffs, 0.05f * value); - break; - case p_input: - bw_chorus_set_coeff_x(&instance->chorus_coeffs, value); - break; - case p_mod: - bw_chorus_set_coeff_mod(&instance->chorus_coeffs, value); + bw_chorus_set_amount(&instance->chorus_coeffs, 0.004f * value); break; } } diff --git a/examples/fx_chorus/src/bw_example_fx_chorus.h b/examples/fx_chorus/src/bw_example_fx_chorus.h index 19aaf9f..80bc66b 100644 --- a/examples/fx_chorus/src/bw_example_fx_chorus.h +++ b/examples/fx_chorus/src/bw_example_fx_chorus.h @@ -29,10 +29,7 @@ extern "C" { enum { p_rate, - p_delay, p_amount, - p_input, - p_mod, p_n }; diff --git a/examples/fx_chorus/src/config.h b/examples/fx_chorus/src/config.h index 434537d..15cf7b3 100644 --- a/examples/fx_chorus/src/config.h +++ b/examples/fx_chorus/src/config.h @@ -66,14 +66,11 @@ static struct config_io_bus config_buses_out[NUM_BUSES_OUT] = { { "Audio out", 1, 0, 0, IO_MONO } }; -#define NUM_PARAMETERS 5 +#define NUM_PARAMETERS 2 static struct config_parameter config_parameters[NUM_PARAMETERS] = { - { "Modulation rate", "Rate", "", 0, 0, 0, 0.5f }, - { "Delay", "Delay", "s", 0, 0, 0, 0.5f }, - { "Modulation amount", "Mod amount", "", 0, 0, 0, 0.5f }, - { "Input", "Input", "", 0, 0, 0, 0.5f }, - { "Modulated branch", "Mod branch", "", 0, 0, 0, 0.5f }, + { "Rate", "Rate", "", 0, 0, 0, 0.5f }, + { "Depth", "Depth", "", 0, 0, 0, 0.5f }, }; // Internal API diff --git a/examples/fx_chorus/web/config.js b/examples/fx_chorus/web/config.js index 861dc56..f704641 100644 --- a/examples/fx_chorus/web/config.js +++ b/examples/fx_chorus/web/config.js @@ -31,27 +31,12 @@ var buses = [ var parameters = [ { - name: "Modulation rate", + name: "Rate", output: false, defaultValue: 0.5 }, { - name: "Delay", - output: false, - defaultValue: 0.5 - }, - { - name: "Modulation amount", - output: false, - defaultValue: 0.5 - }, - { - name: "Input", - output: false, - defaultValue: 0.5 - }, - { - name: "Modulated branch", + name: "Amount", output: false, defaultValue: 0.5 } diff --git a/include/bw_chorus.h b/include/bw_chorus.h index fbf6bdc..af5ebf6 100644 --- a/include/bw_chorus.h +++ b/include/bw_chorus.h @@ -26,10 +26,13 @@ * bw_osc_sin bw_phase_gen * }}} * description {{{ - * Chorus / vibrato with variable speed and amount. + * Chorus / vibrato / flanger with variable rate and amount. * * It outputs a mix of the dry input signal with itself going through a - * modulated delay. + * modulated delay and an optional feedback, as explained in + * + * J. Dattorro, "Effect Design, Part 2: Delay-Line Modulation and Chorus", + * J. Audio Eng. Soc., vol. 45, no. 10, pp. 764-788, October 1997. * }}} * changelog {{{ *