1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
#include <libconfig.h>
#include "generator.h"
float
generate(generator * g, synth_t * s, int i, sound_node * root)
{
float sample = 0;
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);
}
|