now pulls some patch params from patchram
This commit is contained in:
parent
be894c562e
commit
66d2cec2c9
@ -24,10 +24,6 @@ Synth ic29;
|
|||||||
|
|
||||||
Synth::Synth() {
|
Synth::Synth() {
|
||||||
d_debug("initialising synth\n");
|
d_debug("initialising synth\n");
|
||||||
envAtk = 0x00;
|
|
||||||
envDcy = 0x1f;
|
|
||||||
envStn = 0x00;
|
|
||||||
envRls = 0x1f;
|
|
||||||
portaCoeff = 0x0;
|
portaCoeff = 0x0;
|
||||||
lfo.speed = 0x06;
|
lfo.speed = 0x06;
|
||||||
}
|
}
|
||||||
@ -56,9 +52,9 @@ void Synth::run() {
|
|||||||
// PWM is bit 0 sw2, 0 = fixed 1 = lfo
|
// PWM is bit 0 sw2, 0 = fixed 1 = lfo
|
||||||
// 0 sets EA to 0x3fff, 1 adds
|
// 0 sets EA to 0x3fff, 1 adds
|
||||||
uint16_t pwmVal = 0x2000 - ic29.lfo.lfoOut;
|
uint16_t pwmVal = 0x2000 - ic29.lfo.lfoOut;
|
||||||
if (0) pwmVal = 0x3fff;
|
if (ic29.patchRam.switch2 & 0x01) pwmVal = 0x3fff;
|
||||||
|
|
||||||
ic29.pwm = pwmVal / 40960.0f * (1); // 0.5 is knob val
|
ic29.pwm = 0.5 - pwmVal / 40960.0f * (ic29.patchRam.pwmLfoMod/128.0f);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < NUM_VOICES; i++) {
|
for (uint8_t i = 0; i < NUM_VOICES; i++) {
|
||||||
ic29.voices[i].update();
|
ic29.voices[i].update();
|
||||||
@ -111,10 +107,10 @@ Envelope::Envelope() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Envelope::run() {
|
void Envelope::run() {
|
||||||
uint16_t tempStn = ic29.envStn << 7;
|
uint16_t tempStn = ic29.patchRam.sustain << 7;
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case ENV_ATK:
|
case ENV_ATK:
|
||||||
level += atkTable[ic29.envAtk];
|
level += atkTable[ic29.patchRam.attack];
|
||||||
if (level > 0x3fff) {
|
if (level > 0x3fff) {
|
||||||
level = 0x3fff;
|
level = 0x3fff;
|
||||||
phase = ENV_DCY;
|
phase = ENV_DCY;
|
||||||
@ -122,13 +118,13 @@ void Envelope::run() {
|
|||||||
break;
|
break;
|
||||||
case ENV_DCY:
|
case ENV_DCY:
|
||||||
if (level > tempStn) {
|
if (level > tempStn) {
|
||||||
level = (((level - tempStn) * dcyTable[ic29.envDcy]) >> 16) + tempStn;
|
level = (((level - tempStn) * dcyTable[ic29.patchRam.decay]) >> 16) + tempStn;
|
||||||
} else {
|
} else {
|
||||||
level = tempStn;
|
level = tempStn;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ENV_RLS:
|
case ENV_RLS:
|
||||||
level = (level * dcyTable[ic29.envRls]) >> 16;
|
level = (level * dcyTable[ic29.patchRam.release]) >> 16;
|
||||||
break;
|
break;
|
||||||
case ENV_IDLE:
|
case ENV_IDLE:
|
||||||
default:
|
default:
|
||||||
@ -184,7 +180,12 @@ void Voice::update() {
|
|||||||
// calculate the once-per-block values
|
// calculate the once-per-block values
|
||||||
env.run();
|
env.run();
|
||||||
calcPitch();
|
calcPitch();
|
||||||
pw = 0.5 - ic29.pwm;
|
if (ic29.patchRam.switch1 & 0x08) pw = ic29.pwm;
|
||||||
|
else pw = 0;
|
||||||
|
|
||||||
|
saw = (float)((ic29.patchRam.switch1 & 0x10) == true);
|
||||||
|
sub = ic29.patchRam.subLevel / 128.0f;
|
||||||
|
|
||||||
// do filter values
|
// do filter values
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class LFO {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t
|
uint8_t
|
||||||
phase;
|
phase;
|
||||||
uint16_t holdoff;
|
uint16_t holdoff;
|
||||||
uint16_t envelope;
|
uint16_t envelope;
|
||||||
enum { LFO_RUN,
|
enum { LFO_RUN,
|
||||||
@ -79,10 +79,11 @@ class Voice {
|
|||||||
private:
|
private:
|
||||||
Envelope env; // calculated envelope value
|
Envelope env; // calculated envelope value
|
||||||
uint16_t pitch = 0x1818; // calculated pitch value with porta and master pitch etc
|
uint16_t pitch = 0x1818; // calculated pitch value with porta and master pitch etc
|
||||||
float delay; // delay slot for polyblep
|
float delay = 0; // delay slot for polyblep
|
||||||
bool pulseStage;
|
bool pulseStage = 0;
|
||||||
float pw, lastpw, pwrc;
|
float pw = 0, lastpw = 0, pwrc = 0;
|
||||||
float subosc = -1;
|
float subosc = -1;
|
||||||
|
float sub = 0, saw = 0;
|
||||||
float phase = 0, omega = 0;
|
float phase = 0, omega = 0;
|
||||||
enum { V_DONE,
|
enum { V_DONE,
|
||||||
V_OFF,
|
V_OFF,
|
||||||
@ -121,6 +122,26 @@ class Synth {
|
|||||||
|
|
||||||
float pwm;
|
float pwm;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint8_t lfoRate = 0x3f;
|
||||||
|
uint8_t lfoDelay = 0x00;
|
||||||
|
uint8_t vcoLfoMod = 0x00;
|
||||||
|
uint8_t pwmLfoMod = 0x27;
|
||||||
|
uint8_t noiseLevel = 0x00;
|
||||||
|
uint8_t vcfCutoff = 0x4d;
|
||||||
|
uint8_t vcfReso = 0x14;
|
||||||
|
uint8_t vcfEnvMod = 0x04;
|
||||||
|
uint8_t vcfLfoMod = 0x00;
|
||||||
|
uint8_t vcfKeyTrk = 0x6f;
|
||||||
|
uint8_t vcaLevel = 0x22;
|
||||||
|
uint8_t attack = 0x0d;
|
||||||
|
uint8_t decay = 0x57;
|
||||||
|
uint8_t sustain = 0x58;
|
||||||
|
uint8_t release = 0x23;
|
||||||
|
uint8_t subLevel = 0x0e;
|
||||||
|
uint8_t switch1 = 0x1a;
|
||||||
|
uint8_t switch2 = 0x10;
|
||||||
|
} patchRam;
|
||||||
};
|
};
|
||||||
|
|
||||||
// global
|
// global
|
||||||
|
@ -31,9 +31,9 @@ void Voice::run(float *buffer, uint32_t samples) {
|
|||||||
// generate a full block of samples for the oscillator
|
// generate a full block of samples for the oscillator
|
||||||
|
|
||||||
float y, out, t;
|
float y, out, t;
|
||||||
float saw = 0;
|
|
||||||
float gain = env.level / 16384.0;
|
float gain = env.level / 16384.0;
|
||||||
|
|
||||||
|
if (subosc > 0) subosc = sub; else subosc = -sub;
|
||||||
|
|
||||||
|
|
||||||
// this uses an adaptation of Mystran's Polyblep oscillator
|
// this uses an adaptation of Mystran's Polyblep oscillator
|
||||||
|
Loading…
Reference in New Issue
Block a user