I’m trying to make my first module keeping inspiration from Befaco Rampage.

I see that if I change the shape of the rise (or fall) stage, it doens’t change only the shape, but also the “rate” (i.e. the time it would take) to finish the stage.

How would you keep the rate?

Here’s the quick code that shown the number of steps that change, switching shape at some cycle/sample (at the 4° cycle, 120° sample):

```
#include <iostream>
#include <math.h>
const double sampleRate = 44100.0;
inline float interpolate(float a, float b, float frac) { return a + frac * (b - a); }
inline float shapeDelta(float delta, float length, float shape) {
float lin = (copysignf(1.0f, delta) * 10.0) / length;
float exp = (M_E * delta) / length;
return interpolate(lin, exp, shape * 0.90f);
}
int main() {
float in = 10.0;
float out = 0.0;
float shape = 0.0;
float lengthInSeconds = 1e-2; // * powf(2.0, 1.0 * 10.0);
int numCycles = 10;
for(int cycle = 0; cycle < numCycles; cycle++) {
int numSteps = 0;
while (in - out > 1e-3) {
// change shapes
if(cycle == 4 && numSteps == 120) {
shape = 1.0;
}
float delta = in - out;
out += shapeDelta(delta, lengthInSeconds, shape) * (1.0 / sampleRate);
numSteps++;
}
std::cout << "cycle: " << cycle << " | num steps: " << numSteps << " | value: " << out << std::endl;
out -= 10.0;
}
}
```

It should always takes 441 sample to complete the cycle

Can you help me? Some tips?