Try this with Fader and a monitor:
Montitor.value = range(Fader.x, 127,0);
It WOULD be cool if this would give us an inverted 0 - 127 range so that:
When Fader.x = 0 -> Monitor.value=127;
When Fader.x = 1 -> Monitor.value=0;
range(x,min, max) where min>max
Re: range(x,min, max) where min>max
Monitor.value = 127 - Fader.x * 127
Re: range(x,min, max) where min>max
Yeah I know bro....Its just an example. I have a specific usage case scenario where I need to "invert" a couple of generated values which go through a range object....Being able to use the function as I describe would save me some (many) lines of coding.
Aaaanyways.....
Aaaanyways.....
Re: range(x,min, max) where min>max
on a slightly related note, it would be cool to come up with a user defined function that works a lot like the scale object in max. args: (x, low in, hi in, low out, hi out) and maybe even the sixth argument for an exponential slope. Having it work for a single value and vector would be ideal. Anyone interested and got the know how?
It should accomplish also what you are saying, but not as specific.
anyway..
It should accomplish also what you are saying, but not as specific.
anyway..
Re: range(x,min, max) where min>max
Ah this is easy in fact! I just always thought that built in functions must be less ram-cpu hungry than custom ones.
The maths behind it is:
NewValue = (((OldValue - OldMin) * NewRange) / OldRange) + NewMin
where
OldRange = (OldMax - OldMin)
NewRange = (NewMax - NewMin)
So, I made two custom functions:
ranged(x,oldmin,oldmax,min,max) converts a variable x of ANY range (including negative ones) to a new range. Min>max works too!
Specifically in the case that the input is in our familiar 0 to 1 range a simplified function, I made:
rangednorm(x,min,max)
The maths behind it is:
NewValue = (((OldValue - OldMin) * NewRange) / OldRange) + NewMin
where
OldRange = (OldMax - OldMin)
NewRange = (NewMax - NewMin)
So, I made two custom functions:
ranged(x,oldmin,oldmax,min,max) converts a variable x of ANY range (including negative ones) to a new range. Min>max works too!
Specifically in the case that the input is in our familiar 0 to 1 range a simplified function, I made:
rangednorm(x,min,max)
- Attachments
-
- convertranges.jzml
- (7.43KiB)Downloaded 262 times