How to get a clean center value [0.5] from a floating point slider? Easy (sort of).


    Feb 10 2019 | 1:33 am
    Hopefully, this post will save some future Max user from scratching their head. I was gobsmacked today to discover that the position of a slider in a patcher affects its output values.
    My float slider (0…1) pan control wasn't reliably hitting 0.5. Ok, that's a common problem with resolution or using odd-numbered box sizes or something. Easy to fix, right? But I checked. No problems . What the heck? This controller works for a while, then I'll edit make a few cosmetic changes, and it stops hitting 0.5 again. I just couldn't nail down the problem for days. Long story short: it turns that a float slider sitting on a fractional pixel boundary outputs slightly different values than a float slider sitting on a whole number pixel boundary. Yep. The output values (interpolation) of a slider differs when the slider position is x=50 y=100 vs x=50 y=100.5. So every time you move a slider a fraction of a pixel, you risk changing its output.
    In short, it's easy to get a 0…1 slider to hit 0.5 in the middle every time. Don't use odd-numbered box sizes and don't place your float sliders on a fractional pixel. Use snap to grid or manually set the position to a whole number.
    Voila! But that hurt my brain a bit.

    • Feb 10 2019 | 9:18 pm
      Thanks for the info! Do you know, that you can press Shift while dragging UI controls for more precision? This does not solves the issue, but (at least) allows to set third slider from your example to a values .499 and .501.
    • Feb 11 2019 | 12:12 am
      what a weird idea to allow sub pixel positioning.
    • Feb 11 2019 | 1:06 am
      @Roman Something to do with scaling, I would guess.
    • Feb 14 2019 | 10:38 pm
      I've reported this as a bug .
      The issue occurs in Max 6 as well as Max 8.