Need a math teacher...

  • @Christoph-Hart I borrowed some formulas in the core of Hise for applying a skew factor to my vector knobs...
    Well, I can calculate the skew or the midpoint form skew, but I miserably failed to apply it to my value...
    Sure I'm not far though 🤔

    Would you (or anyone else of course) replace the question marks, please?

    var length = knob.get("max") - knob.get("min");
    var normalizedValue = (value - knob.get("min")) / length;
    var skew = Math.log(0.5) / Math.log(( - knob.get("min")) / length);
    var midPoint = Math.pow(2.0, -1.0 / skew) * length + knob.get("min");
    var proportion = Math.pow(normalizedValue, skew);

  • @Christoph-Hart bump bump 🙂

  • This is how I'd solve it knob.setValue(@Christoph-Hart); 😉

  • You don't need a math teacher, you need an invisible knob that does the math for you 🙂

    1. Add a knob with an empty image as filmstrip
    2. Add the panel that draws your vector knob behind the actual knob.
    3. Implement the paint routine. Use Knob.getValueNormalised() which tucks away all this logarithmic stuff and gives you a normalised linear value from 0...1 that you can use to draw the value on your panel.
    4. Add a timer callback that grabs the value and repaints it.
    5. This way you get the other nice things from the Knob / Slider widget (shift click to enter a value, double click to return, adjustable mouse sensitivity etc)

    I am using this trick in HEXERACT for the vector knobs:


  • @Christoph-Hart Why use a timer callback and not the knob's control callback?

  • @Christoph-Hart Well, I'm not sure it is what I want to do, this will clutter a lot my interface and component list. Also I noticed that having too many widget in an interface makes it laggy. And, my vector knob has already all the options I need...

    I really think adjusting from the skew factor would be better in my case.
    It's already what Hise is using, isn't it? So what are the maths after calculating the skew?

    Also, I found some methods in Juce for mapping the values from a skew factor or mid-point, maybe it would be cool to have it in Hise what do you think?

Log in to reply