Random Number Limit?

For general discussion related FlowStone
Post Reply
Dugg Funnie
Posts: 3
Joined: Tue Sep 03, 2013 3:35 pm

Random Number Limit?

Post by Dugg Funnie »

hey everybody, first post! woohoo!

So, I'm working on a plug-in that will randomly load two effects and assigned parameters to an XY pad. Here's the issue I'm running into:

I have a Random prim that's time seeded and using an AfterLoad prim to trigger the generation (and thus the FX selection/assignment) when the plug-in is loaded. However, I'll only have a grand total of 12 effects to choose from, and given that the random prim generates 0-32767, a good percentage of the time it ends up just loading the last plug-in in the Selector's index. So, what can I do to limit the Random's range to something like 0-12 or anything like that?
User avatar
CoreStylerz
Posts: 327
Joined: Sun Jan 22, 2012 2:19 am
Location: italy
Contact:

Re: Random Number Limit?

Post by CoreStylerz »

Try this.
But is an workaround. :lol:
Seed max to 12.fsm
(386 Bytes) Downloaded 931 times
Need my support for app development, website or custom scripts?
PM me if you are interested.
Experienced Java, J2EE, PHP, Javascript, Angular, Cloud Solutions developer.
User avatar
trogluddite
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: Random Number Limit?

Post by trogluddite »

Much easier to use Ruby.
The randomness is automatically time/process seeded, and to get a random number 0-11 (assuming the FX are zero indexed), you need just one line...

Code: Select all

output rand(12)

Yup, that's it, just paste that into a Ruby box and change the input to a trigger and the output to an integer - done!
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
MyCo
Posts: 718
Joined: Tue Jul 13, 2010 12:33 pm
Location: Germany
Contact:

Re: Random Number Limit?

Post by MyCo »

...
Attachments
Reduced Rand (MyCo).fsm
(257 Bytes) Downloaded 875 times
Dugg Funnie
Posts: 3
Joined: Tue Sep 03, 2013 3:35 pm

Re: Random Number Limit?

Post by Dugg Funnie »

/\ Wow. That was simple! Thanks!
Post Reply