How to scale a value up


#1

I want to scale a value up to a different range.

x = between 0 and 96 (this max value will be variable)
y = between 0 and 128

In normal math the formula would be
y = x * (128/96)

or more general y = x * (maxvalue y / maxvalue x)

I am trying to figure out how do I code this in an object?

I have seen the "object"-solution by @thetechnobear
https://sebiik.github.io/community.axoloti.com.backup/t/scaling-values-object/3592/7 but I need the x range to be variable.

Very much apreciated if someone can help me out on this.


#2

Here's how to do this if the max is 64. You set dial "max" to the maximal input (your x), dial 128 to the maximal output, and Dial "your input" always maps to 0...64 on dial_1. Does that help? scale.axp (2.4 KB)

I also found an object for something very similar: scale.axo (728 Bytes)