more work on FM synth code
parent
f300a580a4
commit
80d58f65b6
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "../common.h"
|
||||
#include "fm_2op.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
float fm2_process(struct FM2 *self, EngineState *t) {
|
||||
self->Carrier.gate=self->gate;
|
||||
|
@ -30,3 +31,14 @@ float fm2_process(struct FM2 *self, EngineState *t) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FM2* fm2_new() {
|
||||
FM2 *fm = malloc(sizeof(FM2));
|
||||
fm->Carrier = *operator_new();
|
||||
fm->Modulator = *operator_new();
|
||||
fm->process = fm2_process;
|
||||
fm->Algorithm = _fm2_1; // do what i mean value.
|
||||
fm->gate = false;
|
||||
|
||||
return fm;
|
||||
}
|
||||
|
|
|
@ -38,10 +38,6 @@ typedef struct FM2 {
|
|||
} FM2;
|
||||
|
||||
float fm2_process(struct FM2 *, EngineState *);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
FM2* fm2_new();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "../utils/envelope.h"
|
||||
#include "fm_core.h"
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
float core_fm_run(Operator* self, EngineState * t,float phase) {
|
||||
self->e.gate = self->gate;
|
||||
|
@ -25,3 +26,15 @@ float core_fm_run(Operator* self, EngineState * t,float phase) {
|
|||
return out;
|
||||
}
|
||||
|
||||
Operator* operator_new() {
|
||||
Operator *o = malloc(sizeof(Operator));
|
||||
Envelope e = *envelope_new();
|
||||
o->level = 1.0;
|
||||
o->e = e;
|
||||
o->gate = false;
|
||||
o->feedback_level = 0.0;
|
||||
o->run = core_fm_run
|
||||
o->feedback_buffer = 0.0;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,5 +27,5 @@ typedef struct Operator {
|
|||
float(*run)(struct Operator*,EngineState *,float);
|
||||
} Operator;
|
||||
float core_fm_run(Operator*, EngineState *,float);
|
||||
|
||||
Operator* operator_new();
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue