global synth, envelope might even work
This commit is contained in:
parent
454051d10c
commit
cbae975760
@ -20,6 +20,53 @@
|
||||
|
||||
#include "peacock.hpp"
|
||||
|
||||
Synth::Synth() {
|
||||
}
|
||||
|
||||
void Synth::run() {
|
||||
printf("called synth::run()\n");
|
||||
printf("%d\n", voices[0].env.phase);
|
||||
}
|
||||
|
||||
void Synth::voiceOn(uint8_t voice, uint8_t note) {
|
||||
// enable synth voice, start it all running
|
||||
}
|
||||
|
||||
Envelope::Envelope() {
|
||||
level = 0;
|
||||
phase = ENV_IDLE;
|
||||
printf("initialising envelope\n");
|
||||
}
|
||||
|
||||
void Envelope::run() {
|
||||
switch (phase) {
|
||||
case ENV_ATK:
|
||||
level += s.envAtk;
|
||||
if (level > 0x3fff) {
|
||||
level = 0x3fff;
|
||||
phase = ENV_DCY;
|
||||
}
|
||||
break;
|
||||
case ENV_DCY:
|
||||
if (level > s.envStn) {
|
||||
level -= s.envStn;
|
||||
level *= s.envDcy;
|
||||
level += s.envStn;
|
||||
} else {
|
||||
level = s.envStn;
|
||||
}
|
||||
break;
|
||||
case ENV_RLS:
|
||||
level *= s.envRls;
|
||||
break;
|
||||
case ENV_IDLE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Envelope::gate(uint8_t gate) {
|
||||
}
|
||||
|
||||
Voice::Voice() {
|
||||
}
|
||||
|
@ -20,23 +20,57 @@
|
||||
|
||||
#include "peacock.hpp"
|
||||
|
||||
class Envelope {
|
||||
public:
|
||||
Envelope();
|
||||
void run();
|
||||
void gate(uint8_t gate);
|
||||
uint16_t level;
|
||||
|
||||
//private:
|
||||
enum {
|
||||
ENV_ATK,
|
||||
ENV_DCY,
|
||||
ENV_RLS,
|
||||
ENV_IDLE
|
||||
} phase;
|
||||
};
|
||||
|
||||
class Voice {
|
||||
public:
|
||||
Voice();
|
||||
void run();
|
||||
uint8_t note;
|
||||
|
||||
//private:
|
||||
Envelope env; // calculated envelope value
|
||||
uint16_t pitch; // calculated pitch value with porta and master pitch etc
|
||||
enum { V_DONE,
|
||||
V_OFF,
|
||||
V_ON } voiceState;
|
||||
};
|
||||
|
||||
class Synth {
|
||||
friend Envelope;
|
||||
friend Peacock;
|
||||
|
||||
public:
|
||||
Synth();
|
||||
void run();
|
||||
void voiceOn(uint8_t voice, uint8_t note);
|
||||
void voiceOff(uint8_t voice);
|
||||
void sustainSwitch(uint8_t val);
|
||||
void pitchBend(int16_t bend);
|
||||
void modWheel(uint8_t wheel);
|
||||
uint16_t masterPitch; // sum of bend and LFO, plus any other pitch-setting value
|
||||
protected:
|
||||
uint16_t envAtk, envDcy, envStn, envRls;
|
||||
|
||||
private:
|
||||
Voice voices[NUM_VOICES];
|
||||
void runLfo();
|
||||
void runEnvelope(Voice voice);
|
||||
};
|
||||
|
||||
class Voice {
|
||||
public:
|
||||
Voice();
|
||||
void run();
|
||||
private:
|
||||
|
||||
|
||||
};
|
||||
// global
|
||||
extern Synth s;
|
||||
|
@ -18,12 +18,15 @@
|
||||
|
||||
#include "peacock.hpp"
|
||||
#include "ic1.hpp"
|
||||
#include "ic29.hpp"
|
||||
|
||||
START_NAMESPACE_DISTRHO
|
||||
|
||||
Assigner ic1;
|
||||
Synth s;
|
||||
|
||||
Peacock::Peacock() : Plugin(paramCount, 0, 0), sampleRate(getSampleRate()) {
|
||||
s.run();
|
||||
}
|
||||
|
||||
void Peacock::run(const float **, float **outputs, uint32_t frames, const MidiEvent *midiEvents, uint32_t midiEventCount) {
|
||||
|
Loading…
Reference in New Issue
Block a user