This commit is contained in:
Gordon JC Pearce 2024-09-04 00:40:40 +01:00
parent 152b0c62a5
commit 44feac5e0b
3 changed files with 25 additions and 32 deletions

View File

@ -34,13 +34,30 @@ void Chassis::initParameter(uint32_t index, Parameter &parameter) {
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
break;
case k_sqr:
parameter.hints = kParameterIsAutomatable | kParameterIsBoolean;
parameter.name = "Square";
parameter.symbol = "sqr";
parameter.ranges.min = 0.0f;
parameter.ranges.max = 127.0f;
parameter.ranges.def = 0.0f;
break;
}
}
void Chassis::setParameterValue(uint32_t index, float value) {
switch (index) {
case k_saw:
s.p.saw = value / 127.0f;
break;
case k_sqr:
s.p.sqr = value / 127.0f;
break;
}
}

View File

@ -30,6 +30,7 @@ class Chassis : public Plugin {
public:
enum Parameters {
k_saw,
k_sqr,
kParameterCount
};

View File

@ -55,39 +55,14 @@ void Voice::off() {
}
void Voice::run(Synth &s, float *buffer, uint32_t samples) {
float y, t;
env = ((target - env) * 0.1) + env;
float y;
env = ((target - env) * 0.01) + env;
for (uint32_t i = 0; i < samples; i++) {
// prepare the delay slot
out = delay;
delay = 0;
phase += omega;
//delay = 1-(2*phase);
if (phase > 1) phase -= 1;
y = (2 * phase) - 1;
y -= blep(phase, omega);
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;
buffer[i] += (0.25 * y * env) * s.p.saw;
}
}