tidied up envelope
This commit is contained in:
parent
84eef25f8d
commit
34800af7a1
@ -23,10 +23,10 @@ Synth ic29;
|
|||||||
|
|
||||||
Synth::Synth() {
|
Synth::Synth() {
|
||||||
d_debug("initialising synth\n");
|
d_debug("initialising synth\n");
|
||||||
envAtk = atkTable[0];
|
envAtk = 0x20;
|
||||||
envDcy = dcyTable[90];
|
envDcy = 0x50;
|
||||||
envRls = dcyTable[10];
|
envStn = 0x1f;
|
||||||
envStn = 0xfff;
|
envRls = 0x3f;
|
||||||
portaCoeff = 0x0;
|
portaCoeff = 0x0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,25 +76,27 @@ Envelope::Envelope() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Envelope::run() {
|
void Envelope::run() {
|
||||||
|
|
||||||
|
uint16_t tempStn = ic29.envStn << 6;
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case ENV_ATK:
|
case ENV_ATK:
|
||||||
level += ic29.envAtk;
|
level += atkTable[ic29.envAtk];
|
||||||
if (level > 0x3fff) {
|
if (level > 0x3fff) {
|
||||||
level = 0x3fff;
|
level = 0x3fff;
|
||||||
phase = ENV_DCY;
|
phase = ENV_DCY;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ENV_DCY:
|
case ENV_DCY:
|
||||||
if (level > ic29.envStn) {
|
if (level > tempStn) {
|
||||||
level -= ic29.envStn;
|
// level = ((level * ic29.envDcy) >> 16;
|
||||||
level = (level * ic29.envDcy) >> 16;
|
level = (((level - tempStn) * dcyTable[ic29.envDcy]) >> 16) + tempStn;
|
||||||
level += ic29.envStn;
|
|
||||||
} else {
|
} else {
|
||||||
level = ic29.envStn;
|
level = tempStn;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ENV_RLS:
|
case ENV_RLS:
|
||||||
level = (level * ic29.envRls) >> 16;
|
level = (level * dcyTable[ic29.envRls]) >> 16;
|
||||||
break;
|
break;
|
||||||
case ENV_IDLE:
|
case ENV_IDLE:
|
||||||
default:
|
default:
|
||||||
|
@ -45,6 +45,8 @@ class Envelope {
|
|||||||
ENV_RLS,
|
ENV_RLS,
|
||||||
ENV_IDLE
|
ENV_IDLE
|
||||||
} phase;
|
} phase;
|
||||||
|
static const uint16_t atkTable[128];
|
||||||
|
static const uint16_t dcyTable[128];
|
||||||
};
|
};
|
||||||
|
|
||||||
class Voice {
|
class Voice {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "ic29.hpp"
|
#include "ic29.hpp"
|
||||||
|
|
||||||
extern const uint16_t atkTable[] = {
|
const uint16_t Envelope::atkTable[128] = {
|
||||||
0x4000, 0x2000, 0x1000, 0x0aaa, 0x0800, 0x0666, 0x0555, 0x0492, 0x0400,
|
0x4000, 0x2000, 0x1000, 0x0aaa, 0x0800, 0x0666, 0x0555, 0x0492, 0x0400,
|
||||||
0x038e, 0x0333, 0x02e9, 0x02ab, 0x0276, 0x0249, 0x0222, 0x0200, 0x01e2,
|
0x038e, 0x0333, 0x02e9, 0x02ab, 0x0276, 0x0249, 0x0222, 0x0200, 0x01e2,
|
||||||
0x01c7, 0x01af, 0x0199, 0x0186, 0x0174, 0x0164, 0x0155, 0x0148, 0x013b,
|
0x01c7, 0x01af, 0x0199, 0x0186, 0x0174, 0x0164, 0x0155, 0x0148, 0x013b,
|
||||||
@ -37,7 +37,7 @@ extern const uint16_t atkTable[] = {
|
|||||||
0x001d, 0x001c, 0x001c, 0x001b, 0x001b, 0x001a, 0x0019, 0x0018, 0x0017,
|
0x001d, 0x001c, 0x001c, 0x001b, 0x001b, 0x001a, 0x0019, 0x0018, 0x0017,
|
||||||
0x0016, 0x0015};
|
0x0016, 0x0015};
|
||||||
|
|
||||||
extern const uint16_t dcyTable[128] = {
|
const uint16_t Envelope::dcyTable[128] = {
|
||||||
0x1000, 0x3000, 0x5000, 0x7000, 0x9000, 0xa000, 0xa800, 0xb000, 0xb800,
|
0x1000, 0x3000, 0x5000, 0x7000, 0x9000, 0xa000, 0xa800, 0xb000, 0xb800,
|
||||||
0xc000, 0xc800, 0xd000, 0xd800, 0xe000, 0xe800, 0xf000, 0xf080, 0xf100,
|
0xc000, 0xc800, 0xd000, 0xd800, 0xe000, 0xe800, 0xf000, 0xf080, 0xf100,
|
||||||
0xf180, 0xf200, 0xf280, 0xf300, 0xf380, 0xf400, 0xf480, 0xf500, 0xf580,
|
0xf180, 0xf200, 0xf280, 0xf300, 0xf380, 0xf400, 0xf480, 0xf500, 0xf580,
|
||||||
|
Loading…
Reference in New Issue
Block a user