blob: df90578a0c40fb3fa2375566cd6d8d4094f690a2 (
plain) (
tree)
|
|
#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 */
|