From 4bf634a76736cf16c7010f12463c93893f3b81d4 Mon Sep 17 00:00:00 2001 From: Gordon JC Pearce Date: Fri, 9 Jan 2026 23:56:07 +0000 Subject: [PATCH] bunch of stuff to do with controls --- plugin/assigner.cpp | 7 +++-- plugin/module.cpp | 17 ++++++----- plugin/module.hpp | 4 +-- plugin/parameters.cpp | 67 +++++++++++++++++++++++++++++++------------ plugin/peacock.cpp | 1 + plugin/voice.cpp | 2 +- 6 files changed, 65 insertions(+), 33 deletions(-) diff --git a/plugin/assigner.cpp b/plugin/assigner.cpp index 7673ef5..05139f5 100644 --- a/plugin/assigner.cpp +++ b/plugin/assigner.cpp @@ -61,8 +61,10 @@ void Assigner::handleMidi(MidiEvent* ev) { break; case 0xb0: switch (ev->data[1]) { + case 0x01: // modwheel + printf("mod wheel %02x\n", ev->data[2]); + m->modWheel = ev->data[2]; // handle the following - // CC 1 - modwheel // CC 64 - sustain // FIXME sustain not implemented // possibly JU-06 CC values default: @@ -72,8 +74,7 @@ void Assigner::handleMidi(MidiEvent* ev) { case 0xc0: // program change break; case 0xe0: // pitch bend - m->bend = (int)(ev->data[1] + (ev->data[2]<<7))/2.6667; - //printf("pitch bend %04x\n", (ev->data[1] + (ev->data[2]<<7))); + m->bend = ((ev->data[1] + (ev->data[2]<<7))>>5)-0x100; break; case 0xf0: // sysex break; diff --git a/plugin/module.cpp b/plugin/module.cpp index 21bc2a3..28eb6dd 100644 --- a/plugin/module.cpp +++ b/plugin/module.cpp @@ -85,7 +85,7 @@ void Module::runLFO() { pw = (lfoState & 0x02) ? lfoPhase + 0x2000 : 0x2000 - lfoPhase; // PW LFO is unipolar pw = (patchRam.switch2 & 0x01) ? 0x3fff : pw; // either LFO or "all on" - pw = 0x3fff - ((pw * (int)(patchRam.pwmLfo * 1.45)) >> 7); // FIXME tidy up this bit + pw = 0x3fff - ((pw * (int)(patchRam.pwmLfo*0.9125)) >> 7); // FIXME tidy up this bit } void Module::run(Voice* voices, uint32_t blockSize) { @@ -101,9 +101,6 @@ void Module::run(Voice* voices, uint32_t blockSize) { master = powf(2, (patchRam.vca / 31.75 - 4.0f)) * 0.1; - // originally I had 0.28, 0.36, 0.4 - // measurement suggests that saw and square are around 100mV each with sub 160mV - square = (patchRam.switch1 & 0x08) ? 1 : 0; saw = (patchRam.switch1 & 0x10) ? 1 : 0; sub = (patchRam.sub / 127.0f) * 1.4; @@ -132,19 +129,21 @@ void Module::run(Voice* voices, uint32_t blockSize) { } lfoToVco = (lfoDepthTable[patchRam.vcoLfo] * lfoDelay) >> 8; // lookup table is 0-255 - lfoToVco += /* lfo from modwheel FIXME */ 0; + lfoToVco += ((int)(modWheel * modDepth)); + if (lfoToVco > 0xff) lfoToVco = 0xff; lfoToVco = (lfo * lfoToVco) >> 11; // 8 for normalisation plus three additional DSLR EA lfoToVcf = (patchRam.vcfLfo * lfoDelay) >> 7; // value is 0-127 lfoToVcf = (lfo * lfoToVcf) >> 9; // 8 for normalisation plus one additional DSLR EA - int16_t pitchBase = 0x0c18, vcfBase = 0; + int16_t pitchBase = 0x1818, vcfBase = 0; pitchBase += lfoToVco; - pitchBase += bend; + pitchBase += vcoBendDepth * bend; - vcfBase = (patchRam.vcfFreq << 7) + /* vcf bend FIXME */ 0; + vcfBase = (patchRam.vcfFreq << 7); vcfBase += lfoToVcf; + vcfBase += vcfBendDepth * bend; if (vcfBase > 0x3fff) vcfBase = 0x3fff; if (vcfBase < 0x0000) vcfBase = 0x0000; @@ -192,7 +191,7 @@ void Module::run(Voice* voices, uint32_t blockSize) { // per voice we need to calculate the key follow amount and envelope amount v->vcfCut = vcfBase + (((v->env * patchRam.vcfEnv) >> 7) * ((patchRam.switch2 & 0x02) ? -1 : 1)); - v->vcfCut += (int)((v->note - 36) * (patchRam.vcfKey << 1) * 0.375); + v->vcfCut += (int)((v->note - 60) * (patchRam.vcfKey << 1) * 0.375); if (v->vcfCut > 0x3fff) v->vcfCut = 0x3fff; if (v->vcfCut < 0) v->vcfCut = 0; diff --git a/plugin/module.hpp b/plugin/module.hpp index af24669..821620a 100644 --- a/plugin/module.hpp +++ b/plugin/module.hpp @@ -43,8 +43,8 @@ class Module { uint16_t a, d, s, r; float saw = 0, square = 0, sub = 0, noise = 0, master = 0; - int16_t bend = 0x0c00; - + int16_t bend = 0, modWheel=0; + float vcoBendDepth = 4, vcfBendDepth=1.5, modDepth=.5; struct { uint8_t lfoRate = 0x1f; uint8_t lfoDelay = 0x00; diff --git a/plugin/parameters.cpp b/plugin/parameters.cpp index e0460a4..5ef960e 100644 --- a/plugin/parameters.cpp +++ b/plugin/parameters.cpp @@ -309,19 +309,35 @@ void Peacock::initParameter(uint32_t index, Parameter& parameter) { enumValues[2].label = "Fast"; parameter.enumValues.values = enumValues; } - /* - case pModWheel: - parameter.hints = kParameterIsAutomatable | kParameterIsHidden; - parameter.name = "Mod wheel"; - parameter.symbol = "pfau_modwheel"; - parameter.ranges.min = 0.0f; - parameter.ranges.max = 127.0f; - parameter.ranges.def = 0.0f; - parameter.midiCC = 1; - break; - */ + break; + + case pVcoBend: + parameter.hints = kParameterIsAutomatable; + parameter.name = "VCO Bend"; + parameter.symbol = "pfau_vcobend"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 12.0f; + parameter.ranges.def = 4.0f; + break; + + case pVcfBend: + parameter.hints = kParameterIsAutomatable; + parameter.name = "VCF Bend"; + parameter.symbol = "pfau_vcfbend"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 42.0f; + parameter.ranges.def = 4.0f; + break; + + case pModDepth: + parameter.hints = kParameterIsAutomatable; + parameter.name = "Mod Depth"; + parameter.symbol = "pfau_moddepth"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 4.0f; + parameter.ranges.def = 0.5f; + break; } - // chorus, porta, bend range, key mode still to do } void Peacock::setParameterValue(uint32_t index, float value) { @@ -341,7 +357,7 @@ void Peacock::setParameterValue(uint32_t index, float value) { m->patchRam.vcoLfo = value; break; case pPWMDepth: - m->patchRam.pwmLfo = value / 1.27; + m->patchRam.pwmLfo = value; break; case pSubLevel: m->patchRam.sub = value; @@ -434,10 +450,15 @@ void Peacock::setParameterValue(uint32_t index, float value) { m->patchRam.switch2 &= 0xe7; m->patchRam.switch2 |= (3 - (int)value) << 3; break; - /* - case pModWheel: - //s.ff64 = (int)value << 1; - break;*/ + case pVcoBend: + m->vcoBendDepth = value; + break; + case pVcfBend: + m->vcfBendDepth = value / 2.66f; + break; + case pModDepth: + m->modDepth = value; + break; } } @@ -466,7 +487,7 @@ float Peacock::getParameterValue(uint32_t index) const { return m->patchRam.vcoLfo; break; case pPWMDepth: - return m->patchRam.pwmLfo * 1.27f; + return m->patchRam.pwmLfo; break; case pPWMMode: @@ -536,6 +557,16 @@ float Peacock::getParameterValue(uint32_t index) const { default: break; } + break; + case pVcoBend: + return m->vcoBendDepth; + break; + case pVcfBend: + return m->vcfBendDepth * 2.66f; + break; + case pModDepth: + return m->modDepth; + break; } return 0; } diff --git a/plugin/peacock.cpp b/plugin/peacock.cpp index 09b1211..a40beb4 100644 --- a/plugin/peacock.cpp +++ b/plugin/peacock.cpp @@ -28,6 +28,7 @@ Peacock::Peacock() : Plugin(parameterCount, 0, 0) { sampleRate = getSampleRate(); bufferSize = getBufferSize(); + chorus = new Chorus(); m = new Module(); ic1 = new Assigner; diff --git a/plugin/voice.cpp b/plugin/voice.cpp index 576c976..cd46732 100644 --- a/plugin/voice.cpp +++ b/plugin/voice.cpp @@ -60,7 +60,7 @@ void Voice::run(Module* m, float* buffer, uint32_t framePos, uint32_t samples) { cut = cut / (1 + cut); // correct tuning warp if (cut > 0.7) cut = 0.7; - float r = 5 * m->res; + float r = 6 * m->res; float amp = vcaEnv / 32768.0f;