Compare commits
No commits in common. "36c27f14d8fd07aed9541c1eeb5112edefc282e5" and "9d642475989cb42a586fc336545d2975df67b40b" have entirely different histories.
36c27f14d8
...
9d64247598
|
|
@ -63,7 +63,7 @@
|
||||||
pSustain,
|
pSustain,
|
||||||
pRelease,
|
pRelease,
|
||||||
|
|
||||||
pChorusMode,
|
pChorus,
|
||||||
|
|
||||||
parameterCount
|
parameterCount
|
||||||
};
|
};
|
||||||
|
|
|
||||||
31855
plugin/artwork.cpp
31855
plugin/artwork.cpp
File diff suppressed because it is too large
Load Diff
|
|
@ -110,10 +110,6 @@ void Assigner::noteOn(uint8_t note) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((noteTbl[voiceTbl[0]] & 0x80)) {
|
|
||||||
m->lfoRampOn();
|
|
||||||
}
|
|
||||||
|
|
||||||
// loop around the voices
|
// loop around the voices
|
||||||
for (i = NUM_VOICES - 1; i >= 0; i--) {
|
for (i = NUM_VOICES - 1; i >= 0; i--) {
|
||||||
v = voiceTbl[i];
|
v = voiceTbl[i];
|
||||||
|
|
@ -141,6 +137,6 @@ void Assigner::noteOn(uint8_t note) {
|
||||||
// printf("at end, l=%d e=%d\n", l,e);
|
// printf("at end, l=%d e=%d\n", l,e);
|
||||||
noteTbl[v] = note;
|
noteTbl[v] = note;
|
||||||
|
|
||||||
d_debug("send voice on %3d to voice %d", note, i);
|
d_debug("send voice on %3d to voice %d", note, v);
|
||||||
voice[v].on(note);
|
voice[v].on(note);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ class Assigner {
|
||||||
Assigner();
|
Assigner();
|
||||||
void handleMidi(MidiEvent* ev);
|
void handleMidi(MidiEvent* ev);
|
||||||
Voice* voice;
|
Voice* voice;
|
||||||
Module *m;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void noteOn(uint8_t note); // incoming note on (or off, if velocity = 0)
|
void noteOn(uint8_t note); // incoming note on (or off, if velocity = 0)
|
||||||
|
|
|
||||||
|
|
@ -147,7 +147,6 @@ void Chorus::setChorus(uint8_t mode) {
|
||||||
// switch chorus mode
|
// switch chorus mode
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 0x60:
|
case 0x60:
|
||||||
case 0x20:
|
|
||||||
gain = 0;
|
gain = 0;
|
||||||
break;
|
break;
|
||||||
case 0x40:
|
case 0x40:
|
||||||
|
|
|
||||||
|
|
@ -40,29 +40,9 @@ Module::~Module() {
|
||||||
delete subBuf;
|
delete subBuf;
|
||||||
delete pwmBuf;
|
delete pwmBuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::lfoRampOn() {
|
|
||||||
lfoDelayState = 1;
|
|
||||||
lfoDelayTimer = 0;
|
|
||||||
lfoDelay = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Module::run(Voice* voices, uint32_t blockSize) {
|
void Module::run(Voice* voices, uint32_t blockSize) {
|
||||||
// run updates for module board
|
// run updates for module board
|
||||||
|
|
||||||
if (lfoDelayState == 1) {
|
|
||||||
lfoDelayTimer += lfoDelayTable[patchRam.lfoDelay >> 4];
|
|
||||||
if (lfoDelayTimer & 0xc000) lfoDelayState = 2;
|
|
||||||
}
|
|
||||||
if ((lfoDelayState == 2)) {
|
|
||||||
lfoDelay += attackTable[patchRam.lfoDelay];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lfoDelay & 0xc000) {
|
|
||||||
lfoDelayState = 0;
|
|
||||||
lfoDelay = 0x3fff;
|
|
||||||
}
|
|
||||||
|
|
||||||
// FIXME break these out to the patch setter
|
// FIXME break these out to the patch setter
|
||||||
a = attackTable[patchRam.env_a]; // attack time coeff looked up in table
|
a = attackTable[patchRam.env_a]; // attack time coeff looked up in table
|
||||||
d = decayTable[patchRam.env_d]; // decay time coeff looked up in table
|
d = decayTable[patchRam.env_d]; // decay time coeff looked up in table
|
||||||
|
|
@ -74,7 +54,7 @@ void Module::run(Voice* voices, uint32_t blockSize) {
|
||||||
sub = patchRam.sub / 127.0f;
|
sub = patchRam.sub / 127.0f;
|
||||||
lfoPhase += lfoRateTable[patchRam.lfoRate];
|
lfoPhase += lfoRateTable[patchRam.lfoRate];
|
||||||
|
|
||||||
res = patchRam.vcfReso / 127.0;
|
res = patchRam.vcfReso / 127.0 * 5;
|
||||||
noise = patchRam.noise / 127.0;
|
noise = patchRam.noise / 127.0;
|
||||||
|
|
||||||
// FIXME the exp in these is expensive, don't call it all the time
|
// FIXME the exp in these is expensive, don't call it all the time
|
||||||
|
|
@ -90,8 +70,6 @@ void Module::run(Voice* voices, uint32_t blockSize) {
|
||||||
pw = 0.5 - ((0x2000 + lfo) * patchRam.pwmLfo) / (32768.0f * 128);
|
pw = 0.5 - ((0x2000 + lfo) * patchRam.pwmLfo) / (32768.0f * 128);
|
||||||
pw = (patchRam.switch2 & 0x01) ? 0.5 - (patchRam.pwmLfo / 256.0f) : pw;
|
pw = (patchRam.switch2 & 0x01) ? 0.5 - (patchRam.pwmLfo / 256.0f) : pw;
|
||||||
|
|
||||||
lfo = (lfo * lfoDelay) >> 14;
|
|
||||||
|
|
||||||
float master = powf(2, (patchRam.vca / 31.75 - 4.0f));
|
float master = powf(2, (patchRam.vca / 31.75 - 4.0f));
|
||||||
float sub = patchRam.sub/ 127.0f;
|
float sub = patchRam.sub/ 127.0f;
|
||||||
|
|
||||||
|
|
@ -104,13 +82,14 @@ void Module::run(Voice* voices, uint32_t blockSize) {
|
||||||
pwmBuf[i] = pwmRC;
|
pwmBuf[i] = pwmRC;
|
||||||
subBuf[i] = subRC;
|
subBuf[i] = subRC;
|
||||||
|
|
||||||
|
|
||||||
if (bufPtr < bufferSize) bufPtr++;
|
if (bufPtr < bufferSize) bufPtr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
int16_t vcf = (patchRam.vcfEnv << 7) * ((patchRam.switch2 & 0x02) ? -1 : 1);
|
int16_t vcf = (patchRam.vcfEnv << 7) * ((patchRam.switch2 & 0x02) ? -1 : 1);
|
||||||
|
|
||||||
int16_t pitchBase = 0x1818;
|
int16_t pitchBase = 0x1818;
|
||||||
pitchBase += (lfo * lfoDepthTable[patchRam.vcoLfo]) >> 11;
|
pitchBase += (lfo * lfoDepthTable[patchRam.vcoLfo]) >> 9;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < NUM_VOICES; i++) {
|
for (uint32_t i = 0; i < NUM_VOICES; i++) {
|
||||||
// maybe move all this into voice.cpp FIXME
|
// maybe move all this into voice.cpp FIXME
|
||||||
|
|
@ -142,13 +121,11 @@ void Module::run(Voice* voices, uint32_t blockSize) {
|
||||||
|
|
||||||
px *= (patchRam.switch1 & 0x07);
|
px *= (patchRam.switch1 & 0x07);
|
||||||
|
|
||||||
v->omega = px / (sampleRate * 8.0f); // fixme use proper scaler
|
v->omega = px / (sampleRate * 4.0f); // fixme use proper scaler
|
||||||
|
|
||||||
// per voice we need to calculate the key follow amount and envelope amount
|
// per voice we need to calculate the key follow amount and envelope amount
|
||||||
v->vcfCut = (patchRam.vcfFreq << 7) + ((vcf * v->env) >> 14);
|
v->vcfCut = (patchRam.vcfFreq << 7) + ((vcf * v->env) >> 14);
|
||||||
v->vcfCut += (lfo * patchRam.vcfLfo) >> 9;
|
v->vcfCut += (int)(v->note * (patchRam.vcfKey << 1) * 0.375);
|
||||||
|
|
||||||
v->vcfCut += (int)((v->note - 36) * (patchRam.vcfKey << 1) * 0.375);
|
|
||||||
|
|
||||||
if (v->vcfCut > 0x3fff) v->vcfCut = 0x3fff;
|
if (v->vcfCut > 0x3fff) v->vcfCut = 0x3fff;
|
||||||
if (v->vcfCut < 0) v->vcfCut = 0;
|
if (v->vcfCut < 0) v->vcfCut = 0;
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,6 @@ class Module {
|
||||||
Module();
|
Module();
|
||||||
~Module();
|
~Module();
|
||||||
|
|
||||||
void lfoRampOn();
|
|
||||||
|
|
||||||
void run(Voice* voices, uint32_t blockLeft);
|
void run(Voice* voices, uint32_t blockLeft);
|
||||||
|
|
||||||
float res = 0;
|
float res = 0;
|
||||||
|
|
@ -48,50 +46,27 @@ class Module {
|
||||||
|
|
||||||
float saw = 0, square = 0, sub = 0, noise = 0;
|
float saw = 0, square = 0, sub = 0, noise = 0;
|
||||||
|
|
||||||
#if 0
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t lfoRate = 0x58;
|
uint8_t lfoRate = 0x18;
|
||||||
uint8_t lfoDelay = 0x00;
|
uint8_t lfoDelay = 0x00;
|
||||||
uint8_t vcoLfo = 0x00;
|
uint8_t vcoLfo = 0x00;
|
||||||
uint8_t pwmLfo = 0x3b;
|
uint8_t pwmLfo = 0x60;
|
||||||
uint8_t noise = 0x00;
|
uint8_t noise = 0x00;
|
||||||
uint8_t vcfFreq = 0x25; // 1c; // 0x3f80
|
uint8_t vcfFreq = 0x30; // 1c; // 0x3f80
|
||||||
uint8_t vcfReso = 0x6a;
|
uint8_t vcfReso = 0x00;
|
||||||
uint8_t vcfEnv = 0x25; // 4e;
|
uint8_t vcfEnv = 0x40; // 4e;
|
||||||
uint8_t vcfLfo = 0x00;
|
uint8_t vcfLfo = 0;
|
||||||
uint8_t vcfKey = 0x00; // 47;
|
uint8_t vcfKey = 0x7f; // 47;
|
||||||
uint8_t vca = 0x35;
|
uint8_t vca = 0x28;
|
||||||
uint8_t env_a = 0x00;
|
uint8_t env_a = 0x00;
|
||||||
uint8_t env_d = 0x3c;
|
uint8_t env_d = 0x39;
|
||||||
uint8_t env_s = 0x00; // 0x3f80
|
uint8_t env_s = 0x30; // 0x3f80
|
||||||
uint8_t env_r = 0x3c;
|
uint8_t env_r = 0x30;
|
||||||
uint8_t sub = 0x7f;
|
uint8_t sub = 0x40;
|
||||||
uint8_t switch1 = 0x4a;
|
uint8_t switch1 = 0x59;
|
||||||
uint8_t switch2 = 0x18;
|
uint8_t switch2 = 0x18;
|
||||||
} patchRam;
|
} patchRam;
|
||||||
|
|
||||||
#else
|
|
||||||
struct {
|
|
||||||
uint8_t lfoRate = 0x40;
|
|
||||||
uint8_t lfoDelay = 0x00;
|
|
||||||
uint8_t vcoLfo = 0x00;
|
|
||||||
uint8_t pwmLfo = 0x00;
|
|
||||||
uint8_t noise = 0x01;
|
|
||||||
uint8_t vcfFreq = 0x31;
|
|
||||||
uint8_t vcfReso = 0x7f;
|
|
||||||
uint8_t vcfEnv = 0x00;
|
|
||||||
uint8_t vcfLfo = 0x00;
|
|
||||||
uint8_t vcfKey = 0x7f;
|
|
||||||
uint8_t vca = 0x40;
|
|
||||||
uint8_t env_a = 0x00;
|
|
||||||
uint8_t env_d = 0x00;
|
|
||||||
uint8_t env_s = 0x00; // 0x3f80
|
|
||||||
uint8_t env_r = 0x00;
|
|
||||||
uint8_t sub = 0x00;
|
|
||||||
uint8_t switch1 = 0x22;
|
|
||||||
uint8_t switch2 = 0x1d;
|
|
||||||
} patchRam;
|
|
||||||
#endif
|
|
||||||
Chorus* chorus;
|
Chorus* chorus;
|
||||||
|
|
||||||
float vcaTC;
|
float vcaTC;
|
||||||
|
|
@ -106,9 +81,7 @@ class Module {
|
||||||
float pwmTC = 0, subTC = 0, mVcaTC = 0;
|
float pwmTC = 0, subTC = 0, mVcaTC = 0;
|
||||||
float pwmRC = 0, subRC = 0, vcaRC = 0;
|
float pwmRC = 0, subRC = 0, vcaRC = 0;
|
||||||
|
|
||||||
uint16_t lfoDelay = 0;
|
// controls
|
||||||
uint8_t lfoDelayState = 0;
|
|
||||||
uint16_t lfoDelayTimer = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Voice {
|
class Voice {
|
||||||
|
|
@ -135,8 +108,7 @@ class Voice {
|
||||||
uint8_t note = 0;
|
uint8_t note = 0;
|
||||||
|
|
||||||
// filter
|
// filter
|
||||||
float y0 = 0, y1 = 0, y2 = 0, y3 = 0;
|
float b1 = 0, b2 = 0, b3 = 0, b4 = 0;
|
||||||
double s[4] = {0, 0, 0, 0};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pLFORate:
|
case pLFORate:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "LFO Rate";
|
parameter.name = "LFO Rate";
|
||||||
parameter.symbol = "pfau_lforate";
|
parameter.symbol = "ch_lforate";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 48.0f;
|
parameter.ranges.def = 48.0f;
|
||||||
|
|
@ -33,7 +33,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pLFODelay:
|
case pLFODelay:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "LFO Delay";
|
parameter.name = "LFO Delay";
|
||||||
parameter.symbol = "pfau_lfodelay";
|
parameter.symbol = "ch_lfodelay";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 0.0f;
|
parameter.ranges.def = 0.0f;
|
||||||
|
|
@ -43,7 +43,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pVCORange:
|
case pVCORange:
|
||||||
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
||||||
parameter.name = "Range";
|
parameter.name = "Range";
|
||||||
parameter.symbol = "pfau_vcorange";
|
parameter.symbol = "ch_vcorange";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 2.0f;
|
parameter.ranges.max = 2.0f;
|
||||||
parameter.ranges.def = 1.0f;
|
parameter.ranges.def = 1.0f;
|
||||||
|
|
@ -66,7 +66,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pLFODepth:
|
case pLFODepth:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "LFO";
|
parameter.name = "LFO";
|
||||||
parameter.symbol = "pfau_lfo";
|
parameter.symbol = "ch_lfo";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 10.0f;
|
parameter.ranges.def = 10.0f;
|
||||||
|
|
@ -76,7 +76,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pPWMDepth:
|
case pPWMDepth:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "PWM";
|
parameter.name = "PWM";
|
||||||
parameter.symbol = "pfau_pwm";
|
parameter.symbol = "ch_pwm";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 48.0f;
|
parameter.ranges.def = 48.0f;
|
||||||
|
|
@ -86,7 +86,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pPWMMode:
|
case pPWMMode:
|
||||||
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;
|
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;
|
||||||
parameter.name = "PWM Mode";
|
parameter.name = "PWM Mode";
|
||||||
parameter.symbol = "pfau_pwmmode";
|
parameter.symbol = "ch_pwmmode";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 1.0f;
|
parameter.ranges.max = 1.0f;
|
||||||
parameter.ranges.def = 1.0f;
|
parameter.ranges.def = 1.0f;
|
||||||
|
|
@ -107,7 +107,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pSaw:
|
case pSaw:
|
||||||
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;
|
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;
|
||||||
parameter.name = "Saw";
|
parameter.name = "Saw";
|
||||||
parameter.symbol = "pfau_saw";
|
parameter.symbol = "ch_saw";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 1.0f;
|
parameter.ranges.max = 1.0f;
|
||||||
parameter.ranges.def = 1.0f;
|
parameter.ranges.def = 1.0f;
|
||||||
|
|
@ -117,7 +117,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pSqr:
|
case pSqr:
|
||||||
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;
|
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;
|
||||||
parameter.name = "Square";
|
parameter.name = "Square";
|
||||||
parameter.symbol = "pfau_sqr";
|
parameter.symbol = "ch_sqr";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 1.0f;
|
parameter.ranges.max = 1.0f;
|
||||||
parameter.ranges.def = 1.0f;
|
parameter.ranges.def = 1.0f;
|
||||||
|
|
@ -127,7 +127,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pSubLevel:
|
case pSubLevel:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "Sub Osc";
|
parameter.name = "Sub Osc";
|
||||||
parameter.symbol = "pfau_sub";
|
parameter.symbol = "ch_sub";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 0.0f;
|
parameter.ranges.def = 0.0f;
|
||||||
|
|
@ -137,7 +137,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pNoiseLevel:
|
case pNoiseLevel:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "Noise";
|
parameter.name = "Noise";
|
||||||
parameter.symbol = "pfau_noise";
|
parameter.symbol = "ch_noise";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 0.0f;
|
parameter.ranges.def = 0.0f;
|
||||||
|
|
@ -147,7 +147,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pHPF:
|
case pHPF:
|
||||||
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
||||||
parameter.name = "HPF";
|
parameter.name = "HPF";
|
||||||
parameter.symbol = "pfau_hpf";
|
parameter.symbol = "ch_hpf";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 3.9f;
|
parameter.ranges.max = 3.9f;
|
||||||
parameter.ranges.def = 0.0f;
|
parameter.ranges.def = 0.0f;
|
||||||
|
|
@ -157,7 +157,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pCutoff:
|
case pCutoff:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "Freq";
|
parameter.name = "Freq";
|
||||||
parameter.symbol = "pfau_freq";
|
parameter.symbol = "ch_freq";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 60.0f;
|
parameter.ranges.def = 60.0f;
|
||||||
|
|
@ -166,7 +166,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pRes:
|
case pRes:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "Res";
|
parameter.name = "Res";
|
||||||
parameter.symbol = "pfau_reso";
|
parameter.symbol = "ch_reso";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 0.0f;
|
parameter.ranges.def = 0.0f;
|
||||||
|
|
@ -175,7 +175,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pVCFPol:
|
case pVCFPol:
|
||||||
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
||||||
parameter.name = "Polarity";
|
parameter.name = "Polarity";
|
||||||
parameter.symbol = "pfau_vcfmode";
|
parameter.symbol = "ch_vcfmode";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 1.0f;
|
parameter.ranges.max = 1.0f;
|
||||||
parameter.ranges.def = 0.0f;
|
parameter.ranges.def = 0.0f;
|
||||||
|
|
@ -195,7 +195,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pEnv:
|
case pEnv:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "Env";
|
parameter.name = "Env";
|
||||||
parameter.symbol = "pfau_vcfenv";
|
parameter.symbol = "ch_vcfenv";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 46.0f;
|
parameter.ranges.def = 46.0f;
|
||||||
|
|
@ -204,7 +204,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pLfo:
|
case pLfo:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "LFO";
|
parameter.name = "LFO";
|
||||||
parameter.symbol = "pfau_vcflfo";
|
parameter.symbol = "ch_vcflfo";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 0.0f;
|
parameter.ranges.def = 0.0f;
|
||||||
|
|
@ -213,7 +213,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pKyb:
|
case pKyb:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "Kybd";
|
parameter.name = "Kybd";
|
||||||
parameter.symbol = "pfau_vcfkey";
|
parameter.symbol = "ch_vcfkey";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 71.0f;
|
parameter.ranges.def = 71.0f;
|
||||||
|
|
@ -223,7 +223,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pAttack:
|
case pAttack:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "Attack";
|
parameter.name = "Attack";
|
||||||
parameter.symbol = "pfau_attack";
|
parameter.symbol = "ch_attack";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 27.0f;
|
parameter.ranges.def = 27.0f;
|
||||||
|
|
@ -233,7 +233,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pDecay:
|
case pDecay:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "Decay";
|
parameter.name = "Decay";
|
||||||
parameter.symbol = "pfau_decay";
|
parameter.symbol = "ch_decay";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 57.0f;
|
parameter.ranges.def = 57.0f;
|
||||||
|
|
@ -243,7 +243,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pSustain:
|
case pSustain:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "Sustain";
|
parameter.name = "Sustain";
|
||||||
parameter.symbol = "pfau_sustain";
|
parameter.symbol = "ch_sustain";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 57.0f;
|
parameter.ranges.def = 57.0f;
|
||||||
|
|
@ -253,7 +253,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pRelease:
|
case pRelease:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "Release";
|
parameter.name = "Release";
|
||||||
parameter.symbol = "pfau_release";
|
parameter.symbol = "ch_release";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 48.0f;
|
parameter.ranges.def = 48.0f;
|
||||||
|
|
@ -263,7 +263,7 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pEnvGate:
|
case pEnvGate:
|
||||||
parameter.hints = kParameterIsAutomatable | kParameterIsInteger; // | kParameterIsBoolean;
|
parameter.hints = kParameterIsAutomatable | kParameterIsInteger; // | kParameterIsBoolean;
|
||||||
parameter.name = "Env-Gate";
|
parameter.name = "Env-Gate";
|
||||||
parameter.symbol = "pfau_envgate";
|
parameter.symbol = "ch_envgate";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 1.0f;
|
parameter.ranges.max = 1.0f;
|
||||||
parameter.ranges.def = 0.0f;
|
parameter.ranges.def = 0.0f;
|
||||||
|
|
@ -283,39 +283,17 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) {
|
||||||
case pVCALevel:
|
case pVCALevel:
|
||||||
parameter.hints = kParameterIsAutomatable;
|
parameter.hints = kParameterIsAutomatable;
|
||||||
parameter.name = "VCA Level";
|
parameter.name = "VCA Level";
|
||||||
parameter.symbol = "pfau_vcalevel";
|
parameter.symbol = "ch_vcalevel";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 40.0f;
|
parameter.ranges.def = 40.0f;
|
||||||
parameter.midiCC = 26;
|
parameter.midiCC = 26;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case pChorusMode:
|
|
||||||
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
|
||||||
parameter.name = "Chorus";
|
|
||||||
parameter.symbol = "pfau_chorus";
|
|
||||||
parameter.ranges.min = 0.0f;
|
|
||||||
parameter.ranges.max = 2.0f;
|
|
||||||
parameter.ranges.def = 0.0f;
|
|
||||||
parameter.midiCC = 93;
|
|
||||||
parameter.enumValues.count = 3;
|
|
||||||
parameter.enumValues.restrictedMode = true;
|
|
||||||
{
|
|
||||||
ParameterEnumerationValue* const enumValues = new ParameterEnumerationValue[3];
|
|
||||||
enumValues[0].value = 0.0f;
|
|
||||||
enumValues[0].label = "Off";
|
|
||||||
enumValues[1].value = 1.0f;
|
|
||||||
enumValues[1].label = "Slow";
|
|
||||||
enumValues[2].value = 2.0f;
|
|
||||||
enumValues[2].label = "Fast";
|
|
||||||
parameter.enumValues.values = enumValues;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
case pModWheel:
|
case pModWheel:
|
||||||
parameter.hints = kParameterIsAutomatable | kParameterIsHidden;
|
parameter.hints = kParameterIsAutomatable | kParameterIsHidden;
|
||||||
parameter.name = "Mod wheel";
|
parameter.name = "Mod wheel";
|
||||||
parameter.symbol = "pfau_modwheel";
|
parameter.symbol = "ch_modwheel";
|
||||||
parameter.ranges.min = 0.0f;
|
parameter.ranges.min = 0.0f;
|
||||||
parameter.ranges.max = 127.0f;
|
parameter.ranges.max = 127.0f;
|
||||||
parameter.ranges.def = 0.0f;
|
parameter.ranges.def = 0.0f;
|
||||||
|
|
@ -401,7 +379,7 @@ void Peacock::setParameterValue(uint32_t index, float value) {
|
||||||
m->patchRam.switch1 |= (value >= 0.5) << 4;
|
m->patchRam.switch1 |= (value >= 0.5) << 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case pChorusMode:
|
case pChorus:
|
||||||
m->patchRam.switch1 &= 0x9f;
|
m->patchRam.switch1 &= 0x9f;
|
||||||
|
|
||||||
switch ((int)value) {
|
switch ((int)value) {
|
||||||
|
|
@ -528,7 +506,7 @@ float Peacock::getParameterValue(uint32_t index) const {
|
||||||
case pVCALevel:
|
case pVCALevel:
|
||||||
return m->patchRam.vca;
|
return m->patchRam.vca;
|
||||||
break;
|
break;
|
||||||
case pChorusMode:
|
case pChorus:
|
||||||
|
|
||||||
switch (m->patchRam.switch1 & 0x60) {
|
switch (m->patchRam.switch1 & 0x60) {
|
||||||
case 0x60:
|
case 0x60:
|
||||||
|
|
@ -540,6 +518,8 @@ float Peacock::getParameterValue(uint32_t index) const {
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ Peacock::Peacock() : Plugin(parameterCount, 0, 0) {
|
||||||
m = new Module();
|
m = new Module();
|
||||||
ic1 = new Assigner;
|
ic1 = new Assigner;
|
||||||
ic1->voice = voice;
|
ic1->voice = voice;
|
||||||
ic1->m = m;
|
|
||||||
m->chorus = chorus;
|
m->chorus = chorus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -268,7 +268,7 @@ void DistrhoUIPeacock::parameterChanged(uint32_t index, float value) {
|
||||||
sw1 |= (value > 0.5) << 4;
|
sw1 |= (value > 0.5) << 4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case pChorusMode:
|
case pChorus:
|
||||||
sw1 &= 0x9f;
|
sw1 &= 0x9f;
|
||||||
// 60, 40, 00
|
// 60, 40, 00
|
||||||
switch ((int)value) {
|
switch ((int)value) {
|
||||||
|
|
@ -325,15 +325,15 @@ void DistrhoUIPeacock::imageButtonClicked(ImageButton* imgBtn, int) {
|
||||||
break;
|
break;
|
||||||
case btnCh0:
|
case btnCh0:
|
||||||
sw1 = (sw1 & 0x9f) | 0x20;
|
sw1 = (sw1 & 0x9f) | 0x20;
|
||||||
setParameterValue(pChorusMode, 0);
|
setParameterValue(pChorus, 0);
|
||||||
break;
|
break;
|
||||||
case btnCh1:
|
case btnCh1:
|
||||||
sw1 = (sw1 & 0x9f) | 0x40;
|
sw1 = (sw1 & 0x9f) | 0x40;
|
||||||
setParameterValue(pChorusMode, 1);
|
setParameterValue(pChorus, 1);
|
||||||
break;
|
break;
|
||||||
case btnCh2:
|
case btnCh2:
|
||||||
sw1 = (sw1 & 0x9f);
|
sw1 = (sw1 & 0x9f);
|
||||||
setParameterValue(pChorusMode, 2);
|
setParameterValue(pChorus, 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
123
plugin/voice.cpp
123
plugin/voice.cpp
|
|
@ -40,9 +40,11 @@ Voice::Voice() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Voice::on(uint8_t midiNote) {
|
void Voice::on(uint8_t midiNote) {
|
||||||
while (midiNote < 24) midiNote += 12;
|
// omega = 261.63 * powf(2, (note - 60) / 12.0f) / 48000.0f;
|
||||||
while (midiNote > 108) midiNote -=12;
|
if (midiNote > 24)
|
||||||
note = midiNote - 24;
|
note = midiNote - 24;
|
||||||
|
else
|
||||||
|
note = 24;
|
||||||
envPhase = 1;
|
envPhase = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,46 +52,16 @@ void Voice::off() {
|
||||||
envPhase = 0;
|
envPhase = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// tanh(x)/x approximation, flatline at very high inputs
|
|
||||||
// so might not be safe for very large feedback gains
|
|
||||||
// [limit is 1/15 so very large means ~15 or +23dB]
|
|
||||||
|
|
||||||
|
|
||||||
double tanhXdX(double x) {
|
|
||||||
|
|
||||||
return 1-0.1*abs(x);
|
|
||||||
double a = x*x;
|
|
||||||
// IIRC I got this as Pade-approx for tanh(sqrt(x))/sqrt(x)
|
|
||||||
return ((a + 105)*a + 945) / ((15*a + 420)*a + 945);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Voice::run(Module* m, float* buffer, uint32_t samples) {
|
void Voice::run(Module* m, float* buffer, uint32_t samples) {
|
||||||
// carry out per-voice calculations for each block of samples
|
// carry out per-voice calculations for each block of samples
|
||||||
float out, t, fb;
|
float out, t, fb;
|
||||||
|
|
||||||
double zi;
|
// FIXME incorrect
|
||||||
|
|
||||||
|
|
||||||
// calculate cutoff frequency
|
// calculate cutoff frequency
|
||||||
float cut = 248.0f * (powf(2, (vcfCut - 0x1880) / 1143.0f));
|
float cut = 248.0f * (powf(2, (vcfCut - 0x1880) / 1143.0f));
|
||||||
cut = M_PI * cut / sampleRate;
|
cut = 0.25 * 6.2832 * cut / 48000.0f; // FIXME hardcoded values
|
||||||
cut = cut / (1 + cut); // correct tuning warp
|
cut = cut / (1 + cut); // correct tuning warp
|
||||||
|
|
||||||
|
|
||||||
// printf("%f\n", cut);
|
|
||||||
|
|
||||||
//if (cut > 0.5) cut = 0.5;
|
|
||||||
|
|
||||||
// double f = tan(cut);
|
|
||||||
|
|
||||||
|
|
||||||
//printf("cut = %4f f = %4f\n", cut, f);
|
|
||||||
|
|
||||||
double r = (40.0/9.0) * m->res;
|
|
||||||
|
|
||||||
|
|
||||||
float amp = vcaEnv / 4096.0f;
|
float amp = vcaEnv / 4096.0f;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < samples; i++) {
|
for (uint32_t i = 0; i < samples; i++) {
|
||||||
|
|
@ -128,80 +100,13 @@ double zi;
|
||||||
delay += m->subBuf[i] * subosc ;
|
delay += m->subBuf[i] * subosc ;
|
||||||
|
|
||||||
out += m->noise * (0.8 - 1.6 * (rand() & 0xffff) / 65536.0);
|
out += m->noise * (0.8 - 1.6 * (rand() & 0xffff) / 65536.0);
|
||||||
out *= 0.01;
|
out *= 0.5;
|
||||||
|
|
||||||
// same time constant for both VCF and VCF RC circuits
|
// same time constant for both VCF and VCF RC circuits
|
||||||
vcfRC = (cut - vcfRC) * m->vcaTC + vcfRC;
|
vcfRC = (cut - vcfRC) * m->vcaTC + vcfRC;
|
||||||
|
|
||||||
#if 1
|
|
||||||
|
|
||||||
//// LICENSE TERMS: Copyright 2012 Teemu Voipio
|
|
||||||
//
|
|
||||||
// You can use this however you like for pretty much any purpose,
|
|
||||||
// as long as you don't claim you wrote it. There is no warranty.
|
|
||||||
//
|
|
||||||
// Distribution of substantial portions of this code in source form
|
|
||||||
// must include this copyright notice and list of conditions.
|
|
||||||
//
|
|
||||||
|
|
||||||
// input delay and state for member variables
|
|
||||||
|
|
||||||
// cutoff as normalized frequency (eg 0.5 = Nyquist)
|
|
||||||
// resonance from 0 to 1, self-oscillates at settings over 0.9
|
|
||||||
//void transistorLadder(
|
|
||||||
// double cutoff, double resonance,
|
|
||||||
// double * in, double * out, unsigned nsamples)
|
|
||||||
//{
|
|
||||||
// tuning and feedback
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------ sample loop
|
|
||||||
//for(unsigned n = 0; n < nsamples; ++n)
|
|
||||||
//{
|
|
||||||
// input with half delay, for non-linearities
|
|
||||||
double ih = 0.5 * (out + zi); zi = out;
|
|
||||||
|
|
||||||
//double ih = out;
|
|
||||||
|
|
||||||
// evaluate the non-linear gains
|
|
||||||
double t0 = tanhXdX((ih * (r+1))- r * s[3]);
|
|
||||||
|
|
||||||
double t1 = tanhXdX(s[0]);
|
|
||||||
double t2 = tanhXdX(s[1]);
|
|
||||||
double t3 = tanhXdX(s[2]);
|
|
||||||
double t4 = tanhXdX(s[3]);
|
|
||||||
|
|
||||||
double f = vcfRC;
|
|
||||||
|
|
||||||
// g# the denominators for solutions of individual stages
|
|
||||||
double g0 = 1 / (1 + f*t1), g1 = 1 / (1 + f*t2);
|
|
||||||
double g2 = 1 / (1 + f*t3), g3 = 1 / (1 + f*t4);
|
|
||||||
|
|
||||||
// f# are just factored out of the feedback solution
|
|
||||||
double f3 = f*t3*g3, f2 = f*t2*g2*f3, f1 = f*t1*g1*f2, f0 = f*t0*g0*f1;
|
|
||||||
|
|
||||||
// solve feedback
|
|
||||||
double y3 = (g3*s[3] + f3*g2*s[2] + f2*g1*s[1] + f1*g0*s[0] + f0*out) / (1 + r*f0);
|
|
||||||
|
|
||||||
// then solve the remaining outputs (with the non-linear gains here)
|
|
||||||
double xx = t0*((out * (r+1)) - r*y3);
|
|
||||||
double y0 = t1*g0*(s[0] + f*xx);
|
|
||||||
double y1 = t2*g1*(s[1] + f*y0);
|
|
||||||
double y2 = t3*g2*(s[2] + f*y1);
|
|
||||||
|
|
||||||
// update state
|
|
||||||
s[0] += 2*f * (xx - y0);
|
|
||||||
s[1] += 2*f * (y0 - y1);
|
|
||||||
s[2] += 2*f * (y1 - y2);
|
|
||||||
s[3] += 2*f * (y2 - t4*y3);
|
|
||||||
|
|
||||||
//out[n] = y3;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
for (uint8_t ovs = 0; ovs < 4; ovs++) {
|
for (uint8_t ovs = 0; ovs < 4; ovs++) {
|
||||||
fb = y3;
|
fb = b4;
|
||||||
// hard clip
|
// hard clip
|
||||||
fb = ((out * 0.5) - fb) * m->res;
|
fb = ((out * 0.5) - fb) * m->res;
|
||||||
if (fb > 4) fb = 4;
|
if (fb > 4) fb = 4;
|
||||||
|
|
@ -209,14 +114,14 @@ double zi;
|
||||||
// fb = 1.5 * fb - 0.5 * fb * fb * fb;
|
// fb = 1.5 * fb - 0.5 * fb * fb * fb;
|
||||||
//
|
//
|
||||||
|
|
||||||
y0 = ((out + fb - y0) * vcfRC) + y0;
|
b1 = ((out + fb - b1) * vcfRC) + b1;
|
||||||
y1 = ((y0 - y1) * vcfRC) + y1;
|
b2 = ((b1 - b2) * vcfRC) + b2;
|
||||||
y2 = ((y1 - y2) * vcfRC) + y2;
|
b3 = ((b2 - b3) * vcfRC) + b3;
|
||||||
y3 = ((y2 - y3) * vcfRC) + y3;
|
b4 = ((b3 - b4) * vcfRC) + b4;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
vcaRC = (amp - vcaRC) * m->vcaTC + vcaRC;
|
vcaRC = (amp - vcaRC) * m->vcaTC + vcaRC;
|
||||||
buffer[i] += 1 * m->vcaBuf[i] * vcaRC * y3;
|
buffer[i] += 0.09367 * m->vcaBuf[i] * vcaRC * b4;
|
||||||
|
|
||||||
lastpw = m->pwmBuf[i];
|
lastpw = m->pwmBuf[i];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue