Home › Forums › General › Programming › nice random
Tagged: random
- This topic has 8 replies, 2 voices, and was last updated 6 years, 1 month ago by human fly.
-
AuthorPosts
-
March 5, 2018 at 7:40 am #82753
thought i’d share this little script for randomizing
a list of parameters with different values ranges.
(the seeder is by Possemo, and the min/max property
was from something by dnaldoog)function randVoice() -- This variable stops index issues during panel bootup if panel:getRestoreState() == true or panel:getProgramState() == true then return end -- ----------------------------------------------------- local t=os.time() --[random seeder]-- local c=os.clock() math.randomseed(t*c) -- ----------------------------------------------------- local param=nil local min=nil local max=nil local rnd=nil for i=1,21 do param=tbl_voiceParam --[Voice Edit params]-- --[any value range]-- min = param:getProperty("modulatorMin") max = param:getProperty("modulatorMax") rnd=math.random(min,max) param:setModulatorValue(rnd,false,false,false) end end
i also tried to shorten it, but for some reason, the following
does not seem to work (bad argument):-- for i=1,21 do -- --[any value range]-- -- tbl_voiceParam:getProperty("modulatorMin") -- tbl_voiceParam:getProperty("modulatorMax") -- rnd=math.random(min,max) -- tbl_voiceParam:setModulatorValue(rnd,false,false,false) -- end --end
March 5, 2018 at 12:02 pm #82755There is a better randomseed:
math.randomseed(Time.getMillisecondCounterHiRes())
The other one does not work correctly when using 32-Bit Ctrlr.You aren’t using i anywhare in your loop. This will set the same parameter 21 times?
March 5, 2018 at 11:08 pm #82784ok, i’ll check out your new seeder if you say the other
one has problems – working great here with 64bit.sorry, that’s the forum omitting square brackets without
the space, i thought that was fixed because it appeared
ok when i posted. should read:for i=1,21 do param=tbl_voiceParam[ i ] --[ Voice Edit params ]-- --[ any value range ]-- min = param:getProperty("modulatorMin") max = param:getProperty("modulatorMax") rnd=math.random(min,max) param:setModulatorValue(rnd,false,false,false) end
hope it reads better now.
March 5, 2018 at 11:16 pm #82785so this should also be:
-- for i=1,21 do -- --[any value range]-- -- tbl_voiceParam[ i ]:getProperty("modulatorMin") -- tbl_voiceParam[ i ]:getProperty("modulatorMax") -- rnd=math.random(min,max) -- tbl_voiceParam[ i ]:setModulatorValue(rnd,false,false,false) -- end --end
i tried
(tbl_voiceParam[ i ])
,regular brackets, as well, and figure
it ought to work (?) so i don’t know how to do that. it’s just to skip
a stage, thought it would do that.March 5, 2018 at 11:55 pm #82786Ah ok. I have seen this too. In some cases you have to put it in a variable first.
March 9, 2018 at 10:05 pm #82826confirming that your new seeder is working fine.
thanks! (hope it isn’t producing pseudo-random?
s’pose not, if it depends on system clock)i like your comment ‘in some cases’ LOL
would you like to elaborate?
(‘coz i’ve found some other interesting ‘in some
cases’ with some other stuff. i’ll have to get
together a post for those – found workarounds though.
like: you do *exactly the same thing, in the same context*
and in one case it works, but not in the second… wdf…)March 9, 2018 at 11:07 pm #82830The newer seed uses a high resolution time counter. I guess it will produce a small number with many decimal points. This seems to work better on 32-Bit app than a big number randomseed. On x64 it doesn’t seem to make a difference. I saw the hires counter on a demo panel from atom. You can learn a lot when you check all demo panels carefully.
“in some cases”: I would say you have to use “interim” variables in some cases when you are accessing modulators such as panel:getModulatorByName etc.
March 10, 2018 at 12:14 am #82831interim variable, makes sense.
(think i figured out why the other thing wasn’t working)March 10, 2018 at 8:22 am #82839ah: discovered something interesting…(change of topic, really,
this should be over on RX7 topic) …
i am checking my data reference lists with ‘print jobs’,
because i have to match 1,100 lists to 1,128 lists, for the
purpose of assigning voice numbers to midi note numbers.i’m printing stuff out in a format that i can copy and paste
from the console into a table directly.so i’ve discovered that i cannot have
"""
because it just
leaves the apostrophes open, …of course. i need to do this
because i’m displaying numbers concatenated with text, and
then concatenate a comma in apostrophes, so it’s ready to
just paste where i want it.although it is not ‘recommended to mix
"
and'
, i found
that i can do it for this purpose and get the result wanted.ie:
" ' "
anyway: that’s it for the random topic. i’m over on the RX7
thing now. 😉- This reply was modified 6 years, 1 month ago by human fly. Reason: amended
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.