updated synth examples

This commit is contained in:
Stefano D'Angelo 2023-09-23 07:21:55 +02:00
parent d890510d0f
commit 2bad45aabb
6 changed files with 35 additions and 14 deletions

1
TODO
View File

@ -1,7 +1,6 @@
1.0.0 1.0.0
----- -----
* synth(pp)_poly
* IMPLEMENTATION prepocessor def??? * IMPLEMENTATION prepocessor def???
* debugging - also check outputs different (incl bw_buf) * debugging - also check outputs different (incl bw_buf)
* check all examples again * check all examples again

View File

@ -64,6 +64,7 @@ void bw_example_synth_poly_init(bw_example_synth_poly *instance) {
} }
void bw_example_synth_poly_set_sample_rate(bw_example_synth_poly *instance, float sample_rate) { void bw_example_synth_poly_set_sample_rate(bw_example_synth_poly *instance, float sample_rate) {
bw_osc_saw_set_sample_rate(&instance->vco_saw_coeffs, sample_rate);
bw_osc_pulse_set_sample_rate(&instance->vco1_pulse_coeffs, sample_rate); bw_osc_pulse_set_sample_rate(&instance->vco1_pulse_coeffs, sample_rate);
bw_osc_tri_set_sample_rate(&instance->vco1_tri_coeffs, sample_rate); bw_osc_tri_set_sample_rate(&instance->vco1_tri_coeffs, sample_rate);
bw_gain_set_sample_rate(&instance->vco1_gain_coeffs, sample_rate); bw_gain_set_sample_rate(&instance->vco1_gain_coeffs, sample_rate);
@ -97,6 +98,7 @@ void bw_example_synth_poly_reset(bw_example_synth_poly *instance) {
bw_svf_set_cutoff(&instance->voices[i].vcf_coeffs, bw_clipf(cutoff, 20.f, 20e3f)); bw_svf_set_cutoff(&instance->voices[i].vcf_coeffs, bw_clipf(cutoff, 20.f, 20e3f));
bw_note_queue_reset(&instance->note_queue); bw_note_queue_reset(&instance->note_queue);
bw_osc_saw_reset_coeffs(&instance->vco_saw_coeffs);
bw_osc_pulse_reset_coeffs(&instance->vco1_pulse_coeffs); bw_osc_pulse_reset_coeffs(&instance->vco1_pulse_coeffs);
bw_osc_tri_reset_coeffs(&instance->vco1_tri_coeffs); bw_osc_tri_reset_coeffs(&instance->vco1_tri_coeffs);
bw_gain_reset_coeffs(&instance->vco1_gain_coeffs); bw_gain_reset_coeffs(&instance->vco1_gain_coeffs);
@ -106,29 +108,35 @@ void bw_example_synth_poly_reset(bw_example_synth_poly *instance) {
bw_osc_pulse_reset_coeffs(&instance->vco3_pulse_coeffs); bw_osc_pulse_reset_coeffs(&instance->vco3_pulse_coeffs);
bw_osc_tri_reset_coeffs(&instance->vco3_tri_coeffs); bw_osc_tri_reset_coeffs(&instance->vco3_tri_coeffs);
bw_gain_reset_coeffs(&instance->vco3_gain_coeffs); bw_gain_reset_coeffs(&instance->vco3_gain_coeffs);
bw_noise_gen_reset_coeffs(&instance->noise_gen_coeffs);
bw_pink_filt_reset_coeffs(&instance->pink_filt_coeffs);
bw_gain_reset_coeffs(&instance->noise_gain_coeffs); bw_gain_reset_coeffs(&instance->noise_gain_coeffs);
bw_env_gen_reset_coeffs(&instance->vcf_env_gen_coeffs); bw_env_gen_reset_coeffs(&instance->vcf_env_gen_coeffs);
bw_env_gen_reset_coeffs(&instance->vca_env_gen_coeffs); bw_env_gen_reset_coeffs(&instance->vca_env_gen_coeffs);
bw_phase_gen_reset_coeffs(&instance->a440_phase_gen_coeffs); bw_phase_gen_reset_coeffs(&instance->a440_phase_gen_coeffs);
bw_phase_gen_reset_state(&instance->a440_phase_gen_coeffs, &instance->a440_phase_gen_state, 0.f); float p, pi;
bw_phase_gen_reset_state(&instance->a440_phase_gen_coeffs, &instance->a440_phase_gen_state, 0.f, &p, &pi);
bw_gain_reset_coeffs(&instance->gain_coeffs); bw_gain_reset_coeffs(&instance->gain_coeffs);
bw_ppm_reset_coeffs(&instance->ppm_coeffs); bw_ppm_reset_coeffs(&instance->ppm_coeffs);
bw_ppm_reset_state(&instance->ppm_coeffs, &instance->ppm_state); bw_ppm_reset_state(&instance->ppm_coeffs, &instance->ppm_state, 0.f);
for (int i = 0; i < N_VOICES; i++) { for (int i = 0; i < N_VOICES; i++) {
bw_phase_gen_reset_coeffs(&instance->voices[i].vco1_phase_gen_coeffs);
bw_phase_gen_reset_coeffs(&instance->voices[i].vco2_phase_gen_coeffs); bw_phase_gen_reset_coeffs(&instance->voices[i].vco2_phase_gen_coeffs);
bw_phase_gen_reset_coeffs(&instance->voices[i].vco3_phase_gen_coeffs); bw_phase_gen_reset_coeffs(&instance->voices[i].vco3_phase_gen_coeffs);
bw_svf_reset_coeffs(&instance->voices[i].vcf_coeffs); bw_svf_reset_coeffs(&instance->voices[i].vcf_coeffs);
bw_phase_gen_reset_state(&instance->voices[i].vco1_phase_gen_coeffs, &instance->voices[i].vco1_phase_gen_state, 0.f); bw_phase_gen_reset_state(&instance->voices[i].vco1_phase_gen_coeffs, &instance->voices[i].vco1_phase_gen_state, 0.f, &p, &pi);
bw_phase_gen_reset_state(&instance->voices[i].vco2_phase_gen_coeffs, &instance->voices[i].vco2_phase_gen_state, 0.f); bw_phase_gen_reset_state(&instance->voices[i].vco2_phase_gen_coeffs, &instance->voices[i].vco2_phase_gen_state, 0.f, &p, &pi);
bw_phase_gen_reset_state(&instance->voices[i].vco3_phase_gen_coeffs, &instance->voices[i].vco3_phase_gen_state, 0.f); bw_phase_gen_reset_state(&instance->voices[i].vco3_phase_gen_coeffs, &instance->voices[i].vco3_phase_gen_state, 0.f, &p, &pi);
bw_osc_filt_reset_state(&instance->voices[i].osc_filt_state); bw_osc_filt_reset_state(&instance->voices[i].osc_filt_state, 0.f);
bw_pink_filt_reset_state(&instance->pink_filt_coeffs, &instance->voices[i].pink_filt_state); bw_pink_filt_reset_state(&instance->pink_filt_coeffs, &instance->voices[i].pink_filt_state, 0.f);
bw_svf_reset_state(&instance->voices[i].vcf_coeffs, &instance->voices[i].vcf_state, 0.f); float lp, bp, hp;
bw_env_gen_reset_state(&instance->vcf_env_gen_coeffs, &instance->voices[i].vcf_env_gen_state); bw_svf_reset_state(&instance->voices[i].vcf_coeffs, &instance->voices[i].vcf_state, 0.f, &lp, &bp, &hp);
bw_env_gen_reset_state(&instance->vca_env_gen_coeffs, &instance->voices[i].vca_env_gen_state); bw_env_gen_reset_state(&instance->vcf_env_gen_coeffs, &instance->voices[i].vcf_env_gen_state, 0.f);
bw_env_gen_reset_state(&instance->vca_env_gen_coeffs, &instance->voices[i].vca_env_gen_state, 0.f);
instance->voices[i].note = 69;
instance->voices[i].gate = 0; instance->voices[i].gate = 0;
} }
@ -236,7 +244,7 @@ void bw_example_synth_poly_process(bw_example_synth_poly *instance, const float*
bw_pink_filt_process_multi(&instance->pink_filt_coeffs, pink_filt_states, (const float **)b1, b1, N_VOICES, n); bw_pink_filt_process_multi(&instance->pink_filt_coeffs, pink_filt_states, (const float **)b1, b1, N_VOICES, n);
else else
for (int j = 0; j < N_VOICES; j++) for (int j = 0; j < N_VOICES; j++)
bw_pink_filt_reset_state(&instance->pink_filt_coeffs, pink_filt_states[j]); // FIXME: calling this here is sloppy coding bw_pink_filt_reset_state(&instance->pink_filt_coeffs, pink_filt_states[j], 0.f); // FIXME: calling this here is sloppy coding
bw_buf_scale_multi((const float * const *)b1, 5.f, b1, N_VOICES, n); bw_buf_scale_multi((const float * const *)b1, 5.f, b1, N_VOICES, n);
float vcf_mod[N_VOICES]; float vcf_mod[N_VOICES];

View File

@ -4,3 +4,6 @@ NAME := bw_example_synth_poly
SOURCE := bw_example_synth_poly.c SOURCE := bw_example_synth_poly.c
include ${ROOT_DIR}/../../common/vst3/vst3.mk include ${ROOT_DIR}/../../common/vst3/vst3.mk
CXXFLAGS += -DRELEASE=1 -DNDEBUG -DBW_NO_DEBUG
#CXXFLAGS += -DDEVELOPMENT=1 -DBW_DEBUG_DEEP

View File

@ -47,7 +47,7 @@ void bw_example_synth_simple_reset(bw_example_synth_simple *instance) {
float p, inc; float p, inc;
bw_phase_gen_reset_state(&instance->phase_gen_coeffs, &instance->phase_gen_state, 0.f, &p, &inc); bw_phase_gen_reset_state(&instance->phase_gen_coeffs, &instance->phase_gen_state, 0.f, &p, &inc);
bw_osc_pulse_reset_coeffs(&instance->osc_pulse_coeffs); bw_osc_pulse_reset_coeffs(&instance->osc_pulse_coeffs);
bw_osc_filt_reset_state(&instance->osc_filt_state); bw_osc_filt_reset_state(&instance->osc_filt_state, 0.f);
bw_svf_reset_coeffs(&instance->svf_coeffs); bw_svf_reset_coeffs(&instance->svf_coeffs);
float lp, bp, hp; float lp, bp, hp;
bw_svf_reset_state(&instance->svf_coeffs, &instance->svf_state, 0.f, &lp, &bp, &hp); bw_svf_reset_state(&instance->svf_coeffs, &instance->svf_state, 0.f, &lp, &bp, &hp);

View File

@ -45,12 +45,15 @@ void bw_example_synthpp_poly_init(bw_example_synthpp_poly *instance) {
} }
void bw_example_synthpp_poly_set_sample_rate(bw_example_synthpp_poly *instance, float sample_rate) { void bw_example_synthpp_poly_set_sample_rate(bw_example_synthpp_poly *instance, float sample_rate) {
instance->vco1OscSaw.setSampleRate(sample_rate);
instance->vco1OscPulse.setSampleRate(sample_rate); instance->vco1OscPulse.setSampleRate(sample_rate);
instance->vco1OscTri.setSampleRate(sample_rate); instance->vco1OscTri.setSampleRate(sample_rate);
instance->vco1Gain.setSampleRate(sample_rate); instance->vco1Gain.setSampleRate(sample_rate);
instance->vco2OscSaw.setSampleRate(sample_rate);
instance->vco2OscPulse.setSampleRate(sample_rate); instance->vco2OscPulse.setSampleRate(sample_rate);
instance->vco2OscTri.setSampleRate(sample_rate); instance->vco2OscTri.setSampleRate(sample_rate);
instance->vco2Gain.setSampleRate(sample_rate); instance->vco2Gain.setSampleRate(sample_rate);
instance->vco3OscSaw.setSampleRate(sample_rate);
instance->vco3OscPulse.setSampleRate(sample_rate); instance->vco3OscPulse.setSampleRate(sample_rate);
instance->vco3OscTri.setSampleRate(sample_rate); instance->vco3OscTri.setSampleRate(sample_rate);
instance->vco3Gain.setSampleRate(sample_rate); instance->vco3Gain.setSampleRate(sample_rate);
@ -78,16 +81,20 @@ void bw_example_synthpp_poly_reset(bw_example_synthpp_poly *instance) {
instance->voices[i].vcf.setCutoff(bw_clipf(cutoff, 20.f, 20e3f)); instance->voices[i].vcf.setCutoff(bw_clipf(cutoff, 20.f, 20e3f));
instance->noteQueue = NoteQueue(); instance->noteQueue = NoteQueue();
instance->vco1OscSaw.reset();
instance->vco1OscPulse.reset(); instance->vco1OscPulse.reset();
instance->vco1OscTri.reset(); instance->vco1OscTri.reset();
instance->vco1Gain.reset(); instance->vco1Gain.reset();
instance->vco2OscSaw.reset();
instance->vco2OscPulse.reset(); instance->vco2OscPulse.reset();
instance->vco2OscTri.reset(); instance->vco2OscTri.reset();
instance->vco2Gain.reset(); instance->vco2Gain.reset();
instance->vco3OscSaw.reset();
instance->vco3OscPulse.reset(); instance->vco3OscPulse.reset();
instance->vco3OscTri.reset(); instance->vco3OscTri.reset();
instance->vco3Gain.reset(); instance->vco3Gain.reset();
instance->oscFilt.reset(); instance->oscFilt.reset();
instance->noiseGen.reset();
instance->pinkFilt.reset(); instance->pinkFilt.reset();
instance->noiseGain.reset(); instance->noiseGain.reset();
instance->vcfEnvGen.reset(); instance->vcfEnvGen.reset();
@ -101,6 +108,7 @@ void bw_example_synthpp_poly_reset(bw_example_synthpp_poly *instance) {
instance->voices[i].vco3PhaseGen.reset(); instance->voices[i].vco3PhaseGen.reset();
instance->voices[i].vcf.reset(); instance->voices[i].vcf.reset();
instance->voices[i].note = 69;
instance->voices[i].gate = 0; instance->voices[i].gate = 0;
} }
@ -212,7 +220,7 @@ void bw_example_synthpp_poly_process(bw_example_synthpp_poly *instance, const fl
for (int j = 0; j < N_VOICES; j++) { for (int j = 0; j < N_VOICES; j++) {
bufScale<1>({b2[j]}, instance->params[p_vco1_mod], {b3[j]}, n); bufScale<1>({b2[j]}, instance->params[p_vco1_mod], {b3[j]}, n);
instance->voices[j].vco1PhaseGen.process({b3[j]}, {b4[j]}, {b3[j]}, n); instance->voices[j].vco1PhaseGen.process({b3[j]}, {b3[j]}, {b4[j]}, n);
} }
if (instance->params[p_vco1_waveform] >= (1.f / 4.f + 1.f / 2.f)) { if (instance->params[p_vco1_waveform] >= (1.f / 4.f + 1.f / 2.f)) {
instance->vco1OscTri.process(b3, b4, b3, n); instance->vco1OscTri.process(b3, b4, b3, n);

View File

@ -4,3 +4,6 @@ NAME := bw_example_synthpp_poly
SOURCE := bw_example_synthpp_poly.cpp SOURCE := bw_example_synthpp_poly.cpp
include ${ROOT_DIR}/../../common/vst3/vst3.mk include ${ROOT_DIR}/../../common/vst3/vst3.mk
CXXFLAGS += -DRELEASE=1 -DNDEBUG -DBW_NO_DEBUG
#CXXFLAGS += -DDEVELOPMENT=1 -DBW_DEBUG_DEEP