First time here? Check out the FAQ!
x

Next Preset Random

0 votes
237 views

I have made a drone with 35 presets. Each time I trigger the drone to turn on I would like it to choose one of the 35 presets. I would also like to set the range of which presets to select 1 - 18 or 15 - 35, for example.

Where shall I put this random choice control for the presets in my sound?

 

 

asked May 6, 2017 in Using Kyma by anne-la-berge (Adept) (2,170 points)

1 Answer

+3 votes

I see in your example that you've already taken the first step by feeding your drone into an InterpolatePresets. The range of the Interpolate control is [0,1], but if you prefer to select the presets as integers ranging from 1 to the number of presets, use an expression of this form to translate your integer selection to the (0,1) range:

!SelectedPresetNumber - 1 / (<NumberOfPresets> - 1)

So if you were going to use a fader to select from your 35 presets, you would use: (!Number - 1 / (35 - 1))

But instead, you want to select a preset at random.  So in place of the !Number fader, use an expression that generates a random number, for example:

!Trigger nextRandom abs

That will give you a random number in the range [0,1].  But since you'd like to be able to change the range and the offset, you can set the min and max values for the random preset number as EventValues. The general form for this is to multiply by the range and add the offset.  So you could use something like:

!Trigger nextRandom abs * (!MaxValue - !MinValue) + !MinValue - 1 / (35 - 1)

As a last step, you want to ensure that you are getting integer values for the preset numbers (unless you are interested in getting the interpolated values between two presets which can also be interesting).  So as a last step you could truncate the random preset number (since it will otherwise be a floating point value):

(!Trigger nextRandom abs * (!MaxValue - !MinValue) + !MinValue) truncated - 1 / (35 - 1)

answered May 8, 2017 by ssc (Savant) (126,620 points)
Yes. This works wonderfully and the interpolation between presets is also useful! I had to remember that I had named my !Trigger differently since I am using 6 separate drones to make them all work independently.
Thanks for the clarity.
...