added svf back to synth example
This commit is contained in:
parent
4ebcac26de
commit
2b32ec75d6
@ -28,6 +28,7 @@
|
||||
#include <bw_math.h>
|
||||
#include <bw_noise_gen.h>
|
||||
#include <bw_phase_gen.h>
|
||||
#include <bw_svf.h>
|
||||
#include <bw_osc_sin.h>
|
||||
#include <bw_vol.h>
|
||||
#include <bw_env_follow.h>
|
||||
@ -63,6 +64,8 @@ struct _bw_example_synth {
|
||||
bw_phase_gen_coeffs phase_gen_coeffs;
|
||||
bw_phase_gen_state phase_gen_state;
|
||||
bw_noise_gen_coeffs noise_gen_coeffs;
|
||||
bw_svf_coeffs svf_coeffs;
|
||||
bw_svf_state svf_state;
|
||||
bw_phase_gen_coeffs a440_phase_gen_coeffs;
|
||||
bw_phase_gen_state a440_phase_gen_state;
|
||||
bw_vol_coeffs vol_coeffs;
|
||||
@ -71,7 +74,6 @@ struct _bw_example_synth {
|
||||
/*
|
||||
bw_osc_pulse osc_pulse;
|
||||
bw_osc_filt osc_filt;
|
||||
bw_svf svf;
|
||||
bw_env_gen env_gen;
|
||||
bw_vol vol;
|
||||
bw_env_follow env_follow;
|
||||
@ -97,6 +99,7 @@ bw_example_synth bw_example_synth_new() {
|
||||
bw_phase_gen_init(&instance->phase_gen_coeffs);
|
||||
bw_noise_gen_init(&instance->noise_gen_coeffs, &instance->rand_state);
|
||||
bw_phase_gen_init(&instance->a440_phase_gen_coeffs);
|
||||
bw_svf_init(&instance->svf_coeffs);
|
||||
bw_vol_init(&instance->vol_coeffs);
|
||||
bw_env_follow_init(&instance->env_follow_coeffs);
|
||||
|
||||
@ -125,6 +128,7 @@ void bw_example_synth_set_sample_rate(bw_example_synth instance, float sample_ra
|
||||
bw_phase_gen_set_sample_rate(&instance->phase_gen_coeffs, sample_rate);
|
||||
bw_noise_gen_set_sample_rate(&instance->noise_gen_coeffs, sample_rate);
|
||||
bw_phase_gen_set_sample_rate(&instance->a440_phase_gen_coeffs, sample_rate);
|
||||
bw_svf_set_sample_rate(&instance->svf_coeffs, sample_rate);
|
||||
bw_vol_set_sample_rate(&instance->vol_coeffs, sample_rate);
|
||||
bw_env_follow_set_sample_rate(&instance->env_follow_coeffs, sample_rate);
|
||||
/*
|
||||
@ -139,6 +143,8 @@ void bw_example_synth_reset(bw_example_synth instance) {
|
||||
bw_phase_gen_reset_state(&instance->phase_gen_coeffs, &instance->phase_gen_state);
|
||||
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);
|
||||
bw_svf_reset_coeffs(&instance->svf_coeffs);
|
||||
bw_svf_reset_state(&instance->svf_coeffs, &instance->svf_state);
|
||||
bw_vol_reset_coeffs(&instance->vol_coeffs);
|
||||
bw_env_follow_reset_coeffs(&instance->env_follow_coeffs);
|
||||
bw_env_follow_reset_state(&instance->env_follow_coeffs, &instance->env_follow_state);
|
||||
@ -170,6 +176,8 @@ void bw_example_synth_process(bw_example_synth instance, const float** x, float*
|
||||
if (instance->note != -1)
|
||||
bw_noise_gen_process(&instance->noise_gen_coeffs, y[0], n_samples);
|
||||
|
||||
bw_svf_process(&instance->svf_coeffs, &instance->svf_state, y[0], y[0], NULL, NULL, n_samples);
|
||||
|
||||
/*
|
||||
for (int i = 0; i < n_samples; i += BUFFER_SIZE) {
|
||||
float *out = y[0] + i;
|
||||
@ -197,7 +205,7 @@ void bw_example_synth_process(bw_example_synth instance, const float** x, float*
|
||||
bw_vol_process(&instance->vol_coeffs, y[0], y[0], n_samples);
|
||||
|
||||
bw_env_follow_process(&instance->env_follow_coeffs, &instance->env_follow_state, y[0], NULL, n_samples);
|
||||
instance->level = bw_env_follow_get_y_z1(&instance->env_follow_state);
|
||||
instance->level = bw_clipf(bw_env_follow_get_y_z1(&instance->env_follow_state), 0.f, 1.f);
|
||||
}
|
||||
|
||||
void bw_example_synth_set_parameter(bw_example_synth instance, int index, float value) {
|
||||
@ -209,16 +217,16 @@ void bw_example_synth_set_parameter(bw_example_synth instance, int index, float
|
||||
case p_portamento:
|
||||
bw_phase_gen_set_portamento_tau(&instance->phase_gen_coeffs, value);
|
||||
break;
|
||||
case p_cutoff:
|
||||
bw_svf_set_cutoff(&instance->svf_coeffs, 20.f + (20e3f - 20.f) * value * value * value);
|
||||
break;
|
||||
case p_Q:
|
||||
bw_svf_set_Q(&instance->svf_coeffs, 0.5f + 9.5f * value);
|
||||
break;
|
||||
/*
|
||||
case p_pulse_width:
|
||||
bw_osc_pulse_set_pulse_width(&instance->osc_pulse, value);
|
||||
break;
|
||||
case p_cutoff:
|
||||
bw_svf_set_cutoff(&instance->svf, 20.f + (20e3f - 20.f) * value * value * value);
|
||||
break;
|
||||
case p_Q:
|
||||
bw_svf_set_Q(&instance->svf, 0.5f + 9.5f * value);
|
||||
break;
|
||||
case p_attack:
|
||||
bw_env_gen_set_attack(&instance->env_gen, value);
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user