From 52d33fa3c5016fa5e485150ef18ea171f3eca379 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Thu, 21 Sep 2023 07:59:41 +0200 Subject: [PATCH] finalized bw_noise_gen + updated synth(pp)_mono + better bw_gain debug --- TODO | 4 +- .../synth_mono/src/bw_example_synth_mono.c | 2 + .../src/bw_example_synthpp_mono.cpp | 2 + include/bw_gain.h | 1 + include/bw_noise_gen.h | 302 +++++++++++++++--- 5 files changed, 270 insertions(+), 41 deletions(-) diff --git a/TODO b/TODO index bed6c55..df95d75 100644 --- a/TODO +++ b/TODO @@ -4,7 +4,7 @@ in progress: * add initial state (x0) to reset state of all modules * check assumptions w.r.t. usage of math functions -* empty functions etc. to keep consistency and forward compatibility? +* empty functions etc. to keep consistency and forward compatibility * format declarations in a more readable way code: general: @@ -13,8 +13,6 @@ code: * common smoothing policy (as control rate as possible?) - smoothing control? * IMPLEMENTATION prepocessor def??? semi-specific: -* osc post filter (and one pole init, slew rate, etc.) val from input? set state instead? -* audio rate optional pulse width/slope inputs? * max_delay -> set sample rate? see reverb specific: * bw_comb: should also modulate feedback? diff --git a/examples/synth_mono/src/bw_example_synth_mono.c b/examples/synth_mono/src/bw_example_synth_mono.c index 929cebb..7546839 100644 --- a/examples/synth_mono/src/bw_example_synth_mono.c +++ b/examples/synth_mono/src/bw_example_synth_mono.c @@ -53,6 +53,7 @@ void bw_example_synth_mono_init(bw_example_synth_mono *instance) { bw_osc_tri_set_antialiasing(&instance->vco2_tri_coeffs, 1); bw_osc_pulse_set_antialiasing(&instance->vco3_pulse_coeffs, 1); bw_osc_tri_set_antialiasing(&instance->vco3_tri_coeffs, 1); + bw_noise_gen_set_sample_rate_scaling(&instance->noise_gen_coeffs, 1); bw_phase_gen_set_frequency(&instance->a440_phase_gen_coeffs, 440.f); instance->rand_state = 0xbaddecaf600dfeed; @@ -83,6 +84,7 @@ void bw_example_synth_mono_set_sample_rate(bw_example_synth_mono *instance, floa bw_ppm_set_sample_rate(&instance->ppm_coeffs, sample_rate); bw_osc_saw_reset_coeffs(&instance->vco_saw_coeffs); + bw_noise_gen_reset_coeffs(&instance->noise_gen_coeffs); } void bw_example_synth_mono_reset(bw_example_synth_mono *instance) { diff --git a/examples/synthpp_mono/src/bw_example_synthpp_mono.cpp b/examples/synthpp_mono/src/bw_example_synthpp_mono.cpp index bbc8ed9..4d8c686 100644 --- a/examples/synthpp_mono/src/bw_example_synthpp_mono.cpp +++ b/examples/synthpp_mono/src/bw_example_synthpp_mono.cpp @@ -33,6 +33,7 @@ void bw_example_synthpp_mono_init(bw_example_synthpp_mono *instance) { instance->vco3OscSaw.setAntialiasing(true); instance->vco3OscPulse.setAntialiasing(true); instance->vco3OscTri.setAntialiasing(true); + instance->noiseGen.setSampleRateScaling(true); instance->a440PhaseGen.setFrequency(440.f); instance->rand_state = 0xbaddecaf600dfeed; @@ -86,6 +87,7 @@ void bw_example_synthpp_mono_reset(bw_example_synthpp_mono *instance) { instance->vco3OscTri.reset(); instance->vco3Gain.reset(); instance->oscFilt.reset(); + instance->noiseGen.reset(); instance->pinkFilt.reset(); instance->noiseGain.reset(); instance->vcfEnvGen.reset(); diff --git a/include/bw_gain.h b/include/bw_gain.h index 462b9d2..cf04e0f 100644 --- a/include/bw_gain.h +++ b/include/bw_gain.h @@ -461,6 +461,7 @@ static inline float bw_gain_get_gain_cur( const bw_gain_coeffs * BW_RESTRICT coeffs) { BW_ASSERT(coeffs != NULL); BW_ASSERT_DEEP(bw_gain_coeffs_is_valid(coeffs)); + BW_ASSERT_DEEP(coeffs->state >= bw_gain_coeffs_state_reset_coeffs); return bw_one_pole_get_y_z1(&coeffs->smooth_state); } diff --git a/include/bw_noise_gen.h b/include/bw_noise_gen.h index 0c12201..ecf7807 100644 --- a/include/bw_noise_gen.h +++ b/include/bw_noise_gen.h @@ -33,6 +33,9 @@ *