summaryrefslogtreecommitdiffstats
path: root/src/generator.h
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2023-09-02 19:39:15 +0300
committergramanas <anastasis.gramm2@gmail.com>2023-09-02 19:39:15 +0300
commit1ef25d9be2b5358f3da7429bf0b27d5a9e9fa1a8 (patch)
tree4f4764469ba18eb316466f6522e470de9a9e646f /src/generator.h
parent0ea48752390228224e7f25575b096efc0aacd70b (diff)
downloadsynth-project-1ef25d9be2b5358f3da7429bf0b27d5a9e9fa1a8.tar.gz
synth-project-1ef25d9be2b5358f3da7429bf0b27d5a9e9fa1a8.tar.bz2
synth-project-1ef25d9be2b5358f3da7429bf0b27d5a9e9fa1a8.zip
DELAY
Diffstat (limited to 'src/generator.h')
-rw-r--r--src/generator.h69
1 files changed, 69 insertions, 0 deletions
diff --git a/src/generator.h b/src/generator.h
new file mode 100644
index 0000000..df90578
--- /dev/null
+++ b/src/generator.h
@@ -0,0 +1,69 @@
+#ifndef GENERATOR_H
+#define GENERATOR_H
+
+#include "adsr.h"
+#include "osc.h"
+#include "synth_engine.h"
+
+#define MAX_CMP 64
+
+enum osc_enum {
+ SIN,
+ SAW,
+ DIGISAW,
+ TRI,
+ SQR
+};
+
+enum adsr_type {
+ LINEAR,
+ CUBIC
+};
+
+enum target_enum {
+ OSC_FREQ,
+ OSC_AMP,
+ ADSR_AMP,
+ OUTPUT
+};
+
+// ints are:
+// negative if false
+// the id of the component if true
+typedef struct sound_node {
+ int osc;
+ enum osc_enum osc_type;
+ int lfo;
+ enum adsr_enum adsr_type;
+ int adsr;
+ float target_amp;
+ enum target_enum target;
+
+ struct sound_node ** children;
+ int n;
+} sound_node;
+
+struct generator {
+ // list of indexes for oscilators, lfos and adsrs
+ float osc[MAX_CMP];
+ float lfo[MAX_CMP];
+ float adsr[MAX_CMP];
+
+ // need to include some info about the wiring of the oscs lfos and adsrs
+ // e.g. :
+ // adsr 0 -> osc 0 frequency
+ // lfo 0 -> osc 0 frequency
+ // lfo 1 -> lfo 0 frequency
+ // osc 0 -> output
+
+ //o0-saw:l0-sin:l1-sin:a0-linear
+ //a0-o0/frequency:l0-o0/frequency:l1-l0/frequency:o0-1
+};
+
+int sound_tree_add_node(sound_node * root, const char * cmp);
+
+// needs to "play" the wiring defined in the struct
+// using sounds from `s` and the midi note `i`
+float generate(generator * g, synth_t * s, int i);
+
+#endif /* GENERATOR_H */