diff --git a/plugin/voice.cpp b/plugin/voice.cpp index e811c1a..04e1bdd 100644 --- a/plugin/voice.cpp +++ b/plugin/voice.cpp @@ -55,14 +55,39 @@ void Voice::off() { } void Voice::run(Synth &s, float *buffer, uint32_t samples) { - float y; - env = ((target - env) * 0.01) + env; + float y, t; + env = ((target - env) * 0.1) + env; for (uint32_t i = 0; i < samples; i++) { - phase += omega; - if (phase > 1) phase -= 1; - y = (2 * phase) - 1; - y -= blep(phase, omega); - buffer[i] += (0.25 * y * env) * s.p.saw; + // prepare the delay slot + out = delay; + delay = 0; + phase += omega; + //delay = 1-(2*phase); + + if (phase > 1.0f) { + phase -= 1.0f; + + t = phase / omega; + out -= (t*t*t) - 0.5 * (t*t*t*t); + //delay -= (2 * t) - (t * t) - 1; + + t = 1-(phase / omega); + delay = (t*t*t) - 0.5 * (t*t*t*t); + //out -= (2*t) + (t*t) + 1; + + } + + delay += (phase); + + +y = 0.5 * (out-0.5) * env;// * s.p.saw; + + + + + // y -= blep(phase, omega); + + buffer[i] += y;// (0.25 * y * env) * s.p.saw; } } diff --git a/plugin/voice.hpp b/plugin/voice.hpp index f6d9634..92ade0b 100644 --- a/plugin/voice.hpp +++ b/plugin/voice.hpp @@ -30,7 +30,7 @@ class Patch { class Voice { public: - uint8_t note; + uint8_t note = 72; void on(uint32_t key, bool reset); @@ -50,6 +50,8 @@ class Voice { K_SUSTAIN } keyState = K_OFF; float phase, omega; float env, target; + float out, delay; + }; class Synth {