hei.
the only float calculation i have is - sadly on a frequently used place (every 32th step 32*8 values) —
the calculation should add and substract Velocity to (all) CsC, depending on:
the currently Received Midi-Note-On-Value (Velo_From_Note)
the Assign-CC-Matrix: which and if a CC should be addet or subtract a specified ammount of Value. where Value 63 should end up with ±0, and 0 to -64, 127 to +64 (beat[port].Velo_Morph[x]-64.0)
the Velocity Morph Offset Controller, which when turned of, should minimize the effect from above parameters to minimal, while on MAX the Offset should have full effect (beat[port].Velo_Morph_Offset)
working float code:
static float value = 0; static float morph = 0; // calculate CC Value morph = (((Velo\_From\_Note[port]/127.0) \* (beat[port].Velo\_Morph[x]-64.0)) / 64.0) \* beat[port].Velo\_Morph\_Offset; int morphint = morph; value = value + morph; if(value \<= 0) { value = 0; } // only in a range of 0-127 if(value \>= 127) { value = 127; } // only in a range of 0-127 int valueint = value;
i was trying out bitshifting in high atmosphares (S32 integers), but in reality it did not worked out, i was in maths really bad, and up to now its a pain in the…for me.
not working for example:
static u32 value = 0; static s32 morph = 0; morph = // to get to full u8 range // no need to shift we need half (( (( (Velo\_From\_Note[port] \<\< 1) \* (beat[port].Velo\_Morph[x]\<\<8) )\>\>8) \* (beat[port].Velo\_Morph\_Offset\<\<9))\>\>24); value = value + morph; if(value \<= 0) { value = 0; } // only in a range of 0-127 if(value \>= 127) { value = 127; } // only in a range of 0-127
maybe there is some integer-expert workaround BRO out there who can help?