From bc26c9ed74f706429d18d5527f83ad23f196bd04 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Fri, 20 Jan 2023 19:21:35 +0100 Subject: [PATCH] removed slope nonsense from bw_{h,l}s2 and eq example + fixes --- examples/common/web/web.mk | 4 +- .../fx_eq_3band/src/bw_example_fx_eq_3band.c | 12 +-- examples/fx_eq_3band/src/config.h | 4 +- examples/fx_eq_3band/web/config.js | 4 +- .../synth_mono/src/bw_example_synth_mono.c | 7 +- include/bw_hs2.h | 84 +++---------------- include/bw_ls2.h | 84 +++---------------- include/bw_math.h | 2 +- include/bw_peak.h | 2 +- 9 files changed, 41 insertions(+), 162 deletions(-) diff --git a/examples/common/web/web.mk b/examples/common/web/web.mk index b1af648..785bedd 100644 --- a/examples/common/web/web.mk +++ b/examples/common/web/web.mk @@ -26,7 +26,9 @@ LDFLAGS := \ ifdef SYNTH LDFLAGS += \ -Wl,--export=wrapper_note_on \ - -Wl,--export=wrapper_note_off + -Wl,--export=wrapper_note_off \ + -Wl,--export=wrapper_pitch_bend \ + -Wl,--export=wrapper_mod_wheel INDEX := ${ROOT_DIR}/../../common/web/index-synth.html else diff --git a/examples/fx_eq_3band/src/bw_example_fx_eq_3band.c b/examples/fx_eq_3band/src/bw_example_fx_eq_3band.c index 197cdf5..863ee29 100644 --- a/examples/fx_eq_3band/src/bw_example_fx_eq_3band.c +++ b/examples/fx_eq_3band/src/bw_example_fx_eq_3band.c @@ -32,13 +32,13 @@ enum { p_ls_cutoff, p_ls_gain, - p_ls_slope, + p_ls_Q, p_peak_cutoff, p_peak_gain, p_peak_bw, p_hs_cutoff, p_hs_gain, - p_hs_slope, + p_hs_Q, p_n }; @@ -62,8 +62,6 @@ bw_example_fx_eq_3band bw_example_fx_eq_3band_new() { 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; } @@ -101,7 +99,8 @@ void bw_example_fx_eq_3band_set_parameter(bw_example_fx_eq_3band instance, int i case p_ls_gain: bw_ls2_set_dc_gain_dB(&instance->ls2_coeffs, -20.f + 40.f * value); break; - case p_ls_slope: + case p_ls_Q: + bw_ls2_set_Q(&instance->ls2_coeffs, 0.5f + 4.5f * value); break; case p_peak_cutoff: bw_peak_set_cutoff(&instance->peak_coeffs, 20.f + (20e3f - 20.f) * value * value * value); @@ -118,7 +117,8 @@ void bw_example_fx_eq_3band_set_parameter(bw_example_fx_eq_3band instance, int i case p_hs_gain: bw_hs2_set_high_gain_dB(&instance->hs2_coeffs, -20.f + 40.f * value); break; - case p_hs_slope: + case p_hs_Q: + bw_hs2_set_Q(&instance->hs2_coeffs, 0.5f + 4.5f * value); break; } } diff --git a/examples/fx_eq_3band/src/config.h b/examples/fx_eq_3band/src/config.h index 38acad5..eb090ea 100644 --- a/examples/fx_eq_3band/src/config.h +++ b/examples/fx_eq_3band/src/config.h @@ -71,13 +71,13 @@ static struct config_io_bus config_buses_out[NUM_BUSES_OUT] = { 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 }, + { "Low shelf Q", "LS Q", "", 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.8f }, { "High shelf gain", "HS gain", "dB", 0, 0, 0, 0.5f }, - { "High shelf slope", "HS slope", "", 0, 0, 0, 0.f } + { "High shelf Q", "HS Q", "", 0, 0, 0, 0.f } }; // Internal API diff --git a/examples/fx_eq_3band/web/config.js b/examples/fx_eq_3band/web/config.js index bbaac50..93db7f1 100644 --- a/examples/fx_eq_3band/web/config.js +++ b/examples/fx_eq_3band/web/config.js @@ -41,7 +41,7 @@ var parameters = [ defaultValue: 0.5 }, { - name: "Low shelf slope", + name: "Low shelf Q", output: false, defaultValue: 0.0 }, @@ -71,7 +71,7 @@ var parameters = [ defaultValue: 0.5 }, { - name: "High shelf slope", + name: "High shelf Q", output: false, defaultValue: 0.0 } diff --git a/examples/synth_mono/src/bw_example_synth_mono.c b/examples/synth_mono/src/bw_example_synth_mono.c index fca2f09..59d47e1 100644 --- a/examples/synth_mono/src/bw_example_synth_mono.c +++ b/examples/synth_mono/src/bw_example_synth_mono.c @@ -294,7 +294,8 @@ void bw_example_synth_mono_process(bw_example_synth_mono instance, const float** if (instance->params[p_noise_color] >= 0.5f) bw_pink_filt_process(&instance->pink_filt_coeffs, &instance->pink_filt_state, instance->buf[0], instance->buf[0], n); else - bw_pink_filt_reset_state(&instance->pink_filt_coeffs, &instance->pink_filt_state); + bw_pink_filt_reset_state(&instance->pink_filt_coeffs, &instance->pink_filt_state); // FIXME: calling this here is sloppy coding + bw_buf_scale(instance->buf[0], instance->buf[0], 5.f, n); for (int j = 0; j < n; j++) instance->buf[1][j] = instance->mod_wheel * (out[j] + instance->params[p_mod_mix] * (instance->buf[0][j] - out[j])); @@ -338,8 +339,8 @@ void bw_example_synth_mono_process(bw_example_synth_mono instance, const float** bw_osc_filt_process(&instance->osc_filt_state, out, out, n); const float k = instance->params[p_noise_color] >= 0.5f - ? 3.f * bw_noise_gen_get_scaling_k(&instance->noise_gen_coeffs) * bw_pink_filt_get_scaling_k(&instance->pink_filt_coeffs) - : 0.01f * bw_noise_gen_get_scaling_k(&instance->noise_gen_coeffs); + ? 6.f * bw_noise_gen_get_scaling_k(&instance->noise_gen_coeffs) * bw_pink_filt_get_scaling_k(&instance->pink_filt_coeffs) + : 0.1f * bw_noise_gen_get_scaling_k(&instance->noise_gen_coeffs); bw_buf_scale(instance->buf[0], instance->buf[0], k, n); bw_buf_mix(out, out, instance->buf[0], n); diff --git a/include/bw_hs2.h b/include/bw_hs2.h index 6d45960..70daaf1 100644 --- a/include/bw_hs2.h +++ b/include/bw_hs2.h @@ -26,12 +26,6 @@ * }}} * description {{{ * Second-order high shelf filter (12 dB/oct) with unitary DC gain. - * - * The quality factor can be either directly controlled via the Q parameter - * or indirectly through the slope parameter, which indicates the "shelf - * slope" as defined in the "Cookbook formulae for audio EQ biquad filter - * coefficients" by Robert Bristow-Johnson. The use_slope parameter allows - * you to choose which parameterization to use. * }}} * changelog {{{ *