From c03d395f6848fe9b2d1185173a9cf5ec8277394f Mon Sep 17 00:00:00 2001 From: gramanas Date: Tue, 21 Nov 2023 14:07:33 +0200 Subject: Crappy fft for spectrum analysis and initial gtk test --- src/generator.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 65 insertions(+), 5 deletions(-) (limited to 'src/generator.c') diff --git a/src/generator.c b/src/generator.c index 4e81297..ab2206f 100644 --- a/src/generator.c +++ b/src/generator.c @@ -1,16 +1,76 @@ +#include + #include "generator.h" float -generate(generator * g, synth_t * s, int i) +generate(generator * g, synth_t * s, int i, sound_node * root) { float sample = 0; - float f = get_frequency(g, s, i);' - - sample = osc_saw(midi_note->wvt_index); - midi_note->wvt_index = osc_saw_next(f, midi_note->wvt_index); + sampe = play_tree(root, s->midi_note[i]); return sample; } + +int +sound_tree_add_node(sound_node * root, const char * cmp) +{ + +} + +int +load_preset(sound_node * tree, const char * path) +{ + config_t cfg; + config_setting_t *setting, *x; + const char *str; + + config_init(&cfg); + if (! config_read_file(&cfg, "../preset.synth")) { + fprintf(stderr, "%s:%d - %s\n", config_error_file(&cfg), + config_error_line(&cfg), config_error_text(&cfg)); + config_destroy(&cfg); + return(EXIT_FAILURE); + } + setting = config_lookup(&cfg, "patch"); + if (setting != NULL) { + int count = config_setting_length(setting); + + for(int i = 0; i < count; ++i) { + x = config_setting_get_elem(setting, i); + printf("%s = %f\n", config_setting_name(x), config_setting_get_float(x)); + // TODO + sound_tree_add_node(tree, name); + } + } + + + setting = config_tree_setting(&cfg); + if (setting != NULL) { + int count = config_setting_length(setting); + + for(int i = 0; i < count; ++i) { + chat * name = config_setting_name(x); + x = config_setting_get_elem(setting, i); + printf("%s -- %d\n", config_setting_name(x), config_setting_type(x)); + + if (name[0] == 'o') { // osc + // TODO + configure_osc(tree, id); + } else if (name[0] == 'a') { // adsr + // TODO + configure_adsr(tree, id); + } else if (name[0] == 'l') { // lfo + // TODO + configure_lfo(tree, id); + } else { + printf("%s: wrong!", name); + } + } + } + + config_destroy(&cfg); + +} -- cgit v1.2.3