Applying linear function to each interval



  • Hi

    One master knob controls 2 slave knobs. Slave knob target values are not llinear (like in the graphic below). So I used arrays for that.

    Each blue line between each dots is linear itself. The general linear function is below. Is it possible to divide each master knob value interval and apply the equation below with respective array values?

    Let's say;

    • if Master knob (X1) = -2 >> Knob A (YA1)= 1.3 and Knob B (YB1)= -3.4

    • if Master knob (X2) = -1 >> Knob A (YA2)= 5.2 and Knob B (YB2) = 2.2

    • if master knob is between -2 and -1, the code applies the equation below and finds the linear point. But for each interval, X1, X2, YA1, YA2, YB1, YB2 values will be shifted within the values in the array. How can we implement that?

    NOTE: in below equation, X is the current value of the Master Knob

    Equation for each slave knob

    Target Value = (((Y1)-(Y2))/((X1)-(X2))*X + ((Y1)-(((Y1)-(Y2))/((X1)-(X2))*X1)))
    

    alt text

    HiseSnippet 1103.3ocsV8tahbCD2KI6cGzR0cR4C8iVQ2GH5HnkPRZjRqBABTgx+PkzzJc5DxYWSvJFaztlzvEEo9g9bUkGg9Jz2f6Mncr2E1ENBAgTVjXWOy7aledF6wtouzkFDH8QVouXXeJx5asaMTn5VsKgIPMNRK3PeexP1modEQUF1mDDP8PVVq7yZKrRuJx77kCpP3DgKMVDBcoj4ROg0iohk1r7wLNuNwidAqWBq2tbCWonpjKG.rYEaGTeh6MjqomQzlkxFY8pZdLkzukhnnAHqUqH8F1pq7ODg1eIKfcEmpGTD0BbTn35RtmlwZonpcYbulil0AHvKMiyAqDlCVy9TlGar73bwaMJvwHRlOrRMO5ULI8bVb5YkfdqFRu2Y2x0m0WEqQysuwtgPQ86PfRPRZEZKJUvJ1UkfEBUgdjan08gAiQjaWGm73scb1X+rYz+fRQfBeKwGerPd0g3eBOB70TUUYu9RALH25FsqqQMIhJyEQk0GEmj3NkD.zQq+IAGaRjGXBNSPwcFHbULo.KEwlncgujmycD97PX3CnajMy8Yyj1Ux4T.0sz1WP7g3ztdjWxsw93rYdvDfmmGEBzpLgpJgyuBV0laFzHdFO4Lmn2cQ8ZqMsXaCACf4+G2bq73MKlGC0E3+s9z9yFxVsUFxe4XfEKTJOdmBN.d3iRE1CJrE18ovW5qvuYoBaCAz3.Gsm.Gr4deZL8mNkOu7H1jpwvCW5R3XlwK5wcj93bLHdN6iY3eDuC75CeXiPk2GFIbzyze8P3KsIOn+KQ0+LohdND3L2mIclGxfmVUmNyTWTMhS8moZcmJ+4ALmXPuqn9iVfMxPXK6j8Dre5dBIaY4FtnKggRQCAScdep3o5TfhVoB8LVIhUvWJSGiuKpiQKNyi5iXd515wqPQFVG2Jt6eiV.O7Zayl+oAuV4EGbkoACO+ZiiHJhtyWzDBlj8o9JlN+YcD8V3Hkv9fosOhFbiR1GRyi2aBhWr47cwQ8hxCGO3O+X4dLOONsoLfoKxIIG.teK3jvHYk+2O+WGzijvSH.bRDOpn2ATJaTfMsF0Upwj8MOa5M16OdWRd9akmHxuexH+kCdpYwZk8ncHC3g63mptMlWu5Yqbww9eRxqGcmjHu+wIn42OQTrCiR1nnbB4JJ2DDPxIGdYs1Ge14UZkHTucXhPgZTdT50XMNzZzWehIbtsza.mnl7vb8MXhTnSQIO0Texn.RcCSlReQNgeQo66raxTtcmMeSMC9Bagdo4az8kxZWqSG3HfXxtpc8e+k+xQneQNPwDWeJQ4yfEI1mMnWK35itTfIBAkq63ZkR2aLbridrNyzhJ7LC9O3IRYQ8XqHkEGoD0i35Ka6F1RSeir2Xj.bRXtXZZXuMLFWbTuLaamBNHX6GqsqqNUrIv8YiYqk.Sok.y1KAlcVBL6tDX9gk.ydyEi9N5GNPI6EtMADzrl4LEKqZBBrJyrhD8+zMao4F
    


  • @Fortune Yeah this is a typical Linear Interpolation example. Using both if/else statements & arrays would be somethinng this 🙂

    HiseSnippet 1407.3ocyY0sSabDEdVBaZvstMHkK5ccTTTz5B10l0jhDghw7SEhehUMkVoHj0vtigQrdFqcGmFmnH0K5KQtqOJ7HzGg12fbcugdl8G10A6ccLgPWjfcly4aNey4Lmi8bngqvh54IbQZybP+tTj1Wn2rOWd55mRXbz1anlXMWWRe1q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EnvqLi.EBYE7lzuwEeYXiKZ5vrotHlsp6RwGEP9rNriP+8EWbwpnwXE9Lc+CDC.9Oe6ams13Ct9ffu3hu4bzOu8FDIQ0.lvMDrI6RckLk+SaC5KXVzf1wLi9FTuyjhtfa9xlD.SOd64WF2ArCp0+xA+9yq0gYa6PaH7Xpfbx1pAf61j8pHBW6ed0erZGRhUBAfSh3bI8k.kxGZX+7AUj5RxduLcuwq94uLIO+kZCX4GMnke2piZW7fZ1z1DHQ7vDtd+4Sxq6lYjK11+URdct0fD4QmO.M+5ArhdfUxGZkcIGSc7MBLytqc3ls1Y+mUuYBSc+9ILEZ6ZQtWeswAZitZi6tu9dB6dND4f8TT0H0PAJWTxl2oZPGGbc8S5RuQZz33R2Y0avjVmNb9N0P3KjBcSy2v11lWey1soVxXxNs9V+5MeOZQ+jnmjwOYOhzkAGRz2uWmlhdtVTfIbN0QUwUaJUswfwkUiUdllTts+.nX2EgBqnFqEJrRjPTGhkqnkUPIMUigum+L.m398GeFH2FFiqDUKSWuboxHH8i0xxR4JJBbe3XVXBvXNAXpNAXVbBv7jI.y2OAXVJULp+UAq0SJ5Djl.SzXS+OSQSaSNANk4ehD8ePS2mGm
    


  • @orange Wow! That's what exactly I am looking for! Thank you so much mate, Thank you so much for being very helpful!!!
    👑


Log in to reply
 

13
Online

1.0k
Users

3.6k
Topics

30.7k
Posts