Hello everyone.
I'm currently trying to make a knee object (kinda like the one i have recently put in the library, you can find it as knee k and knee s)
This time i'd like to make the knee move horizontally (see the picture)
As you can see, i already calculated the math formulas for the two ramps (nothing hard really).
For K=l/2 the two ramps are basically just one continuous ramp (x=y)
The hard part comes now: have to scale all values to axoloti's weird ranges.
For the other object i got away without doing divisions and using only ___SMMUL and bitshifts. This time however i have to divide for quantities that are not fixed and that route is no longer viable.
I tried to see how the math/reciprocal works, and it does its thing with
float inf = inlet_in;
outlet_out = (int)(281474976710656.f/inf);
I copied that into my object and got this code (which partially works, but only of the first part of the ramp)
/*
* inlet_in=x
* outlet_out=y
*
* param_amp= knob value ( ParameterFrac32UMapGain type)
* inlet_mod= additional mod input value ( inletFrac32Bipolar type )
* the param_amp and inlet_mod are then added to provide the K parameter
*/
param = param_amp + (inlet_mod<<4); // this is K
float fparam = (param>>4);
float temp;
float input = (inlet_in);
if (inlet_in< (param>>4)) //if x<K -> output the first part of the ramp (this one works as intended)
{
temp=(281474976710656.f/(fparam));
outlet_out= ___SMMUL((int)(temp/2),inlet_in)<<11;
}
else //if x>K -> output the second part of the ramp (and here comes the trouble, it does not work as expected at all)
{
temp=(281474976710656.f/(64-fparam));
outlet_out=___SMMUL((int)(temp/2),(inlet_in+(1<<27)-(param>>3)))<<11;
}
Can someone help?
I'm getting several downward ramps in the output, that variate in number when you rotate the knob. Totally not what i was expecting, and at this point my programming skills break down
I'll post the object and an example patch
knee h k.axo (1.5 KB)
bend prova.axp (1.3 KB)