now everything should work ok again

This commit is contained in:
Stefano D'Angelo 2023-08-10 10:17:22 +02:00
parent 08c8656259
commit 6e2f5b1bce
31 changed files with 66 additions and 66 deletions

2
TODO
View File

@ -28,7 +28,6 @@ code:
* bw_math: review types * bw_math: review types
* src inside distortions? w/ control from outside? * src inside distortions? w/ control from outside?
* bw_fuzz gain compensation? * bw_fuzz gain compensation?
* remove union value = {.f = v};? (std c++ latest) - C++ compound literals...
* make gain of distortions homogeneous? * make gain of distortions homogeneous?
* max_delay -> set sample rate? see reverb * 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) * 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 * voice alloc mode -> voice alloc priority
* clearly specify that state is tied to a particular set of coeffs (1:N) * clearly specify that state is tied to a particular set of coeffs (1:N)
* modulation vs process (multi) no update (post 1.0.0)??? * modulation vs process (multi) no update (post 1.0.0)???
* check assumptions w.r.t. usage of math functions
build system: build system:
* single header generation (vs modules in bwp... to think about) * single header generation (vs modules in bwp... to think about)

View File

@ -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; 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_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 + 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))); + 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_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 + 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))); + 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_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 + 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))); + 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 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; 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)) 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)) 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)) 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 // otherwise no kbd control
bw_svf_set_cutoff(&instance->vcf_coeffs, bw_clipf(cutoff, 20.f, 20e3f)); 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); bw_svf_process(&instance->vcf_coeffs, &instance->vcf_state, out, out, NULL, NULL, n);

View File

@ -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); + 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++) { for (int i = 0; i < N_VOICES; i++) {
int n3 = instance->params[p_vco3_kbd] >= 0.5f ? instance->voices[i].note : 0; 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].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_3(df2 + 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_3(df3 + 8.333333333333333e-2f * n3)); 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]; 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 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; 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)) 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)) 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)) 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 // otherwise no kbd control
bw_svf_set_cutoff(&instance->voices[j].vcf_coeffs, bw_clipf(cutoff, 20.f, 20e3f)); 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); bw_svf_process(&instance->voices[j].vcf_coeffs, &instance->voices[j].vcf_state, b0[j], b0[j], NULL, NULL, n);

View File

@ -62,7 +62,7 @@ void bw_example_synth_simple_process(bw_example_synth_simple *instance, const fl
if (instance->note >= 0) if (instance->note >= 0)
bw_phase_gen_set_frequency(&instance->phase_gen_coeffs, 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) { for (int i = 0; i < n_samples; i += BUFFER_SIZE) {
float *out = y[0] + i; float *out = y[0] + i;

View File

@ -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; int n = instance->params[p_vco3_kbd] >= 0.5f ? instance->note : 0;
instance->vco1PhaseGen.setFrequency(440.f * 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 + 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))); + 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 * 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 + 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))); + 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 * 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 + 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))); + 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 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; 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)) 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)) 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)) 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 // otherwise no kbd control
instance->vcf.setCutoff(bw_clipf(cutoff, 20.f, 20e3f)); instance->vcf.setCutoff(bw_clipf(cutoff, 20.f, 20e3f));
instance->vcf.process({out}, {out}, {nullptr}, {nullptr}, n); instance->vcf.process({out}, {out}, {nullptr}, {nullptr}, n);

View File

@ -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); + 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++) { for (int i = 0; i < N_VOICES; i++) {
int n3 = instance->params[p_vco3_kbd] >= 0.5f ? instance->voices[i].note : 0; 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].vco1PhaseGen.setFrequency(440.f * bw_pow2f(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].vco2PhaseGen.setFrequency(440.f * bw_pow2f(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].vco3PhaseGen.setFrequency(440.f * bw_pow2f(df3 + 8.333333333333333e-2f * n3));
} }
const float vcf_mod_k = 0.3f * instance->params[p_vcf_mod]; 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 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; 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)) 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)) 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)) 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 // otherwise no kbd control
instance->voices[j].vcf.setCutoff(bw_clipf(cutoff, 20.f, 20e3f)); 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); instance->voices[j].vcf.process({b0.data()[j]}, {b0.data()[j]}, {nullptr}, {nullptr}, n);

View File

@ -51,7 +51,7 @@ void bw_example_synthpp_simple_process(bw_example_synthpp_simple *instance, cons
if (instance->note >= 0) if (instance->note >= 0)
instance->phaseGen.setFrequency( 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) { for (int i = 0; i < n_samples; i += BUFFER_SIZE) {
float *out = y[0] + i; float *out = y[0] + i;

View File

@ -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) { static inline void bw_bd_reduce_update_coeffs_ctrl(bw_bd_reduce_coeffs *BW_RESTRICT coeffs) {
if (coeffs->bit_depth_prev != coeffs->bit_depth) { 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->ki = bw_rcpf(coeffs->k);
coeffs->max = 1.f - 0.5f * coeffs->ki; coeffs->max = 1.f - 0.5f * coeffs->ki;
coeffs->bit_depth_prev = coeffs->bit_depth; coeffs->bit_depth_prev = coeffs->bit_depth;

View File

@ -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 a = bw_absf(x);
const float F = a > 1.f ? a - 0.5f : 0.5f * a * a; const float F = a > 1.f ? a - 0.5f : 0.5f * a * a;
const float d = x - state->x_z1; 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->x_z1 = x;
state->F_z1 = F; state->F_z1 = F;
return y - coeffs->bias_dc; return y - coeffs->bias_dc;

View File

@ -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. */ * change at any time in future versions. Please, do not use it directly. */
static inline char bw_is_inf(float x) { 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; v.f = x;
return (v.u & 0x7fffffff) == 0x7f800000; return (v.u & 0x7fffffff) == 0x7f800000;
} }
static inline char bw_is_nan(float x) { 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; v.f = x;
return ((v.u & 0x7f800000) == 0x7f800000) && (v.u & 0x7fffff); return ((v.u & 0x7f800000) == 0x7f800000) && (v.u & 0x7fffff);
} }
static inline char bw_is_finite(float x) { 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; v.f = x;
return (v.u & 0x7f800000) != 0x7f800000; return (v.u & 0x7f800000) != 0x7f800000;
} }

View File

@ -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) { 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 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 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); 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) { 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) { static inline void bw_comp_set_ratio(bw_comp_coeffs *BW_RESTRICT coeffs, float value) {

View File

@ -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) { 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) { static inline void bw_gain_set_smooth_tau(bw_gain_coeffs *BW_RESTRICT coeffs, float value) {

View File

@ -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) { static inline void _bw_hs1_update_mm1_params(bw_hs1_coeffs *BW_RESTRICT coeffs) {
if (coeffs->update) { 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_x(&coeffs->mm1_coeffs, coeffs->high_gain);
bw_mm1_set_coeff_lp(&coeffs->mm1_coeffs, 1.f - 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); 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) { 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 #ifdef __cplusplus

View File

@ -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) { static inline void _bw_hs2_update_mm2_params(bw_hs2_coeffs *BW_RESTRICT coeffs) {
if (coeffs->param_changed) { if (coeffs->param_changed) {
if (coeffs->param_changed & _BW_HS2_PARAM_HIGH_GAIN) { if (coeffs->param_changed & _BW_HS2_PARAM_HIGH_GAIN) {
coeffs->sg = bw_sqrtf_2(coeffs->high_gain); coeffs->sg = bw_sqrtf(coeffs->high_gain);
coeffs->ssg = bw_sqrtf_2(coeffs->sg); coeffs->ssg = bw_sqrtf(coeffs->sg);
bw_mm2_set_coeff_x(&coeffs->mm2_coeffs, 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_lp(&coeffs->mm2_coeffs, 1.f - coeffs->sg);
bw_mm2_set_coeff_hp(&coeffs->mm2_coeffs, coeffs->high_gain - 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) { 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 #undef _BW_HS2_PARAM_HIGH_GAIN

View File

@ -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 || cutoff_changed) {
if (prewarp_freq_changed) { if (prewarp_freq_changed) {
prewarp_freq_cur = bw_one_pole_process1_sticky_rel(&coeffs->smooth_coeffs, &coeffs->smooth_prewarp_freq_state, prewarp_freq); 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) { if (cutoff_changed) {
cutoff_cur = bw_one_pole_process1_sticky_rel(&coeffs->smooth_coeffs, &coeffs->smooth_cutoff_state, coeffs->cutoff); cutoff_cur = bw_one_pole_process1_sticky_rel(&coeffs->smooth_coeffs, &coeffs->smooth_cutoff_state, coeffs->cutoff);

View File

@ -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) { static inline void _bw_ls1_update_mm1_params(bw_ls1_coeffs *BW_RESTRICT coeffs) {
if (coeffs->update) { 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_coeff_lp(&coeffs->mm1_coeffs, coeffs->dc_gain - 1.f);
bw_mm1_set_prewarp_freq(&coeffs->mm1_coeffs, coeffs->cutoff); bw_mm1_set_prewarp_freq(&coeffs->mm1_coeffs, coeffs->cutoff);
coeffs->update = 0; 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) { 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 #ifdef __cplusplus

View File

@ -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) { static inline void _bw_ls2_update_mm2_params(bw_ls2_coeffs *BW_RESTRICT coeffs) {
if (coeffs->param_changed) { if (coeffs->param_changed) {
if (coeffs->param_changed & _BW_LS2_PARAM_DC_GAIN) { if (coeffs->param_changed & _BW_LS2_PARAM_DC_GAIN) {
coeffs->sg = bw_sqrtf_2(coeffs->dc_gain); coeffs->sg = bw_sqrtf(coeffs->dc_gain);
coeffs->issg = bw_sqrtf_2(bw_rcpf(coeffs->sg)); coeffs->issg = bw_sqrtf(bw_rcpf(coeffs->sg));
bw_mm2_set_coeff_x(&coeffs->mm2_coeffs, 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_lp(&coeffs->mm2_coeffs, coeffs->dc_gain - coeffs->sg);
bw_mm2_set_coeff_hp(&coeffs->mm2_coeffs, 1.f - 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) { 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 #undef _BW_LS2_PARAM_DC_GAIN

View File

@ -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) { 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 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 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) { 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) { 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) { static inline void bw_noise_gate_set_ratio(bw_noise_gate_coeffs *BW_RESTRICT coeffs, float value) {

View File

@ -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) { 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) { static inline float bw_noise_gen_process1(const bw_noise_gen_coeffs *BW_RESTRICT coeffs) {

View File

@ -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) { 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) {
if (coeffs->param_changed & _BW_ONE_POLE_PARAM_CUTOFF_UP) 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 // tau < 1 ns is instantaneous for any practical purpose
if (coeffs->param_changed & _BW_ONE_POLE_PARAM_CUTOFF_DOWN) 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 // as before
if (coeffs->param_changed & _BW_ONE_POLE_PARAM_STICKY_THRESH) if (coeffs->param_changed & _BW_ONE_POLE_PARAM_STICKY_THRESH)
coeffs->st2 = coeffs->sticky_thresh * coeffs->sticky_thresh; coeffs->st2 = coeffs->sticky_thresh * coeffs->sticky_thresh;

View File

@ -104,7 +104,7 @@ static inline void bw_osc_sin_process_multi(const float **x, float **y, int n_ch
#include <bw_math.h> #include <bw_math.h>
static inline float bw_osc_sin_process1(float x) { 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) { static inline void bw_osc_sin_process(const float *x, float *y, int n_samples) {

View File

@ -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) { static inline void _bw_pan_do_update_coeffs(bw_pan_coeffs *BW_RESTRICT coeffs, char force) {
if (force || coeffs->pan != coeffs->pan_prev) { if (force || coeffs->pan != coeffs->pan_prev) {
const float k = 0.125f * coeffs->pan + 0.125f; 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->l_coeffs, bw_cos2pif(k));
bw_gain_set_gain_lin(&coeffs->r_coeffs, bw_sin2pif_3(k)); bw_gain_set_gain_lin(&coeffs->r_coeffs, bw_sin2pif(k));
coeffs->pan_prev = coeffs->pan; coeffs->pan_prev = coeffs->pan;
} }
} }

View File

@ -253,7 +253,7 @@ static inline void _bw_peak_update_mm2_params(bw_peak_coeffs *BW_RESTRICT coeffs
if (coeffs->use_bandwidth) { if (coeffs->use_bandwidth) {
if (coeffs->param_changed & (_BW_PEAK_PARAM_PEAK_GAIN | _BW_PEAK_PARAM_BANDWIDTH)) { if (coeffs->param_changed & (_BW_PEAK_PARAM_PEAK_GAIN | _BW_PEAK_PARAM_BANDWIDTH)) {
if (coeffs->param_changed & _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); 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_Q(&coeffs->mm2_coeffs, Q);
bw_mm2_set_coeff_bp(&coeffs->mm2_coeffs, (coeffs->peak_gain - 1.f) * bw_rcpf(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) { 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) { static inline void bw_peak_set_bandwidth(bw_peak_coeffs *BW_RESTRICT coeffs, float value) {

View File

@ -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) { 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); *y = _bw_phase_gen_update_phase(state, *y_phase_inc);
} }

View File

@ -228,7 +228,7 @@ static inline void bw_phaser_update_coeffs_audio(bw_phaser_coeffs *BW_RESTRICT c
float p, pi; float p, pi;
bw_phase_gen_process1(&coeffs->phase_gen_coeffs, &coeffs->phase_gen_state, &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); 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_ctrl(&coeffs->ap1_coeffs);
bw_ap1_update_coeffs_audio(&coeffs->ap1_coeffs); bw_ap1_update_coeffs_audio(&coeffs->ap1_coeffs);
} }

View File

@ -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) { 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) { static inline void bw_pink_filt_reset_state(const bw_pink_filt_coeffs *BW_RESTRICT coeffs, bw_pink_filt_state *BW_RESTRICT state) {

View File

@ -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) { 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 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; state->y_z1 = y;
return y; return y;
} }

View File

@ -215,7 +215,7 @@ struct _bw_satur_state {
float F_z1; 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 xm = bw_clipf(x, -2.115287308554551f, 2.115287308554551f);
const float axm = bw_absf(xm); const float axm = bw_absf(xm);
return xm * axm * (0.01218073260037716f * axm - 0.2750231331124371f) + 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); float bias_cur = bw_one_pole_get_y_z1(&coeffs->smooth_bias_state);
if (force || coeffs->bias != bias_cur) { if (force || coeffs->bias != bias_cur) {
bias_cur = bw_one_pole_process1_sticky_abs(&coeffs->smooth_coeffs, &coeffs->smooth_bias_state, coeffs->bias); 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); float gain_cur = bw_one_pole_get_y_z1(&coeffs->smooth_gain_state);
if (force || coeffs->gain != gain_cur) { 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 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 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 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->x_z1 = x;
state->F_z1 = F; state->F_z1 = F;
return y - coeffs->bias_dc; return y - coeffs->bias_dc;

View File

@ -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; coeffs->k = ratio >= 1.f ? 1.f / ratio : -1.f / ratio;
// 4th-degree Butterworth with cutoff at ratio * Nyquist, using bilinear transform w/ prewarping // 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 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 T2 = T * T;
const float k = 1.f / (T * (T * (T * (T + 2.613125929752753f) + 3.414213562373095f) + 2.613125929752753f) + 1.f); const float k = 1.f / (T * (T * (T * (T + 2.613125929752753f) + 3.414213562373095f) + 2.613125929752753f) + 1.f);
coeffs->b0 = k * T2 * T2; coeffs->b0 = k * T2 * T2;

View File

@ -160,7 +160,7 @@ static inline void bw_src_int_init(bw_src_int_coeffs *BW_RESTRICT coeffs, int ra
coeffs->ratio = ratio; coeffs->ratio = ratio;
// 4th-degree Butterworth with cutoff at ratio * Nyquist, using bilinear transform w/ prewarping // 4th-degree Butterworth with cutoff at ratio * Nyquist, using bilinear transform w/ prewarping
const float fc = (float)(ratio >= 0 ? ratio : -ratio); 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 T2 = T * T;
const float k = 1.f / (T * (T * (T * (T + 2.613125929752753f) + 3.414213562373095f) + 2.613125929752753f) + 1.f); const float k = 1.f / (T * (T * (T * (T + 2.613125929752753f) + 3.414213562373095f) + 2.613125929752753f) + 1.f);
coeffs->b0 = k * T2 * T2; coeffs->b0 = k * T2 * T2;

View File

@ -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); cutoff_cur = bw_one_pole_process1_sticky_rel(&coeffs->smooth_coeffs, &coeffs->smooth_cutoff_state, coeffs->cutoff);
if (prewarp_freq_changed) { if (prewarp_freq_changed) {
prewarp_freq_cur = bw_one_pole_process1_sticky_rel(&coeffs->smooth_coeffs, &coeffs->smooth_prewarp_freq_state, prewarp_freq); 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->kf = coeffs->t * bw_rcpf(prewarp_freq_cur);
} }
coeffs->kbl = coeffs->kf * cutoff_cur; coeffs->kbl = coeffs->kf * cutoff_cur;