[Solved] Scaling values evenly
i have a stream of incoming values, with a range of let's say 1-90.
i want to scale the output to let's say 1-3.
and i want to scale them evenly, meaning 30 input values for each output:
input 1-30 outputs: 1
input 31-60 outputs: 2
input 61-90 outputs: 3
if i use the [scale 1 90 1 3] object i will get the following result:
input 1-45 outputs: 1
input 46-89 outputs:2
only input 90 outputs: 3
if i make the ouput scaling floating numbers [scale 1 90 1. 3.] and add a [round] object on the outlet i get:
input 1-23 outputs: 1
input 24-67 outputs: 2
input 68-90 ouputs: 3
this is not as horrible as the above but still the side values are always half as many as the rest.
any tips?
(preferably without the use of external objects, but i will if necessary)
You could use [split].
thanks for the suggestions guys, but:
@broc: i can't use your [split] approach because input and output ranges will be changing dynamically. the 1-90 to 1-3 was just an example to illustrate why [scale] is not scaling evenly.
@doubleug: i don't understand why you use the [round] object. i just bypassed it and got the same results.
anyway, inspired by you guys i managed to come up with the patcher attached below, but:
1. i was hoping there would be a more elegant one-object solution, something similar to scale where you can just connect the range numbox's and the value to be scaled. Ok, i know, i can just encapsulate it, but i need to use many instances of this (over 100) so i try to keep things as minimal as possible for tidyness and cpu reasons.
2. i also need the curve function that [scale] provides (rightmost inlet). if i recall correctly the [scale] object also has some issues with this, confusing me (and apparently many others to the point where someone made an external behaving exactly like [scale], but with proper curve behaviour).
anyway, here is my patch in case it will be of help to anyone, for me it is not of any use for this project, for the above reasons.
ps: i suppose it could be done also with [expr] for a more elegant solution.
expr ($i1>0&&$i1<31) + (($i1>30&&$i1<61)*2) + (($i1>60&&$i1<91)*3)
Hello Mark,
Try it with [scale 1 91 1 4].
Hey Len!
such an obvious solution but i would never have thought of it!
just add 1 to the in-max (2nd inlet) and out-max(4th inlet) values of [scale].
thanks so much!
now i just have to figure out the curve behaviour of this object.
but i can mark this topic as solved.
I do not exactly understand what you mean by curve but maybe [linedrive] might help you if you consider a non-linear output.