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