summaryrefslogtreecommitdiffstats
path: root/src/generator.c
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2023-11-21 14:07:33 +0200
committergramanas <anastasis.gramm2@gmail.com>2023-11-21 14:07:33 +0200
commitc03d395f6848fe9b2d1185173a9cf5ec8277394f (patch)
tree2dad9fe79a189096b713559e35cf49497fea817a /src/generator.c
parenta7c39399e3ec051f210d9e991fe0112d0f988817 (diff)
downloadsynth-project-c03d395f6848fe9b2d1185173a9cf5ec8277394f.tar.gz
synth-project-c03d395f6848fe9b2d1185173a9cf5ec8277394f.tar.bz2
synth-project-c03d395f6848fe9b2d1185173a9cf5ec8277394f.zip
Crappy fft for spectrum analysis and initial gtk test
Diffstat (limited to 'src/generator.c')
-rw-r--r--src/generator.c70
1 files changed, 65 insertions, 5 deletions
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 <libconfig.h>
+
#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);
+
+}