From 55ce72c20a6e1d4a095c501f24c81d7798ae2078 Mon Sep 17 00:00:00 2001 From: grm Date: Fri, 28 Nov 2025 19:35:45 +0200 Subject: add more save and load --- src/synth_engine_v2.c | 47 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/synth_engine_v2.c b/src/synth_engine_v2.c index 538a840..3c5238e 100644 --- a/src/synth_engine_v2.c +++ b/src/synth_engine_v2.c @@ -724,6 +724,8 @@ load_synth(synth_t *synth, const char *path) fprintf(stderr, "No 'synth.name' setting in configuration file.\n"); config_lookup_int(&cfg, "synth.generator", &synth->geni); + config_lookup_int(&cfg, "synth.octave", &synth->octave); + config_lookup_int(&cfg, "synth.clamp", &synth->clamp); config_lookup_float(&cfg, "synth.adsr.a", &FLOAT); synth->cc_adsr_a.target = FLOAT; @@ -735,6 +737,18 @@ load_synth(synth_t *synth, const char *path) synth->cc_adsr_s.target = FLOAT; config_lookup_float(&cfg, "synth.adsr.r", &FLOAT); synth->cc_adsr_r.target = FLOAT; + + config_lookup_int(&cfg, "synth.f_adsr.enable", &synth->f_adsr_enabled); + config_lookup_float(&cfg, "synth.f_adsr.a", &FLOAT); + synth->cc_f_adsr_a.target = FLOAT; + config_lookup_float(&cfg, "synth.f_adsr.peak", &FLOAT); + synth->cc_f_adsr_peak.target = FLOAT; + config_lookup_float(&cfg, "synth.f_adsr.d", &FLOAT); + synth->cc_f_adsr_d.target = FLOAT; + config_lookup_float(&cfg, "synth.f_adsr.s", &FLOAT); + synth->cc_f_adsr_s.target = FLOAT; + config_lookup_float(&cfg, "synth.f_adsr.r", &FLOAT); + synth->cc_f_adsr_r.target = FLOAT; config_lookup_int(&cfg, "synth.delay.enable", &synth->delay); config_lookup_float(&cfg, "synth.delay.time", &FLOAT); @@ -742,7 +756,10 @@ 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.biquad.enable", &synth->biquad); + int placeholder; + config_lookup_int(&cfg, "synth.biquad.type", &placeholder); + synth->biquad_type = placeholder; config_lookup_int(&cfg, "synth.filter.enable", &synth->filter); config_lookup_float(&cfg, "synth.filter.cutoff", &FLOAT); synth->cc_cutoff.target = FLOAT; @@ -753,6 +770,8 @@ load_synth(synth_t *synth, const char *path) synth->cc_lfo_freq.target = FLOAT; config_lookup_float(&cfg, "synth.lfo.amp", &FLOAT); synth->cc_lfo_amp.target = FLOAT; + config_lookup_int(&cfg, "synth.lfo.on_pitch", &synth->lfo_on_pitch); + config_lookup_int(&cfg, "synth.lfo.on_cutoff", &synth->lfo_on_cutoff); config_lookup_int(&cfg, "synth.autogain", &synth->autogain); config_lookup_float(&cfg, "synth.gain", &FLOAT); @@ -770,7 +789,7 @@ save_synth(synth_t *synth, const char *path) const char *output_file = path;//"TEST.cfg"; config_t cfg; - config_setting_t *root, *setting, *group, *adsr, *delay, *lfo, *filter; + config_setting_t *root, *setting, *group, *adsr, *f_adsr, *delay, *lfo, *filter; config_init(&cfg); root = config_root_setting(&cfg); @@ -783,6 +802,10 @@ save_synth(synth_t *synth, const char *path) setting = config_setting_add(group, "generator", CONFIG_TYPE_INT); config_setting_set_int(setting, synth->geni); + setting = config_setting_add(group, "octave", CONFIG_TYPE_INT); + config_setting_set_int(setting, synth->octave); + setting = config_setting_add(group, "clamp", CONFIG_TYPE_INT); + config_setting_set_int(setting, synth->clamp); adsr = config_setting_add(group, "adsr", CONFIG_TYPE_GROUP); setting = config_setting_add(adsr, "a", CONFIG_TYPE_FLOAT); @@ -796,6 +819,20 @@ save_synth(synth_t *synth, const char *path) setting = config_setting_add(adsr, "r", CONFIG_TYPE_FLOAT); config_setting_set_float(setting, synth->cc_adsr_r.target); + f_adsr = config_setting_add(group, "f_adsr", CONFIG_TYPE_GROUP); + setting = config_setting_add(f_adsr, "enable", CONFIG_TYPE_INT); + config_setting_set_int(setting, synth->f_adsr_enabled); + setting = config_setting_add(f_adsr, "a", CONFIG_TYPE_FLOAT); + config_setting_set_float(setting, synth->cc_f_adsr_a.target); + setting = config_setting_add(f_adsr, "peak", CONFIG_TYPE_FLOAT); + config_setting_set_float(setting, synth->cc_f_adsr_peak.target); + setting = config_setting_add(f_adsr, "d", CONFIG_TYPE_FLOAT); + config_setting_set_float(setting, synth->cc_f_adsr_d.target); + setting = config_setting_add(f_adsr, "s", CONFIG_TYPE_FLOAT); + config_setting_set_float(setting, synth->cc_f_adsr_s.target); + setting = config_setting_add(f_adsr, "r", CONFIG_TYPE_FLOAT); + config_setting_set_float(setting, synth->cc_f_adsr_r.target); + delay = config_setting_add(group, "delay", CONFIG_TYPE_GROUP); setting = config_setting_add(delay, "enable", CONFIG_TYPE_INT); config_setting_set_int(setting, synth->delay); @@ -807,6 +844,8 @@ save_synth(synth_t *synth, const char *path) 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); + setting = config_setting_add(filter, "type", CONFIG_TYPE_INT); + config_setting_set_int(setting, synth->biquad_type); filter = config_setting_add(group, "filter", CONFIG_TYPE_GROUP); setting = config_setting_add(filter, "enable", CONFIG_TYPE_INT); @@ -821,6 +860,10 @@ save_synth(synth_t *synth, const char *path) config_setting_set_float(setting, synth->cc_lfo_freq.target); setting = config_setting_add(lfo, "amp", CONFIG_TYPE_FLOAT); config_setting_set_float(setting, synth->cc_lfo_amp.target); + setting = config_setting_add(lfo, "on_pitch", CONFIG_TYPE_INT); + config_setting_set_int(setting, synth->lfo_on_pitch); + setting = config_setting_add(lfo, "on_cutoff", CONFIG_TYPE_INT); + config_setting_set_int(setting, synth->lfo_on_cutoff); setting = config_setting_add(group, "autogain", CONFIG_TYPE_INT); config_setting_set_int(setting, synth->autogain); -- cgit v1.2.3