diff --git a/plugin/chorus.cpp b/plugin/chorus.cpp index d181c6c..06b4f92 100644 --- a/plugin/chorus.cpp +++ b/plugin/chorus.cpp @@ -29,8 +29,8 @@ Chorus::Chorus() { lfoPhase = 1; lfoSpeed = 6.283 * 10.7 / sampleRate; // plainly silly value to show if it hasn't been set - gainTC = 1 - exp(-6.283 * 10 / sampleRate); // 1/10th of a second declick - bbdTC = 1 - exp(-6.283 * 30 / sampleRate); // hpf into BBD at 159Hz + gainTC = 1 - exp(-M_PI * 10 / sampleRate); // 1/10th of a second declick + bbdTC = 1 - exp(-M_PI * 60 / sampleRate); // hpf into BBD // not quite Butterworth but you'd never hear the difference // these are calculated from the real-world component values @@ -127,11 +127,11 @@ void Chorus::setHpf(uint8_t mode) { // k = 1-exp(-2pi * Fc * sampleRate) switch (mode) { case 0x00: - hpCut = 1 - exp(-6.283 * 720 / sampleRate); + hpCut = 1 - exp(-M_PI * 720 / sampleRate); hpGain = -1; break; case 0x08: - hpCut = 1 - exp(-6.283 * 225 / sampleRate); + hpCut = 1 - exp(-M_PI * 225 / sampleRate); hpGain = -1; break; case 0x10: @@ -139,7 +139,7 @@ void Chorus::setHpf(uint8_t mode) { hpGain = 0; break; case 0x18: - hpCut = 1 - exp(-6.283 * 85 / sampleRate); + hpCut = 1 - exp(-M_PI * 85 / sampleRate); hpGain = 1.707; break; } @@ -154,11 +154,11 @@ void Chorus::setChorus(uint8_t mode) { break; case 0x40: gain = 1.2; - lfoSpeed = 6.283 * 0.525 / sampleRate / 2; + lfoSpeed = M_PI * 0.525 / sampleRate; break; case 0x00: gain = 1.2; - lfoSpeed = 6.283 * 0.85 / sampleRate / 2; + lfoSpeed = M_PI * 0.85 / sampleRate; break; } } diff --git a/plugin/module.cpp b/plugin/module.cpp index c174ec9..6f55c87 100644 --- a/plugin/module.cpp +++ b/plugin/module.cpp @@ -25,9 +25,9 @@ Module::Module() { // cutoff frequencies for various RC networks - vcaTC = 1 - exp(-6.283 * 159 / sampleRate); // VCA and VCF 10k/0.1u time constant - subTC = 1 - exp(-6.283 * 15 / sampleRate); // Main VCA and Sub Level 1k + 10u time constant - pwmTC = 1 - exp(-6.283 * 40 / sampleRate); // integrator with 100k/0.047u time constant + vcaTC = 1 - exp(-M_PI * 159 / sampleRate); // VCA and VCF 10k/0.1u time constant + subTC = 1 - exp(-M_PI * 15 / sampleRate); // Main VCA and Sub Level 1k + 10u time constant + pwmTC = 1 - exp(-M_PI * 40 / sampleRate); // integrator with 100k/0.047u time constant vcaBuf = new float[bufferSize]; subBuf = new float[bufferSize]; @@ -104,12 +104,12 @@ void Module::run(Voice* voices, uint32_t blockSize) { // 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) ? 0.3 : 0; - saw = (patchRam.switch1 & 0x10) ? .3 : 0; - sub = (patchRam.sub / 127.0f) * 0.48; + square = (patchRam.switch1 & 0x08) ? 1 : 0; + saw = (patchRam.switch1 & 0x10) ? 1 : 0; + sub = (patchRam.sub / 127.0f) * 1.6; res = patchRam.vcfReso / 127.0; - noise = (patchRam.noise / 127.0) * 0.4; + noise = (patchRam.noise / 127.0); // FIXME the exp in these is expensive, don't call it all the time chorus->setChorus(patchRam.switch1 & 0x60); @@ -183,7 +183,7 @@ void Module::run(Voice* voices, uint32_t blockSize) { v->omega = px / (sampleRate * 8.0f); // FIXME recalculate table using proper scaler // per voice we need to calculate the key follow amount and envelope amount - v->vcfCut = vcfBase + (((v->env * patchRam.vcfEnv)>>7) * ((patchRam.switch1 & 0x02) ? -1 : 1)); + v->vcfCut = vcfBase + (((v->env * patchRam.vcfEnv)>>7) * ((patchRam.switch2 & 0x02) ? -1 : 1)); v->vcfCut += (int)((v->note - 36) * (patchRam.vcfKey << 1) * 0.375); diff --git a/plugin/voice.cpp b/plugin/voice.cpp index 92ecf8f..918cd46 100644 --- a/plugin/voice.cpp +++ b/plugin/voice.cpp @@ -72,7 +72,7 @@ void Voice::run(Module* m, float* buffer, uint32_t framePos, uint32_t samples) { float r = 5 * m->res; - float amp = vcaEnv / 4096.0f; + float amp = vcaEnv / 16384.0f; for (uint32_t i = 0; i < samples; i++) { out = delay;