summaryrefslogtreecommitdiffstats
path: root/src/synth_engine_v2.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/synth_engine_v2.c')
-rw-r--r--src/synth_engine_v2.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/src/synth_engine_v2.c b/src/synth_engine_v2.c
index 7db9a6f..8740fe0 100644
--- a/src/synth_engine_v2.c
+++ b/src/synth_engine_v2.c
@@ -149,11 +149,13 @@ do_fliter(synth_t *synth, float *sample, unsigned int sample_rate, int frame)
}
}
- cutoff = 50 + cutoff * fix_adsr(&synth->f_adsr,
- note->noteOn,
- note->noteOff,
- note->elapsed,
- note->noteOffSample);
+ float adsr = fix_adsr(&synth->f_adsr,
+ note->noteOn,
+ note->noteOff,
+ note->elapsed,
+ note->noteOffSample);
+ if (adsr < 0.1) adsr = 0.1;
+ cutoff = cutoff * adsr;
}
}
@@ -274,8 +276,10 @@ make_sample(synth_t * synth, unsigned int sample_rate, int frame)
if (synth->clamp) sample = clamp(sample, -1, 1);
// autogain
- if (synth->autogain && (sample >= 1 || sample <= -1)) {
- synth->cc_gain.target *= 0.999;
+ if (synth->autogain) {
+ if (sample >= 1 || sample <= -1) {
+ synth->cc_gain.target *= 0.999;
+ }
}
//printf("CLICK! %f\n", fabsf(prev_sample) - fabsf(sample));
@@ -630,7 +634,7 @@ load_synth(synth_t *synth, const char *path)
config_init(&cfg);
/* Read the file. If there is an error, report it and exit. */
- if(! config_read_file(&cfg, "TEST.cfg"))
+ if(! config_read_file(&cfg, path))
{
fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg),
config_error_line(&cfg), config_error_text(&cfg));
@@ -663,6 +667,7 @@ load_synth(synth_t *synth, const char *path)
config_lookup_float(&cfg, "synth.delay.feedback", &FLOAT);
synth->cc_del_feedback.target = FLOAT;
+ config_lookup_int(&cfg, "synth.biquad.enable", &synth->filter);
config_lookup_int(&cfg, "synth.filter.enable", &synth->filter);
config_lookup_float(&cfg, "synth.filter.cutoff", &FLOAT);
synth->cc_cutoff.target = FLOAT;
@@ -687,7 +692,7 @@ save_synth(synth_t *synth, const char *path)
{
(void)path;
- static const char *output_file = "TEST.cfg";
+ const char *output_file = path;//"TEST.cfg";
config_t cfg;
config_setting_t *root, *setting, *group, *adsr, *delay, *lfo, *filter;
@@ -699,7 +704,7 @@ save_synth(synth_t *synth, const char *path)
group = config_setting_add(root, "synth", CONFIG_TYPE_GROUP);
setting = config_setting_add(group, "name", CONFIG_TYPE_STRING);
- config_setting_set_string(setting, "example synth name");
+ config_setting_set_string(setting, path);
setting = config_setting_add(group, "generator", CONFIG_TYPE_INT);
config_setting_set_int(setting, synth->geni);
@@ -724,6 +729,10 @@ save_synth(synth_t *synth, const char *path)
setting = config_setting_add(delay, "feedback", CONFIG_TYPE_FLOAT);
config_setting_set_float(setting, synth->cc_del_feedback.target);
+ filter = config_setting_add(group, "biquad", CONFIG_TYPE_GROUP);
+ setting = config_setting_add(filter, "enable", CONFIG_TYPE_INT);
+ config_setting_set_int(setting, synth->biquad);
+
filter = config_setting_add(group, "filter", CONFIG_TYPE_GROUP);
setting = config_setting_add(filter, "enable", CONFIG_TYPE_INT);
config_setting_set_int(setting, synth->filter);