randomi
Generates a user-controlled random number series with interpolation between each new number.
Syntax
ares randomi kmin, kmax, xcps [,imode] [,ifirstval]
kres randomi kmin, kmax, kcps [,imode] [,ifirstval]
Initialization
imode (optional, default=0) -- first interpolation cycle mode (see below)
ifirstval (optional, default=0) -- first output value
Performance
kmin -- minimum range limit
kmax -- maximum range limit
kcps, xcps -- rate of random break-point generation
The randomi opcode is similar to randi but allows the user to set arbitrary minimum and maximum values.
When imode = 0 (the default), the kmin argument value is outputted during 1/kcps (resp. 1/xcps) seconds at the beginning of the note, before the first random number is generated. Then the normal interpolation process takes place, first between kmin and the first random number generated, and then between successive generated random numbers, each interpolation cycle having a duration of 1/kcps (resp. 1/xcps) seconds.
When imode = 1, a random number is generated at initialization and interpolation begins immediately between the kmin argument value and that random number.
When imode = 2, a random number is generated at initialization and interpolation begins immediately between the ifirstval argument value and that random number.
When imode = 3, two random numbers are generated at initialization as breakpoints for the first interpolation cycle.
Examples
Here is an example of the randomi opcode. It uses the file randomi.csd.
Its output should include lines like this:
Mode: 0
k1 = 220.000000
k1 = 220.000000
k1 = 220.146093
k1 = 246.827703
k1 = 395.595775
...
Mode: 1
k1 = 220.000000
k1 = 224.325329
k1 = 274.370074
k1 = 343.216049
k1 = 414.324347
...
Mode: 2
k1 = 330.000000
k1 = 292.628171
k1 = 334.519777
k1 = 290.610602
k1 = 394.905366
...
Mode: 3
k1 = 360.727674
k1 = 431.680412
k1 = 380.625254
k1 = 289.267139
k1 = 303.038109
...
See also
Credits
Author: Gabriel Maldonado
Arguments imode and ifirstval added by François Pinot, Jan. 2011, after a discussion with Peiman Khosravi on the csnd list.
Example written by Kevin Conder, adapted for new args by François Pinot.