How is this midpoint slider calculated?

Screenshot 2024-07-09 at 5.45.10 AM

Serum and FM8 are calculating this midpoint to match the curve. What can I do differently so it matches up?

Zed is my midipoint thumb and init and target are x1,y1 x2,y2

if(init->getY() > target->getY()) {
                
            c = juce::jmap((float)zeds[i]->getY(),(float)target->getY(),(float)init->getY(), -4.0f, 4.0f);

        }else if(init->getY() < target->getY()){

            c = juce::jmap((float)zeds[i]->getY(),(float)init->getY(),(float)target->getY(), -4.0f, 4.0f);
        }else{
            c = 0;
        }

        c = -c;
        
1 Like

this is so strange but looks like implicit equation
given x and y which i know i have to solve for t y = (exp(t*x) -1)/(exp(t)-1)
double newton(double x, double y, double t0, double eps) {
double t = t0;
const int max = 32;
int c = 0;
while (c < max) {
double f_t = f(t, x, y);
double f_prime_t = f_prime(t, x);
double t_next = t - f_t / f_prime_t;
if (abs(t_next - t) < eps) {
return t_next;
}
t = t_next;
c++;
}
}
im sure there is better way with powf(x,t);

1 Like

There is actually another way to improve with a 3 way cross fader and linearize the zed.

eq1 = (exp(x*-10)-1)/(exp(-10)-1)
eq2 = x
eq3 = (exp(x*10)-1)/(exp(10)-1)

three way crossfader zed between eq1 eq2 and eq3 I think this should work

1 Like

0 = -y + (exp(0.5*x)-1.0)/(exp(x)-1.0) this is the equation to solve y is between 0.00001 and 0.99995 or something like that depending on you max exponents you want to clamp to someone on kvr helped me out with the inverse function.

0 = -y + (exp(0.5*x)-1.0)/(exp(x)-1.0)
   y = std::clamp(y, (exp(0.5f*16.0f)-1.0f)/(exp(16.0f)-1.0f), (exp(0.5f*-16.0f)-1.0f)/(exp(-16.0f)-1.0f));
            
   auto v = log((0.5f*(2*y*y-2*y-2*(y-0.5)+1))/(y*y));