envelopes work again
This commit is contained in:
parent
af2968c23f
commit
1c3c6adf3c
@ -22,6 +22,7 @@
|
|||||||
#include "peacock.hpp"
|
#include "peacock.hpp"
|
||||||
|
|
||||||
void Assigner::printMap() {
|
void Assigner::printMap() {
|
||||||
|
return;
|
||||||
printf("note memory:\n");
|
printf("note memory:\n");
|
||||||
for (uint8_t i = 0; i < NUM_VOICES; i++) printf("%02x ", voicemap[i]);
|
for (uint8_t i = 0; i < NUM_VOICES; i++) printf("%02x ", voicemap[i]);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
@ -33,7 +34,7 @@ Assigner::Assigner() {
|
|||||||
// set up the assigner
|
// set up the assigner
|
||||||
for (uint8_t i = 0; i < NUM_VOICES; i++) {
|
for (uint8_t i = 0; i < NUM_VOICES; i++) {
|
||||||
voicemap[i] = 0x80 + i;
|
voicemap[i] = 0x80 + i;
|
||||||
keymap[i] = 0x3c | 0x80;
|
keymap[i] = 0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,6 +75,7 @@ void Assigner::noteOff(uint8_t note) {
|
|||||||
voicemap[NUM_VOICES - 1] = voice;
|
voicemap[NUM_VOICES - 1] = voice;
|
||||||
keymap[NUM_VOICES - 1] = note | 0x80;
|
keymap[NUM_VOICES - 1] = note | 0x80;
|
||||||
_ic29->voiceOff(voice);
|
_ic29->voiceOff(voice);
|
||||||
|
printMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,6 +92,7 @@ void Assigner::noteOn(uint8_t note) {
|
|||||||
keymap[0] = note; // show note as on
|
keymap[0] = note; // show note as on
|
||||||
voicemap[0] = voice;
|
voicemap[0] = voice;
|
||||||
_ic29->voiceOn(voice, note);
|
_ic29->voiceOn(voice, note);
|
||||||
|
printMap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,6 +107,7 @@ void Assigner::noteOn(uint8_t note) {
|
|||||||
keymap[0] = note; // show note as on
|
keymap[0] = note; // show note as on
|
||||||
voicemap[0] = voice;
|
voicemap[0] = voice;
|
||||||
_ic29->voiceOn(voice, note);
|
_ic29->voiceOn(voice, note);
|
||||||
|
printMap();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#define DEBUG
|
#define DEBUG
|
||||||
|
|
||||||
Synth::Synth() {
|
Synth::Synth() {
|
||||||
printf("Synth constructor\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Synth::buildTables(double sampleRate) {
|
void Synth::buildTables(double sampleRate) {
|
||||||
@ -71,11 +70,13 @@ void Synth::run() {
|
|||||||
// generate the voices, then
|
// generate the voices, then
|
||||||
for (uint32_t i = 0; i < bufferSize; i++) {
|
for (uint32_t i = 0; i < bufferSize; i++) {
|
||||||
tr21 = (tr21 * 519) + 3;
|
tr21 = (tr21 * 519) + 3;
|
||||||
noise[i] = (1 - (tr21 & 0x00ffffff) / 8388608.0f) * (patchRam.noiseLevel * 0.0063);
|
// noise[i] = (1 - (tr21 & 0x00ffffff) / 8388608.0f) * (patchRam.noiseLevel * 0.0063);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printf("updating\n");
|
||||||
|
|
||||||
for (uint8_t i = 0; i < NUM_VOICES; i++) {
|
for (uint8_t i = 0; i < NUM_VOICES; i++) {
|
||||||
//voices[i].update();
|
voices[i].update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,40 +123,43 @@ void LFO::run() {
|
|||||||
// printf("lfoOut=%04x\n", lfoOut);
|
// printf("lfoOut=%04x\n", lfoOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint16_t Envelope::atk = 0x10;
|
||||||
|
uint16_t Envelope::dcy = 0x3f;
|
||||||
|
uint16_t Envelope::stn = 0x3f;
|
||||||
|
uint16_t Envelope::rls = 0x1f;
|
||||||
|
|
||||||
Envelope::Envelope() {
|
Envelope::Envelope() {
|
||||||
level = 0;
|
level = 0;
|
||||||
phase = ENV_RLS;
|
phase = ENV_RLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Envelope::run() {
|
void Envelope::run() {
|
||||||
/*
|
uint16_t temp = stn << 7;
|
||||||
uint16_t tempStn = patchRam.sustain << 7;
|
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case ENV_ATK:
|
case ENV_ATK:
|
||||||
level += atkTable[ic29.patchRam.attack];
|
level += atkTable[atk];
|
||||||
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 > tempStn) {
|
if (level > temp) {
|
||||||
level = (((level - tempStn) * dcyTable[ic29.patchRam.decay]) >> 16) + tempStn;
|
level = (((level - temp) * dcyTable[dcy]) >> 16) + temp;
|
||||||
} else {
|
} else {
|
||||||
level = tempStn;
|
level = temp;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ENV_RLS:
|
case ENV_RLS:
|
||||||
level = (level * dcyTable[ic29.patchRam.release]) >> 16;
|
level = (level * dcyTable[rls]) >> 16;
|
||||||
break;
|
break;
|
||||||
case ENV_IDLE:
|
case ENV_IDLE:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Voice::Voice() {
|
Voice::Voice() {
|
||||||
subosc = .1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Voice::calcPitch() {
|
void Voice::calcPitch() {
|
||||||
@ -196,21 +200,22 @@ void Voice::calcPitch() {
|
|||||||
double frac = (pitch & 0xff) / 256.0f;
|
double frac = (pitch & 0xff) / 256.0f;
|
||||||
|
|
||||||
omega = ((o2 - o1) * frac) + o1;
|
omega = ((o2 - o1) * frac) + o1;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Voice::update() {
|
void Voice::update() {
|
||||||
// calculate the once-per-block values
|
// calculate the once-per-block values
|
||||||
env.run();
|
env.run();
|
||||||
calcPitch();
|
calcPitch();
|
||||||
|
//printf("env=%04x\n", env.level);
|
||||||
pw = (ic29.patchRam.switch1 & 0x08) ? ic29.pwm : 0.0f;
|
/*
|
||||||
|
pw = (patchRam.switch1 & 0x08) ? ic29.pwm : 0.0f;
|
||||||
saw = (ic29.patchRam.switch1 & 0x10) ? 1.0f : 0.0f;
|
saw = (ic29.patchRam.switch1 & 0x10) ? 1.0f : 0.0f;
|
||||||
sub = ic29.patchRam.subLevel / 128.0f;
|
sub = ic29.patchRam.subLevel / 128.0f;
|
||||||
|
|
||||||
ic29.lfo.rate = ic29.patchRam.lfoRate;
|
ic29.lfo.rate = ic29.patchRam.lfoRate;
|
||||||
|
|
||||||
// do filter values
|
|
||||||
*/
|
*/
|
||||||
|
// do filter values
|
||||||
}
|
}
|
||||||
|
|
||||||
void Voice::on(uint8_t key) {
|
void Voice::on(uint8_t key) {
|
||||||
@ -220,7 +225,7 @@ void Voice::on(uint8_t key) {
|
|||||||
phase = 0;
|
phase = 0;
|
||||||
}
|
}
|
||||||
note = key;
|
note = key;
|
||||||
if (env.phase == env.ENV_RLS) {
|
if (env.inRelease()) {
|
||||||
env.on(); // FIXME move to synth update code
|
env.on(); // FIXME move to synth update code
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ class LFO {
|
|||||||
class Envelope {
|
class Envelope {
|
||||||
public:
|
public:
|
||||||
Envelope();
|
Envelope();
|
||||||
|
|
||||||
void run();
|
void run();
|
||||||
void on() {
|
void on() {
|
||||||
phase = ENV_ATK;
|
phase = ENV_ATK;
|
||||||
@ -55,18 +56,20 @@ class Envelope {
|
|||||||
return phase == ENV_RLS;
|
return phase == ENV_RLS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static uint16_t atk, dcy, stn, rls;
|
||||||
|
|
||||||
uint16_t level;
|
uint16_t level;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const uint16_t atkTable[128];
|
||||||
|
static const uint16_t dcyTable[128];
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
ENV_ATK,
|
ENV_ATK,
|
||||||
ENV_DCY,
|
ENV_DCY,
|
||||||
ENV_RLS,
|
ENV_RLS,
|
||||||
ENV_IDLE
|
ENV_IDLE
|
||||||
} phase;
|
} phase;
|
||||||
|
|
||||||
private:
|
|
||||||
static const uint16_t atkTable[128];
|
|
||||||
static const uint16_t dcyTable[128];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Voice {
|
class Voice {
|
||||||
|
Loading…
Reference in New Issue
Block a user