Knob.setRange



  • Is there a way of doing it the right way?

    This is my situation: I got 3 buttons (small, medium, large) and a knob (gain)

    when I pressed small button I would like to set the range of the knob(gain) to a specific value but I want it to be fixed to the value.
    when I pressed medium button I would like to set the range of the knob(gain) to a specific value but I want it to be fixed to the value.
    when I pressed large button I would like to set the range of the knob(gain) to a specific value but I want it to be fixed to the value.

    example:

    small(range):
    c_wetKnb.setRange(-100, -55, 0.1); // I don't want this knob to go over the -55and I want the default value to be -10

    medium(range):
    c_wetKnb.setRange(-100, -75, 0.1); // I don't want this knob to go over the -75 and I want the default value to be -10

    large(range):
    c_wetKnb.setRange(-100, -10, 0.1); // I don't want this knob to go over the -10 and I want the default value to be -10

    This is what got so far and is not working for me

    // -----------------------------------------------------------------------------------------------
    const var smallBtn = Content.getComponent("smallBtn");
    const var medieumBtn = Content.getComponent("medieumBtn");
    const var largeBtn = Content.getComponent("largeBtn");

    inline function onsmallBtnControl(component, value)
    {
    if(value == 1)
    {
    rsLbl.set("text", "Small");
    c_wetKnb.setRange(-100, -55, 0.1);
    c_wetKnb.changed();
    }
    };
    Content.getComponent("smallBtn").setControlCallback(onsmallBtnControl);

    inline function onmedieumBtnControl(component, value)
    {
    if(value == 1)
    {
    rsLbl.set("text", "Medium");
    c_wetKnb.setRange(-100, -75, 0.1);
    c_wetKnb.changed();
    }
    };
    Content.getComponent("medieumBtn").setControlCallback(onmedieumBtnControl);

    inline function onlargeBtnControl(component, value)
    {
    if(value == 1)
    {
    rsLbl.set("text", "Large");
    c_wetKnb.setRange(-100, -10, 0.1);
    c_wetKnb.changed();
    }
    };
    Content.getComponent("largeBtn").setControlCallback(onlargeBtnControl);



  • setRange() can't be used after initialisation has completed (I don't know why) but you can use set("min") and set("max"). Since the minimum and the default value is the same for all of the modes there is no need to change these via scripting and they can just be set in the interface designer. The only value that needs to change is the knob's max.

    This is how I would do it

    HiseSnippet 1157.3ocsW0saaaCElJIJa1atXcXWtKHB1ExHooxNMsCKanYw4GXjkDi5zfMTTTPKQY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COE1v+cXVnQcY+b793u9K50u8b+hyA8SWC8F.wU+q+NYEF44wFGO.iGi6Gp.t01GlqAY74luD5z.WyRh3Jb3P.GnQOz78bYr+oVtXlBm2e70n+8LAvjIR2HNQM63J5YzRMneQJNWf9teA7BNoX8bIlgwdgGwZQo6CM6nuEY97co4vW3jy+27MchvZlG34QcT4jcEyC+wOzw+JAUdgLRwD8Og.kMPQj4oQ9cgAjcn.SDBJOT2HaIcerDY6rFacoB2XAcMXpwFZYiTiMxLh7INAx2jNPfdlyONVCvIQ7n2Uf+C.Him1BSya3HB6MNN5Dwi.lO+HZV5H1pzQ7jRGw1kNhmV5HdVoi3quiHz+qiuORI8SNV.J5bP7UGFFGHHPUUbEH5eDfJxt.
    


  • @Jay
    Here is another example with multiple version. In this example, knob value is stable (in order to prevent from possible crash problems), but buttons change the range of the controlled parameters. On each button pressed, it changes the range with predefined values and recalculates the new value upon the knob's latest position. So one knob, controls multiple parameters with variable ranges (Simple Gain is used in this example) 😉

    HiseSnippet 1980.3oc0Y08aajaDeW6rswpmKxc3d7dfPOzacqhOsR2WnGJhh+HAFo9CD4jb.FFoT6RIwy6RJPx0NpAA3dnu2+g5CG5eI8g9GPe3tmuaH49AkkrpbJthKxFIhCmY3uY3LC4PehfGSjRtvyeiSmNg34+dA8mxTi2cLlx7NXOO+FAGez9O4ni2IxamoSvRIIwy2e8Gqm2ei63Y97edvN3TLKlTSxy64bZL4OSynpZpmz6IzzzGgSHmRyb39S6cPLmsKOkmCXY8f1dSvwWfGQNBqYas.O+e09ITEWzWgUDom+c1gmLs+X9ULK+OmJoCRI5AQd8AEYI+HdZhFwZpd6NlllbRoMK8.sbRsGXcqG3CCNjlPqnW6ItmYBTsDt9C+0VF7hbgW6EBu1KBd9Nv6NV389A8iEzIp5YzX62Db.SQDCwvVfKrr75s1VuWvtbfClZ6L7EjGIfAURD9Esa2BE0o8Ve0lM1rwm7In9DERwQJQNQ++SDTFPXLAcINMmHMyAifsLIOkr8lMzeSAyJP6syi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blzMIAMXJT+fDeAjXanZPHxF7WIakETdppl90Nov8ZDaazxwCqM84RUcrabrJuLOWZKqUWBxVbSZka40w9ppZzUW84l8J.kPg1NcwcQZhPGUnuPhfmtagJBu1tp8JaWequrFUkTN68F6al89WPr6HZXZvq09PPopw7DzX3lesfrA31e0WPoR3wX8AifuRNlNTYO7UnuR6J5nr6FUEUWfEeciwZx5eprWNSGUdLKbqFutwFMdybyLb3hlpXkRIhEMqtCKwRDKjkmMfHJ8nE7AMZLamLMt4NYbazJ1dwSGF4rCXT0wSHUisFYIk1dUFmKoZixkpwXV.a0jlu8IuhKCq6yqfcfUkoMpeaQaT8SoIDgGMQ2CUUmDdFWRQ6oe2OD9Odf2Mo.aHuQA2Mvd69RoC7M81t5R14sVxtyfXSG4dO6f8vJrtKxB+.3alPDJpdW0eOxkP641dJ2HXOh7BEeBzocUWCfSakbUupZQ+tI8lVM3aOtmmittqUWaV18JlQRKL.y2ibziWSG83E16J8oTUDP+sdiIzQiqeUgu8w8FvE.15S+qy7BDVpOEmPyktz8Wedjsr8SGngbg1GcMn4874fVudvklf0wcAKsXA.L9iE77I0Z3tKxqsrHFG2+W+KKr00Eai94Gay+VI2K3P88+wpYeFG8ESJl.JHNy6kneSDnwV0T2Lo+meamE8zSqJbe+fSnp3wKFuqs.7Bg2+bi2hWJay.6i2TC16D7nu9s8Ywhd6dVrec06VVcoSCTlgvM7xk+quO7e+.yMTKH7W96+y606EyFa965sf21ze8Ysq0WM65+xKPt73.yKm8NSb6GDXbruKAXyF+6N.9d55g+B.tOkmqf1dNDCs+AU7CNJOqOOWDSzOmETvVpuOyZ5qyXG2t79M8IrDyfeD9TLYjdrewjQkS9+k0HCGK3uL1dmKcp4cMT.6lY9iPrQvg5wnp62o8MYzD5Kii0k9tO3cVrDct0Rz8VKwmdqk3yt0R742ZI9hasDe4RjP+2e4g4JdlMdGHbx9l6356uOS2juIz26mPV4e3T
    
    


  • @orange Thanks buddy, you are a genius


Log in to reply
 

3
Online

470
Users

1.6k
Topics

11.8k
Posts