From 6e2f5b1bce12f2eb4d5a47c1e13400bd0b280091 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Thu, 10 Aug 2023 10:17:22 +0200 Subject: [PATCH] now everything should work ok again --- TODO | 2 +- examples/synth_mono/src/bw_example_synth_mono.c | 12 ++++++------ examples/synth_poly/src/bw_example_synth_poly.c | 12 ++++++------ examples/synth_simple/src/bw_example_synth_simple.c | 2 +- .../synthpp_mono/src/bw_example_synthpp_mono.cpp | 12 ++++++------ .../synthpp_poly/src/bw_example_synthpp_poly.cpp | 12 ++++++------ .../synthpp_simple/src/bw_example_synthpp_simple.cpp | 2 +- include/bw_bd_reduce.h | 2 +- include/bw_clip.h | 2 +- include/bw_common.h | 6 +++--- include/bw_comp.h | 4 ++-- include/bw_gain.h | 2 +- include/bw_hs1.h | 4 ++-- include/bw_hs2.h | 6 +++--- include/bw_lp1.h | 2 +- include/bw_ls1.h | 4 ++-- include/bw_ls2.h | 6 +++--- include/bw_noise_gate.h | 4 ++-- include/bw_noise_gen.h | 2 +- include/bw_one_pole.h | 4 ++-- include/bw_osc_sin.h | 2 +- include/bw_pan.h | 4 ++-- include/bw_peak.h | 4 ++-- include/bw_phase_gen.h | 2 +- include/bw_phaser.h | 2 +- include/bw_pink_filt.h | 2 +- include/bw_ppm.h | 2 +- include/bw_satur.h | 6 +++--- include/bw_src.h | 2 +- include/bw_src_int.h | 2 +- include/bw_svf.h | 2 +- 31 files changed, 66 insertions(+), 66 deletions(-) diff --git a/TODO b/TODO index be5821e..54d2a85 100644 --- a/TODO +++ b/TODO @@ -28,7 +28,6 @@ code: * bw_math: review types * src inside distortions? w/ control from outside? * bw_fuzz gain compensation? -* remove union value = {.f = v};? (std c++ latest) - C++ compound literals... * make gain of distortions homogeneous? * max_delay -> set sample rate? see reverb * revise typedef style (see https://stackoverflow.com/questions/54752861/using-an-anonymous-struct-vs-a-named-struct-with-typedef) @@ -50,6 +49,7 @@ code: * voice alloc mode -> voice alloc priority * clearly specify that state is tied to a particular set of coeffs (1:N) * modulation vs process (multi) no update (post 1.0.0)??? +* check assumptions w.r.t. usage of math functions build system: * single header generation (vs modules in bwp... to think about) diff --git a/examples/synth_mono/src/bw_example_synth_mono.c b/examples/synth_mono/src/bw_example_synth_mono.c index 442c9a0..19e9577 100644 --- a/examples/synth_mono/src/bw_example_synth_mono.c +++ b/examples/synth_mono/src/bw_example_synth_mono.c @@ -133,15 +133,15 @@ void bw_example_synth_mono_process(bw_example_synth_mono *instance, const float* int n = instance->params[p_vco3_kbd] >= 0.5f ? instance->note : 0; bw_phase_gen_set_frequency(&instance->vco1_phase_gen_coeffs, 440.f * - bw_pow2f_3(6.f * instance->params[p_vco1_coarse] - 3.f + bw_pow2f(6.f * instance->params[p_vco1_coarse] - 3.f + 2.f * instance->pitch_bend - 1.f + 8.333333333333333e-2f * ((instance->note - 69) + 2.f * (instance->params[p_master_tune] + instance->params[p_vco1_fine]) - 2.f))); bw_phase_gen_set_frequency(&instance->vco2_phase_gen_coeffs, 440.f * - bw_pow2f_3(6.f * instance->params[p_vco2_coarse] - 3.f + bw_pow2f(6.f * instance->params[p_vco2_coarse] - 3.f + 2.f * instance->pitch_bend - 1.f + 8.333333333333333e-2f * ((instance->note - 69) + 2.f * (instance->params[p_master_tune] + instance->params[p_vco2_fine]) - 2.f))); bw_phase_gen_set_frequency(&instance->vco3_phase_gen_coeffs, 440.f * - bw_pow2f_3(6.f * instance->params[p_vco3_coarse] - 3.f + bw_pow2f(6.f * instance->params[p_vco3_coarse] - 3.f + 2.f * instance->pitch_bend - 1.f + 8.333333333333333e-2f * ((n - 69) + 2.f * (instance->params[p_master_tune] + instance->params[p_vco3_fine]) - 2.f))); @@ -220,11 +220,11 @@ void bw_example_synth_mono_process(bw_example_synth_mono *instance, const float* float v = instance->params[p_vcf_cutoff] + instance->params[p_vcf_contour] * bw_env_gen_get_y_z1(&instance->vcf_env_gen_state) + vcf_mod; float cutoff = 20.f + (20e3f - 20.f) * v * v * v; if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 2.f / 3.f)) - cutoff *= bw_pow2f_3(8.333333333333333e-2f * (instance->note - 60)); + cutoff *= bw_pow2f(8.333333333333333e-2f * (instance->note - 60)); else if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 1.f / 3.f)) - cutoff *= bw_pow2f_3((0.793700525984100f * 8.333333333333333e-2f) * (instance->note - 60)); + cutoff *= bw_pow2f((0.793700525984100f * 8.333333333333333e-2f) * (instance->note - 60)); else if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 2.f / 3.f)) - cutoff *= bw_pow2f_3((0.629960524947437f * 8.333333333333333e-2f) * (instance->note - 60)); + cutoff *= bw_pow2f((0.629960524947437f * 8.333333333333333e-2f) * (instance->note - 60)); // otherwise no kbd control bw_svf_set_cutoff(&instance->vcf_coeffs, bw_clipf(cutoff, 20.f, 20e3f)); bw_svf_process(&instance->vcf_coeffs, &instance->vcf_state, out, out, NULL, NULL, n); diff --git a/examples/synth_poly/src/bw_example_synth_poly.c b/examples/synth_poly/src/bw_example_synth_poly.c index 6f43428..68c8562 100644 --- a/examples/synth_poly/src/bw_example_synth_poly.c +++ b/examples/synth_poly/src/bw_example_synth_poly.c @@ -188,9 +188,9 @@ void bw_example_synth_poly_process(bw_example_synth_poly *instance, const float* + 8.333333333333333e-2f * (2.f * (instance->params[p_master_tune] + instance->params[p_vco3_fine]) - 71.f); for (int i = 0; i < N_VOICES; i++) { int n3 = instance->params[p_vco3_kbd] >= 0.5f ? instance->voices[i].note : 0; - bw_phase_gen_set_frequency(&instance->voices[i].vco1_phase_gen_coeffs, 440.f * bw_pow2f_3(df1 + 8.333333333333333e-2f * instance->voices[i].note)); - bw_phase_gen_set_frequency(&instance->voices[i].vco2_phase_gen_coeffs, 440.f * bw_pow2f_3(df2 + 8.333333333333333e-2f * instance->voices[i].note)); - bw_phase_gen_set_frequency(&instance->voices[i].vco3_phase_gen_coeffs, 440.f * bw_pow2f_3(df3 + 8.333333333333333e-2f * n3)); + bw_phase_gen_set_frequency(&instance->voices[i].vco1_phase_gen_coeffs, 440.f * bw_pow2f(df1 + 8.333333333333333e-2f * instance->voices[i].note)); + bw_phase_gen_set_frequency(&instance->voices[i].vco2_phase_gen_coeffs, 440.f * bw_pow2f(df2 + 8.333333333333333e-2f * instance->voices[i].note)); + bw_phase_gen_set_frequency(&instance->voices[i].vco3_phase_gen_coeffs, 440.f * bw_pow2f(df3 + 8.333333333333333e-2f * n3)); } const float vcf_mod_k = 0.3f * instance->params[p_vcf_mod]; @@ -298,11 +298,11 @@ void bw_example_synth_poly_process(bw_example_synth_poly *instance, const float* float v = instance->params[p_vcf_cutoff] + instance->params[p_vcf_contour] * bw_env_gen_get_y_z1(vcf_env_gen_states[j]) + vcf_mod[j]; float cutoff = 20.f + (20e3f - 20.f) * v * v * v; if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 2.f / 3.f)) - cutoff *= bw_pow2f_3(8.333333333333333e-2f * (instance->voices[j].note - 60)); + cutoff *= bw_pow2f(8.333333333333333e-2f * (instance->voices[j].note - 60)); else if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 1.f / 3.f)) - cutoff *= bw_pow2f_3((0.793700525984100f * 8.333333333333333e-2f) * (instance->voices[j].note - 60)); + cutoff *= bw_pow2f((0.793700525984100f * 8.333333333333333e-2f) * (instance->voices[j].note - 60)); else if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 2.f / 3.f)) - cutoff *= bw_pow2f_3((0.629960524947437f * 8.333333333333333e-2f) * (instance->voices[j].note - 60)); + cutoff *= bw_pow2f((0.629960524947437f * 8.333333333333333e-2f) * (instance->voices[j].note - 60)); // otherwise no kbd control bw_svf_set_cutoff(&instance->voices[j].vcf_coeffs, bw_clipf(cutoff, 20.f, 20e3f)); bw_svf_process(&instance->voices[j].vcf_coeffs, &instance->voices[j].vcf_state, b0[j], b0[j], NULL, NULL, n); diff --git a/examples/synth_simple/src/bw_example_synth_simple.c b/examples/synth_simple/src/bw_example_synth_simple.c index 3602463..aef0014 100644 --- a/examples/synth_simple/src/bw_example_synth_simple.c +++ b/examples/synth_simple/src/bw_example_synth_simple.c @@ -62,7 +62,7 @@ void bw_example_synth_simple_process(bw_example_synth_simple *instance, const fl if (instance->note >= 0) bw_phase_gen_set_frequency(&instance->phase_gen_coeffs, - 440.f * bw_pow2f_3(8.333333333333333e-2f * ((instance->note - 69) + 2.f * instance->params[p_master_tune] - 1.f))); + 440.f * bw_pow2f(8.333333333333333e-2f * ((instance->note - 69) + 2.f * instance->params[p_master_tune] - 1.f))); for (int i = 0; i < n_samples; i += BUFFER_SIZE) { float *out = y[0] + i; diff --git a/examples/synthpp_mono/src/bw_example_synthpp_mono.cpp b/examples/synthpp_mono/src/bw_example_synthpp_mono.cpp index aaed143..7392622 100644 --- a/examples/synthpp_mono/src/bw_example_synthpp_mono.cpp +++ b/examples/synthpp_mono/src/bw_example_synthpp_mono.cpp @@ -105,15 +105,15 @@ void bw_example_synthpp_mono_process(bw_example_synthpp_mono *instance, const fl int n = instance->params[p_vco3_kbd] >= 0.5f ? instance->note : 0; instance->vco1PhaseGen.setFrequency(440.f * - bw_pow2f_3(6.f * instance->params[p_vco1_coarse] - 3.f + bw_pow2f(6.f * instance->params[p_vco1_coarse] - 3.f + 2.f * instance->pitch_bend - 1.f + 8.333333333333333e-2f * ((instance->note - 69) + 2.f * (instance->params[p_master_tune] + instance->params[p_vco1_fine]) - 2.f))); instance->vco2PhaseGen.setFrequency(440.f * - bw_pow2f_3(6.f * instance->params[p_vco2_coarse] - 3.f + bw_pow2f(6.f * instance->params[p_vco2_coarse] - 3.f + 2.f * instance->pitch_bend - 1.f + 8.333333333333333e-2f * ((instance->note - 69) + 2.f * (instance->params[p_master_tune] + instance->params[p_vco2_fine]) - 2.f))); instance->vco3PhaseGen.setFrequency(440.f * - bw_pow2f_3(6.f * instance->params[p_vco3_coarse] - 3.f + bw_pow2f(6.f * instance->params[p_vco3_coarse] - 3.f + 2.f * instance->pitch_bend - 1.f + 8.333333333333333e-2f * ((n - 69) + 2.f * (instance->params[p_master_tune] + instance->params[p_vco3_fine]) - 2.f))); @@ -192,11 +192,11 @@ void bw_example_synthpp_mono_process(bw_example_synthpp_mono *instance, const fl float v = instance->params[p_vcf_cutoff] + instance->params[p_vcf_contour] * instance->vcfEnvGen.getYZ1(0) + vcf_mod; float cutoff = 20.f + (20e3f - 20.f) * v * v * v; if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 2.f / 3.f)) - cutoff *= bw_pow2f_3(8.333333333333333e-2f * (instance->note - 60)); + cutoff *= bw_pow2f(8.333333333333333e-2f * (instance->note - 60)); else if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 1.f / 3.f)) - cutoff *= bw_pow2f_3((0.793700525984100f * 8.333333333333333e-2f) * (instance->note - 60)); + cutoff *= bw_pow2f((0.793700525984100f * 8.333333333333333e-2f) * (instance->note - 60)); else if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 2.f / 3.f)) - cutoff *= bw_pow2f_3((0.629960524947437f * 8.333333333333333e-2f) * (instance->note - 60)); + cutoff *= bw_pow2f((0.629960524947437f * 8.333333333333333e-2f) * (instance->note - 60)); // otherwise no kbd control instance->vcf.setCutoff(bw_clipf(cutoff, 20.f, 20e3f)); instance->vcf.process({out}, {out}, {nullptr}, {nullptr}, n); diff --git a/examples/synthpp_poly/src/bw_example_synthpp_poly.cpp b/examples/synthpp_poly/src/bw_example_synthpp_poly.cpp index fd91dcf..a41cc22 100644 --- a/examples/synthpp_poly/src/bw_example_synthpp_poly.cpp +++ b/examples/synthpp_poly/src/bw_example_synthpp_poly.cpp @@ -160,9 +160,9 @@ void bw_example_synthpp_poly_process(bw_example_synthpp_poly *instance, const fl + 8.333333333333333e-2f * (2.f * (instance->params[p_master_tune] + instance->params[p_vco3_fine]) - 71.f); for (int i = 0; i < N_VOICES; i++) { int n3 = instance->params[p_vco3_kbd] >= 0.5f ? instance->voices[i].note : 0; - instance->voices[i].vco1PhaseGen.setFrequency(440.f * bw_pow2f_3(df1 + 8.333333333333333e-2f * instance->voices[i].note)); - instance->voices[i].vco2PhaseGen.setFrequency(440.f * bw_pow2f_3(df2 + 8.333333333333333e-2f * instance->voices[i].note)); - instance->voices[i].vco3PhaseGen.setFrequency(440.f * bw_pow2f_3(df3 + 8.333333333333333e-2f * n3)); + instance->voices[i].vco1PhaseGen.setFrequency(440.f * bw_pow2f(df1 + 8.333333333333333e-2f * instance->voices[i].note)); + instance->voices[i].vco2PhaseGen.setFrequency(440.f * bw_pow2f(df2 + 8.333333333333333e-2f * instance->voices[i].note)); + instance->voices[i].vco3PhaseGen.setFrequency(440.f * bw_pow2f(df3 + 8.333333333333333e-2f * n3)); } const float vcf_mod_k = 0.3f * instance->params[p_vcf_mod]; @@ -269,11 +269,11 @@ void bw_example_synthpp_poly_process(bw_example_synthpp_poly *instance, const fl float v = instance->params[p_vcf_cutoff] + instance->params[p_vcf_contour] * instance->vcfEnvGen.getYZ1(j) + vcf_mod[j]; float cutoff = 20.f + (20e3f - 20.f) * v * v * v; if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 2.f / 3.f)) - cutoff *= bw_pow2f_3(8.333333333333333e-2f * (instance->voices[j].note - 60)); + cutoff *= bw_pow2f(8.333333333333333e-2f * (instance->voices[j].note - 60)); else if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 1.f / 3.f)) - cutoff *= bw_pow2f_3((0.793700525984100f * 8.333333333333333e-2f) * (instance->voices[j].note - 60)); + cutoff *= bw_pow2f((0.793700525984100f * 8.333333333333333e-2f) * (instance->voices[j].note - 60)); else if (instance->params[p_vcf_kbd_ctrl] >= (1.f / 6.f + 2.f / 3.f)) - cutoff *= bw_pow2f_3((0.629960524947437f * 8.333333333333333e-2f) * (instance->voices[j].note - 60)); + cutoff *= bw_pow2f((0.629960524947437f * 8.333333333333333e-2f) * (instance->voices[j].note - 60)); // otherwise no kbd control instance->voices[j].vcf.setCutoff(bw_clipf(cutoff, 20.f, 20e3f)); instance->voices[j].vcf.process({b0.data()[j]}, {b0.data()[j]}, {nullptr}, {nullptr}, n); diff --git a/examples/synthpp_simple/src/bw_example_synthpp_simple.cpp b/examples/synthpp_simple/src/bw_example_synthpp_simple.cpp index 0de7ee8..93c708b 100644 --- a/examples/synthpp_simple/src/bw_example_synthpp_simple.cpp +++ b/examples/synthpp_simple/src/bw_example_synthpp_simple.cpp @@ -51,7 +51,7 @@ void bw_example_synthpp_simple_process(bw_example_synthpp_simple *instance, cons if (instance->note >= 0) instance->phaseGen.setFrequency( - 440.f * bw_pow2f_3(8.333333333333333e-2f * ((instance->note - 69) + 2.f * instance->params[p_master_tune] - 1.f))); + 440.f * bw_pow2f(8.333333333333333e-2f * ((instance->note - 69) + 2.f * instance->params[p_master_tune] - 1.f))); for (int i = 0; i < n_samples; i += BUFFER_SIZE) { float *out = y[0] + i; diff --git a/include/bw_bd_reduce.h b/include/bw_bd_reduce.h index 66ada52..568375a 100644 --- a/include/bw_bd_reduce.h +++ b/include/bw_bd_reduce.h @@ -163,7 +163,7 @@ static inline void bw_bd_reduce_reset_coeffs(bw_bd_reduce_coeffs *BW_RESTRICT co static inline void bw_bd_reduce_update_coeffs_ctrl(bw_bd_reduce_coeffs *BW_RESTRICT coeffs) { if (coeffs->bit_depth_prev != coeffs->bit_depth) { - coeffs->k = bw_pow2f_3(coeffs->bit_depth - 1); + coeffs->k = bw_pow2f(coeffs->bit_depth - 1); coeffs->ki = bw_rcpf(coeffs->k); coeffs->max = 1.f - 0.5f * coeffs->ki; coeffs->bit_depth_prev = coeffs->bit_depth; diff --git a/include/bw_clip.h b/include/bw_clip.h index 55d0a29..8762c16 100644 --- a/include/bw_clip.h +++ b/include/bw_clip.h @@ -254,7 +254,7 @@ static inline float bw_clip_process1(const bw_clip_coeffs *BW_RESTRICT coeffs, b const float a = bw_absf(x); const float F = a > 1.f ? a - 0.5f : 0.5f * a * a; const float d = x - state->x_z1; - const float y = d * d < 1e-6f ? bw_clipf(0.5f * (x + state->x_z1), -1.f, 1.f) : (F - state->F_z1) * bw_rcpf_2(d); + const float y = d * d < 1e-6f ? bw_clipf(0.5f * (x + state->x_z1), -1.f, 1.f) : (F - state->F_z1) * bw_rcpf(d); state->x_z1 = x; state->F_z1 = F; return y - coeffs->bias_dc; diff --git a/include/bw_common.h b/include/bw_common.h index e4e80e0..00de08d 100644 --- a/include/bw_common.h +++ b/include/bw_common.h @@ -250,19 +250,19 @@ static inline uint32_t bw_hash_sdbm(const char *string); * change at any time in future versions. Please, do not use it directly. */ static inline char bw_is_inf(float x) { - union {uint32_t u; float f;} v; + union { uint32_t u; float f; } v; v.f = x; return (v.u & 0x7fffffff) == 0x7f800000; } static inline char bw_is_nan(float x) { - union {uint32_t u; float f;} v; + union { uint32_t u; float f; } v; v.f = x; return ((v.u & 0x7f800000) == 0x7f800000) && (v.u & 0x7fffff); } static inline char bw_is_finite(float x) { - union {uint32_t u; float f;} v; + union { uint32_t u; float f; } v; v.f = x; return (v.u & 0x7f800000) != 0x7f800000; } diff --git a/include/bw_comp.h b/include/bw_comp.h index feb5447..6385b91 100644 --- a/include/bw_comp.h +++ b/include/bw_comp.h @@ -275,7 +275,7 @@ static inline void bw_comp_update_coeffs_audio(bw_comp_coeffs *BW_RESTRICT coeff static inline float bw_comp_process1(const bw_comp_coeffs *BW_RESTRICT coeffs, bw_comp_state *BW_RESTRICT state, float x, float x_sc) { const float env = bw_env_follow_process1(&coeffs->env_follow_coeffs, &state->env_follow_state, x_sc); const float thresh = bw_one_pole_get_y_z1(&coeffs->smooth_thresh_state); - const float y = env > thresh ? bw_pow2f_3(coeffs->kc * bw_log2f_3(thresh * bw_rcpf(env))) * x : x; + const float y = env > thresh ? bw_pow2f(coeffs->kc * bw_log2f(thresh * bw_rcpf(env))) * x : x; return bw_gain_process1(&coeffs->gain_coeffs, y); } @@ -301,7 +301,7 @@ static inline void bw_comp_set_thresh_lin(bw_comp_coeffs *BW_RESTRICT coeffs, fl } static inline void bw_comp_set_thresh_dBFS(bw_comp_coeffs *BW_RESTRICT coeffs, float value) { - coeffs->thresh = bw_dB2linf_3(value); + coeffs->thresh = bw_dB2linf(value); } static inline void bw_comp_set_ratio(bw_comp_coeffs *BW_RESTRICT coeffs, float value) { diff --git a/include/bw_gain.h b/include/bw_gain.h index e579e74..14868f7 100644 --- a/include/bw_gain.h +++ b/include/bw_gain.h @@ -245,7 +245,7 @@ static inline void bw_gain_set_gain_lin(bw_gain_coeffs *BW_RESTRICT coeffs, floa } static inline void bw_gain_set_gain_dB(bw_gain_coeffs *BW_RESTRICT coeffs, float value) { - coeffs->gain = bw_dB2linf_3(value); + coeffs->gain = bw_dB2linf(value); } static inline void bw_gain_set_smooth_tau(bw_gain_coeffs *BW_RESTRICT coeffs, float value) { diff --git a/include/bw_hs1.h b/include/bw_hs1.h index 82c6ef6..5e102ac 100644 --- a/include/bw_hs1.h +++ b/include/bw_hs1.h @@ -207,7 +207,7 @@ static inline void bw_hs1_set_sample_rate(bw_hs1_coeffs *BW_RESTRICT coeffs, flo static inline void _bw_hs1_update_mm1_params(bw_hs1_coeffs *BW_RESTRICT coeffs) { if (coeffs->update) { - bw_mm1_set_cutoff(&coeffs->mm1_coeffs, coeffs->cutoff * bw_sqrtf_2(coeffs->high_gain)); + bw_mm1_set_cutoff(&coeffs->mm1_coeffs, coeffs->cutoff * bw_sqrtf(coeffs->high_gain)); bw_mm1_set_coeff_x(&coeffs->mm1_coeffs, coeffs->high_gain); bw_mm1_set_coeff_lp(&coeffs->mm1_coeffs, 1.f - coeffs->high_gain); bw_mm1_set_prewarp_freq(&coeffs->mm1_coeffs, coeffs->cutoff); @@ -270,7 +270,7 @@ static inline void bw_hs1_set_high_gain_lin(bw_hs1_coeffs *BW_RESTRICT coeffs, f } static inline void bw_hs1_set_high_gain_dB(bw_hs1_coeffs *BW_RESTRICT coeffs, float value) { - bw_hs1_set_high_gain_lin(coeffs, bw_dB2linf_3(value)); + bw_hs1_set_high_gain_lin(coeffs, bw_dB2linf(value)); } #ifdef __cplusplus diff --git a/include/bw_hs2.h b/include/bw_hs2.h index dfde1b4..fcf9e3f 100644 --- a/include/bw_hs2.h +++ b/include/bw_hs2.h @@ -222,8 +222,8 @@ static inline void bw_hs2_set_sample_rate(bw_hs2_coeffs *BW_RESTRICT coeffs, flo 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_HIGH_GAIN) { - coeffs->sg = bw_sqrtf_2(coeffs->high_gain); - coeffs->ssg = bw_sqrtf_2(coeffs->sg); + coeffs->sg = bw_sqrtf(coeffs->high_gain); + coeffs->ssg = bw_sqrtf(coeffs->sg); bw_mm2_set_coeff_x(&coeffs->mm2_coeffs, coeffs->sg); bw_mm2_set_coeff_lp(&coeffs->mm2_coeffs, 1.f - coeffs->sg); bw_mm2_set_coeff_hp(&coeffs->mm2_coeffs, coeffs->high_gain - coeffs->sg); @@ -294,7 +294,7 @@ static inline void bw_hs2_set_high_gain_lin(bw_hs2_coeffs *BW_RESTRICT coeffs, f } static inline void bw_hs2_set_high_gain_dB(bw_hs2_coeffs *BW_RESTRICT coeffs, float value) { - bw_hs2_set_high_gain_lin(coeffs, bw_dB2linf_3(value)); + bw_hs2_set_high_gain_lin(coeffs, bw_dB2linf(value)); } #undef _BW_HS2_PARAM_HIGH_GAIN diff --git a/include/bw_lp1.h b/include/bw_lp1.h index 40da230..9c0e310 100644 --- a/include/bw_lp1.h +++ b/include/bw_lp1.h @@ -231,7 +231,7 @@ static inline void _bw_lp1_do_update_coeffs(bw_lp1_coeffs *BW_RESTRICT coeffs, c if (prewarp_freq_changed || cutoff_changed) { if (prewarp_freq_changed) { prewarp_freq_cur = bw_one_pole_process1_sticky_rel(&coeffs->smooth_coeffs, &coeffs->smooth_prewarp_freq_state, prewarp_freq); - coeffs->t = bw_tanf_3(coeffs->t_k * prewarp_freq_cur); + coeffs->t = bw_tanf(coeffs->t_k * prewarp_freq_cur); } if (cutoff_changed) { cutoff_cur = bw_one_pole_process1_sticky_rel(&coeffs->smooth_coeffs, &coeffs->smooth_cutoff_state, coeffs->cutoff); diff --git a/include/bw_ls1.h b/include/bw_ls1.h index 9c6116c..c2f8b0f 100644 --- a/include/bw_ls1.h +++ b/include/bw_ls1.h @@ -205,7 +205,7 @@ static inline void bw_ls1_set_sample_rate(bw_ls1_coeffs *BW_RESTRICT coeffs, flo static inline void _bw_ls1_update_mm1_params(bw_ls1_coeffs *BW_RESTRICT coeffs) { if (coeffs->update) { - bw_mm1_set_cutoff(&coeffs->mm1_coeffs, coeffs->cutoff * bw_rcpf(bw_sqrtf_2(coeffs->dc_gain))); + bw_mm1_set_cutoff(&coeffs->mm1_coeffs, coeffs->cutoff * bw_rcpf(bw_sqrtf(coeffs->dc_gain))); bw_mm1_set_coeff_lp(&coeffs->mm1_coeffs, coeffs->dc_gain - 1.f); bw_mm1_set_prewarp_freq(&coeffs->mm1_coeffs, coeffs->cutoff); coeffs->update = 0; @@ -267,7 +267,7 @@ static inline void bw_ls1_set_dc_gain_lin(bw_ls1_coeffs *BW_RESTRICT coeffs, flo } static inline void bw_ls1_set_dc_gain_dB(bw_ls1_coeffs *BW_RESTRICT coeffs, float value) { - bw_ls1_set_dc_gain_lin(coeffs, bw_dB2linf_3(value)); + bw_ls1_set_dc_gain_lin(coeffs, bw_dB2linf(value)); } #ifdef __cplusplus diff --git a/include/bw_ls2.h b/include/bw_ls2.h index fdc7aa8..1c49794 100644 --- a/include/bw_ls2.h +++ b/include/bw_ls2.h @@ -221,8 +221,8 @@ static inline void bw_ls2_set_sample_rate(bw_ls2_coeffs *BW_RESTRICT coeffs, flo 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) { - coeffs->sg = bw_sqrtf_2(coeffs->dc_gain); - coeffs->issg = bw_sqrtf_2(bw_rcpf(coeffs->sg)); + coeffs->sg = bw_sqrtf(coeffs->dc_gain); + coeffs->issg = bw_sqrtf(bw_rcpf(coeffs->sg)); bw_mm2_set_coeff_x(&coeffs->mm2_coeffs, coeffs->sg); bw_mm2_set_coeff_lp(&coeffs->mm2_coeffs, coeffs->dc_gain - coeffs->sg); bw_mm2_set_coeff_hp(&coeffs->mm2_coeffs, 1.f - coeffs->sg); @@ -293,7 +293,7 @@ static inline void bw_ls2_set_dc_gain_lin(bw_ls2_coeffs *BW_RESTRICT coeffs, flo } static inline void bw_ls2_set_dc_gain_dB(bw_ls2_coeffs *BW_RESTRICT coeffs, float value) { - bw_ls2_set_dc_gain_lin(coeffs, bw_dB2linf_3(value)); + bw_ls2_set_dc_gain_lin(coeffs, bw_dB2linf(value)); } #undef _BW_LS2_PARAM_DC_GAIN diff --git a/include/bw_noise_gate.h b/include/bw_noise_gate.h index b6d1377..c82337c 100644 --- a/include/bw_noise_gate.h +++ b/include/bw_noise_gate.h @@ -249,7 +249,7 @@ static inline void bw_noise_gate_update_coeffs_audio(bw_noise_gate_coeffs *BW_RE static inline float bw_noise_gate_process1(const bw_noise_gate_coeffs *BW_RESTRICT coeffs, bw_noise_gate_state *BW_RESTRICT state, float x, float x_sc) { const float env = bw_env_follow_process1(&coeffs->env_follow_coeffs, &state->env_follow_state, x_sc); const float thresh = bw_one_pole_get_y_z1(&coeffs->smooth_thresh_state); - return env < thresh ? bw_pow2f_3(coeffs->kc * bw_log2f_3(thresh * bw_rcpf(env))) * x : x; + return env < thresh ? bw_pow2f(coeffs->kc * bw_log2f(thresh * bw_rcpf(env))) * x : x; } static inline void bw_noise_gate_process(bw_noise_gate_coeffs *BW_RESTRICT coeffs, bw_noise_gate_state *BW_RESTRICT state, const float *x, const float *x_sc, float *y, int n_samples) { @@ -274,7 +274,7 @@ static inline void bw_noise_gate_set_thresh_lin(bw_noise_gate_coeffs *BW_RESTRIC } static inline void bw_noise_gate_set_thresh_dBFS(bw_noise_gate_coeffs *BW_RESTRICT coeffs, float value) { - coeffs->thresh = bw_dB2linf_3(value); + coeffs->thresh = bw_dB2linf(value); } static inline void bw_noise_gate_set_ratio(bw_noise_gate_coeffs *BW_RESTRICT coeffs, float value) { diff --git a/include/bw_noise_gen.h b/include/bw_noise_gen.h index a27d558..08c6d13 100644 --- a/include/bw_noise_gen.h +++ b/include/bw_noise_gen.h @@ -160,7 +160,7 @@ static inline void bw_noise_gen_init(bw_noise_gen_coeffs *BW_RESTRICT coeffs, ui } static inline void bw_noise_gen_set_sample_rate(bw_noise_gen_coeffs *BW_RESTRICT coeffs, float sample_rate) { - coeffs->scaling_k = 0.004761904761904762f * bw_sqrtf_2(sample_rate); + coeffs->scaling_k = 0.004761904761904762f * bw_sqrtf(sample_rate); } static inline float bw_noise_gen_process1(const bw_noise_gen_coeffs *BW_RESTRICT coeffs) { diff --git a/include/bw_one_pole.h b/include/bw_one_pole.h index c7778ba..85dbb87 100644 --- a/include/bw_one_pole.h +++ b/include/bw_one_pole.h @@ -408,10 +408,10 @@ static inline void bw_one_pole_set_sample_rate(bw_one_pole_coeffs *BW_RESTRICT c static inline void _bw_one_pole_do_update_coeffs_ctrl(bw_one_pole_coeffs *BW_RESTRICT coeffs) { if (coeffs->param_changed) { if (coeffs->param_changed & _BW_ONE_POLE_PARAM_CUTOFF_UP) - coeffs->mA1u = coeffs->cutoff_up > 1.591549430918953e8f ? 0.f : bw_expf_3(coeffs->Ttm2pi * coeffs->cutoff_up); + coeffs->mA1u = coeffs->cutoff_up > 1.591549430918953e8f ? 0.f : bw_expf(coeffs->Ttm2pi * coeffs->cutoff_up); // tau < 1 ns is instantaneous for any practical purpose if (coeffs->param_changed & _BW_ONE_POLE_PARAM_CUTOFF_DOWN) - coeffs->mA1d = coeffs->cutoff_down > 1.591549430918953e8f ? 0.f : bw_expf_3(coeffs->Ttm2pi * coeffs->cutoff_down); + coeffs->mA1d = coeffs->cutoff_down > 1.591549430918953e8f ? 0.f : bw_expf(coeffs->Ttm2pi * coeffs->cutoff_down); // as before if (coeffs->param_changed & _BW_ONE_POLE_PARAM_STICKY_THRESH) coeffs->st2 = coeffs->sticky_thresh * coeffs->sticky_thresh; diff --git a/include/bw_osc_sin.h b/include/bw_osc_sin.h index e5525ad..5535252 100644 --- a/include/bw_osc_sin.h +++ b/include/bw_osc_sin.h @@ -104,7 +104,7 @@ static inline void bw_osc_sin_process_multi(const float **x, float **y, int n_ch #include static inline float bw_osc_sin_process1(float x) { - return bw_sin2pif_3(x); + return bw_sin2pif(x); } static inline void bw_osc_sin_process(const float *x, float *y, int n_samples) { diff --git a/include/bw_pan.h b/include/bw_pan.h index 5cb1469..dece94e 100644 --- a/include/bw_pan.h +++ b/include/bw_pan.h @@ -168,8 +168,8 @@ static inline void bw_pan_set_sample_rate(bw_pan_coeffs *BW_RESTRICT coeffs, flo static inline void _bw_pan_do_update_coeffs(bw_pan_coeffs *BW_RESTRICT coeffs, char force) { if (force || coeffs->pan != coeffs->pan_prev) { const float k = 0.125f * coeffs->pan + 0.125f; - bw_gain_set_gain_lin(&coeffs->l_coeffs, bw_cos2pif_3(k)); - bw_gain_set_gain_lin(&coeffs->r_coeffs, bw_sin2pif_3(k)); + bw_gain_set_gain_lin(&coeffs->l_coeffs, bw_cos2pif(k)); + bw_gain_set_gain_lin(&coeffs->r_coeffs, bw_sin2pif(k)); coeffs->pan_prev = coeffs->pan; } } diff --git a/include/bw_peak.h b/include/bw_peak.h index 59790e1..a8d4fad 100644 --- a/include/bw_peak.h +++ b/include/bw_peak.h @@ -253,7 +253,7 @@ static inline void _bw_peak_update_mm2_params(bw_peak_coeffs *BW_RESTRICT coeffs 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) - coeffs->bw_k = bw_pow2f_3(coeffs->bandwidth); + coeffs->bw_k = bw_pow2f(coeffs->bandwidth); const float Q = bw_sqrtf_2(coeffs->bw_k * coeffs->peak_gain) * bw_rcpf(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(Q)); @@ -328,7 +328,7 @@ static inline void bw_peak_set_peak_gain_lin(bw_peak_coeffs *BW_RESTRICT coeffs, } static inline void bw_peak_set_peak_gain_dB(bw_peak_coeffs *BW_RESTRICT coeffs, float value) { - bw_peak_set_peak_gain_lin(coeffs, bw_dB2linf_3(value)); + bw_peak_set_peak_gain_lin(coeffs, bw_dB2linf(value)); } static inline void bw_peak_set_bandwidth(bw_peak_coeffs *BW_RESTRICT coeffs, float value) { diff --git a/include/bw_phase_gen.h b/include/bw_phase_gen.h index e3d4f48..f2a838b 100644 --- a/include/bw_phase_gen.h +++ b/include/bw_phase_gen.h @@ -264,7 +264,7 @@ static inline void bw_phase_gen_process1(const bw_phase_gen_coeffs *BW_RESTRICT } static inline void bw_phase_gen_process1_mod(const bw_phase_gen_coeffs *BW_RESTRICT coeffs, bw_phase_gen_state *BW_RESTRICT state, float x_mod, float *BW_RESTRICT y, float *BW_RESTRICT y_phase_inc) { - *y_phase_inc = bw_one_pole_get_y_z1(&coeffs->portamento_state) * bw_pow2f_3(x_mod); + *y_phase_inc = bw_one_pole_get_y_z1(&coeffs->portamento_state) * bw_pow2f(x_mod); *y = _bw_phase_gen_update_phase(state, *y_phase_inc); } diff --git a/include/bw_phaser.h b/include/bw_phaser.h index 1100134..49dddc2 100644 --- a/include/bw_phaser.h +++ b/include/bw_phaser.h @@ -228,7 +228,7 @@ static inline void bw_phaser_update_coeffs_audio(bw_phaser_coeffs *BW_RESTRICT c float p, pi; bw_phase_gen_process1(&coeffs->phase_gen_coeffs, &coeffs->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_set_cutoff(&coeffs->ap1_coeffs, bw_clipf(coeffs->center * bw_pow2f(m), 1.f, coeffs->cutoff_max)); bw_ap1_update_coeffs_ctrl(&coeffs->ap1_coeffs); bw_ap1_update_coeffs_audio(&coeffs->ap1_coeffs); } diff --git a/include/bw_pink_filt.h b/include/bw_pink_filt.h index a9f0d79..9ed5b5f 100644 --- a/include/bw_pink_filt.h +++ b/include/bw_pink_filt.h @@ -195,7 +195,7 @@ static inline void bw_pink_filt_init(bw_pink_filt_coeffs *BW_RESTRICT coeffs) { } static inline void bw_pink_filt_set_sample_rate(bw_pink_filt_coeffs *BW_RESTRICT coeffs, float sample_rate) { - coeffs->scaling_k = 210.f / bw_sqrtf_2(sample_rate); + coeffs->scaling_k = 210.f / bw_sqrtf(sample_rate); } static inline void bw_pink_filt_reset_state(const bw_pink_filt_coeffs *BW_RESTRICT coeffs, bw_pink_filt_state *BW_RESTRICT state) { diff --git a/include/bw_ppm.h b/include/bw_ppm.h index 9e396fb..83b1c36 100644 --- a/include/bw_ppm.h +++ b/include/bw_ppm.h @@ -208,7 +208,7 @@ static inline void bw_ppm_update_coeffs_audio(bw_ppm_coeffs *BW_RESTRICT coeffs) static inline float bw_ppm_process1(const bw_ppm_coeffs *BW_RESTRICT coeffs, bw_ppm_state *BW_RESTRICT state, float x) { const float yl = bw_env_follow_process1(&coeffs->env_follow_coeffs, &state->env_follow_state, x); - const float y = yl >= 1e-30f ? bw_lin2dBf_3(yl) : -INFINITY; // -600 dB is quiet enough + const float y = yl >= 1e-30f ? bw_lin2dBf(yl) : -INFINITY; // -600 dB is quiet enough state->y_z1 = y; return y; } diff --git a/include/bw_satur.h b/include/bw_satur.h index cb59440..07772e7 100644 --- a/include/bw_satur.h +++ b/include/bw_satur.h @@ -215,7 +215,7 @@ struct _bw_satur_state { float F_z1; }; -static inline float _bw_satur_tanhf_3(float x) { +static inline float _bw_satur_tanhf(float x) { const float xm = bw_clipf(x, -2.115287308554551f, 2.115287308554551f); const float axm = bw_absf(xm); return xm * axm * (0.01218073260037716f * axm - 0.2750231331124371f) + xm; @@ -239,7 +239,7 @@ static inline void _bw_satur_do_update_coeffs(bw_satur_coeffs *BW_RESTRICT coeff float bias_cur = bw_one_pole_get_y_z1(&coeffs->smooth_bias_state); if (force || coeffs->bias != bias_cur) { bias_cur = bw_one_pole_process1_sticky_abs(&coeffs->smooth_coeffs, &coeffs->smooth_bias_state, coeffs->bias); - coeffs->bias_dc = _bw_satur_tanhf_3(bias_cur); + coeffs->bias_dc = _bw_satur_tanhf(bias_cur); } float gain_cur = bw_one_pole_get_y_z1(&coeffs->smooth_gain_state); if (force || coeffs->gain != gain_cur) { @@ -273,7 +273,7 @@ static inline float bw_satur_process1(const bw_satur_coeffs *BW_RESTRICT coeffs, const float ax = bw_absf(x); const float F = ax >= 2.115287308554551f ? ax - 0.6847736211329452f : ax * ax * ((0.00304518315009429f * ax - 0.09167437770414569f) * ax + 0.5f); const float d = x - state->x_z1; - const float y = d * d < 1e-6f ? _bw_satur_tanhf_3(0.5f * (x + state->x_z1)) : (F - state->F_z1) * bw_rcpf(d); + const float y = d * d < 1e-6f ? _bw_satur_tanhf(0.5f * (x + state->x_z1)) : (F - state->F_z1) * bw_rcpf(d); state->x_z1 = x; state->F_z1 = F; return y - coeffs->bias_dc; diff --git a/include/bw_src.h b/include/bw_src.h index 3979302..cd84be1 100644 --- a/include/bw_src.h +++ b/include/bw_src.h @@ -152,7 +152,7 @@ static inline void bw_src_init(bw_src_coeffs *BW_RESTRICT coeffs, float ratio) { coeffs->k = ratio >= 1.f ? 1.f / ratio : -1.f / ratio; // 4th-degree Butterworth with cutoff at ratio * Nyquist, using bilinear transform w/ prewarping const float fc = bw_minf(ratio >= 1.f ? 1.f / ratio : ratio, 0.9f); - const float T = bw_tanf_3(1.570796326794896f * fc); + const float T = bw_tanf(1.570796326794896f * fc); const float T2 = T * T; const float k = 1.f / (T * (T * (T * (T + 2.613125929752753f) + 3.414213562373095f) + 2.613125929752753f) + 1.f); coeffs->b0 = k * T2 * T2; diff --git a/include/bw_src_int.h b/include/bw_src_int.h index 1203891..7630670 100644 --- a/include/bw_src_int.h +++ b/include/bw_src_int.h @@ -160,7 +160,7 @@ static inline void bw_src_int_init(bw_src_int_coeffs *BW_RESTRICT coeffs, int ra coeffs->ratio = ratio; // 4th-degree Butterworth with cutoff at ratio * Nyquist, using bilinear transform w/ prewarping const float fc = (float)(ratio >= 0 ? ratio : -ratio); - const float T = bw_tanf_3(1.570796326794896f / fc); + const float T = bw_tanf(1.570796326794896f / fc); const float T2 = T * T; const float k = 1.f / (T * (T * (T * (T + 2.613125929752753f) + 3.414213562373095f) + 2.613125929752753f) + 1.f); coeffs->b0 = k * T2 * T2; diff --git a/include/bw_svf.h b/include/bw_svf.h index d28e014..f0fe539 100644 --- a/include/bw_svf.h +++ b/include/bw_svf.h @@ -277,7 +277,7 @@ static inline void _bw_svf_do_update_coeffs(bw_svf_coeffs *BW_RESTRICT coeffs, c cutoff_cur = bw_one_pole_process1_sticky_rel(&coeffs->smooth_coeffs, &coeffs->smooth_cutoff_state, coeffs->cutoff); if (prewarp_freq_changed) { prewarp_freq_cur = bw_one_pole_process1_sticky_rel(&coeffs->smooth_coeffs, &coeffs->smooth_prewarp_freq_state, prewarp_freq); - coeffs->t = bw_tanf_3(coeffs->t_k * prewarp_freq_cur); + coeffs->t = bw_tanf(coeffs->t_k * prewarp_freq_cur); coeffs->kf = coeffs->t * bw_rcpf(prewarp_freq_cur); } coeffs->kbl = coeffs->kf * cutoff_cur;