diff --git a/plugin/module.cpp b/plugin/module.cpp index 8bcca79..d4d4cf1 100644 --- a/plugin/module.cpp +++ b/plugin/module.cpp @@ -39,6 +39,9 @@ void Module::run(Voice* voice) { sub = patchRam.sub / 127.0f; lfoPhase += lfoRateTable[patchRam.lfoRate]; + res = patchRam.vcfReso / 127.0 * 5; + noise = patchRam.noise / 127.0; + if (lfoPhase & 0x4000) lfo = 0x1fff - (lfoPhase & 0x3fff); else diff --git a/plugin/module.hpp b/plugin/module.hpp index ae4eee2..2a907c6 100644 --- a/plugin/module.hpp +++ b/plugin/module.hpp @@ -32,7 +32,7 @@ class Module { void run(Voice* voice); // Voice voices[NUM_VOICES]; - float vcfCutoff = 0, vcfReso = 0; + float res = 0; // precomputed values for all voices float pw; //, saw, square, sub; diff --git a/plugin/voice.cpp b/plugin/voice.cpp index 51291d0..924264f 100644 --- a/plugin/voice.cpp +++ b/plugin/voice.cpp @@ -98,14 +98,13 @@ void Voice::run(Module* m, float* buffer, uint32_t samples) { delay += m->sub * subosc; // delay += (1-(m->noisegen/(float)(1<<30))) * m->noise; FIXME figure out what to do about noise - //out = 0.5-(rand() & 0xffff) / 65536.0; + out += m->noise * (0.8-1.6 *(rand() & 0xffff) / 65536.0); out *= 0.5; - float res = 3; for (uint8_t ovs = 0; ovs < 4; ovs++) { fb = b4; // hard clip - fb = ((out*0.5) - fb) * res; + fb = ((out*0.5) - fb) * m->res; if (fb > 4) fb = 4; if (fb < -4) fb = -4; // fb = 1.5 * fb - 0.5 * fb * fb * fb;