Trying to randomize live.dial with random values scaled to match the range of the dial
My ultimate goal here is to randomly set the value of quite a few [live.dial] objects in a Max for Live device, and each of the ones I will be randomizing will have a different range of values. So I need to scale the range of [random] so the output is scaled to the range of the dial it is connected to appropriately, which seems to require figuring out the range/enum of the dial, and basing the range of the [random] on that.
So, I'm trying to parse lists from [getattr _parameter_range] connected to a [live.dial]. The resulting lists will either be:
1. A series of ints
2. A list of alphanumeric strings
3. A min and max value (float or int)
Each of these needs to be handled differently:
1. I need to use [zl.len] to determine the length of the list, then [zl.lookup] to determine the first and last values.
2. I need to use [zl.len] to get the length of the list, then generate a list containing "0", and the length of the list -1.
3. Pass the list of min/max values to another object.
Maybe there is an easier way to do this. I just haven't been able to think of it. Hopefully someone here already has, or can let me know how to do what I'm aiming to do as described above.
Ideally, I would also like to be able to manually adjust the range for the min/max value of the scaled random as well, in case I want the output value to only adjust the dial through part of its range.
Please let me know if you can help. Thanks!
Have you tried prepending the rawfloat message? Then you can just use 0-1 float values
You mean prepending sending the message to live.dial? Would that adjust the live.dial value regardless of the enum/range, so that the random would be scaled to be an evenly weighted range randomization?
Unless I'm missing something a combination of the scale and random objects should be able to do the job for this, I was working on something similar for a filter effect I was working on.
Does this help in any way?
Thanks, @Daniel Beck! That is helpful. However, the thing I am stuck on is how to determine the range of each dial procedurally so that I can make one abstraction I can connect to any dial and the [scale] output range will be set to the dial's range appropriately. So then the main issue is, of course, how to determine the range for each dial. But it sounds like prepending rawfloat to the value output from [scale], and simply setting the output range of the [scale] to 0. to 1. may work.
...a while later...
Eureka! Got it all figured out now. Here's a patch showing what I was trying to do in greater detail.
Thanks again, @Daniel and @Centre Ville for your help!
Just a note: this isn't truly individual-control randomization, since setting the output of the random to the same number will generate the same resulting values on all of the controls. However, this is exactly what I wanted for the purposes of being able to undo/redo random changes to all connected live.dials by automating and storing the value of the randomized number object (or a live.dial connected to the random object). And I figure if I use a random with a large enough range (say 0-10,000), the odds of having a repeated setting on all of the dials would be very slim.