Hi there,
is it possible to generate a random number (best between 0 and 255) with a script?
Reason: I want to set a DMX fixture with a random value every beat by OS2L.
is it possible to generate a random number (best between 0 and 255) with a script?
Reason: I want to set a DMX fixture with a random value every beat by OS2L.
Mensajes Fri 17 Feb 23 @ 12:19 pm
No, there's no random seed generator.
However, I guess you could query something like volume (get_level), and multiply it with something like seconds elapsed to get a pseudorandom seed.
However, I guess you could query something like volume (get_level), and multiply it with something like seconds elapsed to get a pseudorandom seed.
Mensajes Fri 17 Feb 23 @ 2:09 pm
That sounds like an interesting experiment. A common way to generate (pseudo-)random values is to indeed take some kind of variable (as you suggest, get_level, or something else like get_cpu) and then mutiply that by a very large number and then use the MOD operator. But I can't find which operators are supported in VDJ script... (e.g. MOD).
Mensajes Sun 19 Feb 23 @ 2:23 pm
param_mod is a thing
Mensajes Sun 19 Feb 23 @ 8:31 pm
Although the required operations are indeed there (param_multiply, param_add, param_mod) it looks like the most basic random number generators require operations on 32-bit unsigned integers, and because vdj internally uses floating point for the param_ operations they don't seem to get the right result when i tried some.
Mensajes Mon 20 Feb 23 @ 5:54 am
I had the same use case as @bibi-b, sending random numbers to OS2L.
I accidentally wrote this code and have no idea why it works, ... but it seems to be enough to meet my usecase, a random "enough" number between 1-10. It requires a song to be playing to work because it uses get_time:
I accidentally wrote this code and have no idea why it works, ... but it seems to be enough to meet my usecase, a random "enough" number between 1-10. It requires a song to be playing to work because it uses get_time:
get_time & param_cast & get_time & param_mod 10 & param_add 1 & param_cast & debug
Mensajes Thu 26 Sep 24 @ 6:57 pm