functional envelopes
This commit is contained in:
parent
cbae975760
commit
c758a0a493
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "ic1.hpp"
|
||||
#include "ic29.hpp"
|
||||
|
||||
#include "peacock.hpp"
|
||||
|
||||
@ -62,6 +63,8 @@ void Assigner::noteOff(uint8_t note) {
|
||||
memmove(keymap + i, keymap + i + 1, NUM_VOICES - i - 1);
|
||||
voicemap[NUM_VOICES - 1] = voice;
|
||||
keymap[NUM_VOICES - 1] = note | 0x80;
|
||||
s.voiceOff(voice);
|
||||
|
||||
}
|
||||
}
|
||||
printMap();
|
||||
@ -80,6 +83,7 @@ void Assigner::noteOn(uint8_t note) {
|
||||
memmove(keymap + 1, keymap, i);
|
||||
keymap[0] = note; // show note as on
|
||||
voicemap[0] = voice;
|
||||
s.voiceOn(voice, note);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -95,6 +99,7 @@ void Assigner::noteOn(uint8_t note) {
|
||||
memmove(keymap + 1, keymap, i);
|
||||
keymap[0] = note; // show note as on
|
||||
voicemap[0] = voice;
|
||||
s.voiceOn(voice, note);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -18,24 +18,41 @@
|
||||
|
||||
#include "ic29.hpp"
|
||||
|
||||
#include "peacock.hpp"
|
||||
|
||||
Synth s;
|
||||
|
||||
|
||||
Synth::Synth() {
|
||||
printf("initialising synth\n");
|
||||
envAtk = 0x007f;
|
||||
envDcy = envRls = 0xfe90;
|
||||
envStn = 0x1fff;
|
||||
}
|
||||
|
||||
void Synth::run() {
|
||||
printf("called synth::run()\n");
|
||||
printf("%d\n", voices[0].env.phase);
|
||||
//printf("called synth::run()\n");
|
||||
//printf("%d\n", voices[0].env.phase);
|
||||
for (uint8_t i=0; i<NUM_VOICES; i++) {
|
||||
s.voices[i].env.run();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Synth::voiceOn(uint8_t voice, uint8_t note) {
|
||||
// enable synth voice, start it all running
|
||||
voice &= 0x7f;
|
||||
s.voices[voice].env.on();
|
||||
}
|
||||
|
||||
void Synth::voiceOff(uint8_t voice) {
|
||||
// enable synth voice, start it all running
|
||||
voice &= 0x7f;
|
||||
s.voices[voice].env.off();
|
||||
}
|
||||
|
||||
Envelope::Envelope() {
|
||||
level = 0;
|
||||
phase = ENV_IDLE;
|
||||
printf("initialising envelope\n");
|
||||
}
|
||||
|
||||
void Envelope::run() {
|
||||
@ -50,14 +67,14 @@ void Envelope::run() {
|
||||
case ENV_DCY:
|
||||
if (level > s.envStn) {
|
||||
level -= s.envStn;
|
||||
level *= s.envDcy;
|
||||
level = (level * s.envDcy) >> 16;
|
||||
level += s.envStn;
|
||||
} else {
|
||||
level = s.envStn;
|
||||
}
|
||||
break;
|
||||
case ENV_RLS:
|
||||
level *= s.envRls;
|
||||
level = (level * s.envRls) >> 16;
|
||||
break;
|
||||
case ENV_IDLE:
|
||||
default:
|
||||
@ -65,8 +82,7 @@ void Envelope::run() {
|
||||
}
|
||||
}
|
||||
|
||||
void Envelope::gate(uint8_t gate) {
|
||||
}
|
||||
|
||||
Voice::Voice() {
|
||||
}
|
||||
|
||||
extern Synth s;
|
@ -20,14 +20,22 @@
|
||||
|
||||
#include "peacock.hpp"
|
||||
|
||||
|
||||
|
||||
class Envelope {
|
||||
public:
|
||||
Envelope();
|
||||
void run();
|
||||
void gate(uint8_t gate);
|
||||
void on() {
|
||||
phase = ENV_ATK;
|
||||
}
|
||||
|
||||
void off() {
|
||||
phase = ENV_RLS;
|
||||
}
|
||||
uint16_t level;
|
||||
|
||||
//private:
|
||||
// private:
|
||||
enum {
|
||||
ENV_ATK,
|
||||
ENV_DCY,
|
||||
@ -42,7 +50,7 @@ class Voice {
|
||||
void run();
|
||||
uint8_t note;
|
||||
|
||||
//private:
|
||||
// private:
|
||||
Envelope env; // calculated envelope value
|
||||
uint16_t pitch; // calculated pitch value with porta and master pitch etc
|
||||
enum { V_DONE,
|
||||
|
@ -23,7 +23,6 @@
|
||||
START_NAMESPACE_DISTRHO
|
||||
|
||||
Assigner ic1;
|
||||
Synth s;
|
||||
|
||||
Peacock::Peacock() : Plugin(paramCount, 0, 0), sampleRate(getSampleRate()) {
|
||||
s.run();
|
||||
@ -41,6 +40,7 @@ void Peacock::run(const float **, float **outputs, uint32_t frames, const MidiEv
|
||||
|
||||
|
||||
}
|
||||
s.run();
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user