see attachment <div>uses tabdumb and list-idx</div><div>chooses one of 18 'onn/off states' in a table randomly and flips it<br><div><div>gr,</div><div>Tim<br><br><div class="gmail_quote">2010/8/17 Frank Barknecht <span dir="ltr"><<a href="mailto:fbar@footils.org">fbar@footils.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Joćo,<br>
<div class="im"><br>
On Tue, Aug 17, 2010 at 04:30:00PM +0100, Joćo de Brito Rocha Reis Vidigal wrote:<br>
> Here's what I wanna do:<br>
><br>
> I have 18 slot for audio and video to play. There can be one playing, none or even um to the 18.<br>
> These slots are to be triggered randomly.<br>
> Is there a possibility of storing the ID of the slots already triggered? Like a list? The thing is that if it is a list it would have to have a variable number of floats (wouldn't it?).<br>
> Why do I need this? Because after triggering a random slot ON I want to trigger a random slot OFF. So, I have to know what are the slots triggered on in order to trigger one of these OFF and not one 18. Otherwise I could end up triggering off a slot that was never on!<br>
> As well I need to know witch ones are OFF to randomly select and turn one on.<br>
<br>
</div>A brute-force approach to your problem is attached: It uses [select] to<br>
re-trigger the random selection if you get a slot-value that already is off.<br>
If instead you get a usable slot-value, it stores this in a [f] object<br>
by using the cold, right inlet, so it can be switched off later, then<br>
also updates the [select] via its right inlet to watch for the new "ON"<br>
slot.<br>
<br>
There is a small risk to get a lot of the same values from [random] but<br>
this is very, very unlikely.<br>
<br>
You should remember the<br>
<br>
[t f b]<br>
\/<br>
/\<br>
[f ]<br>
<br>
idiom to delay the output of a float value by one execution step. It's<br>
often useful, and also the use of [select] to filter out unwanted<br>
values.<br>
<br>
You can also do all this without storing the OFF value by transferring<br>
the logic of switching off or on into your "slot" abstractions. The<br>
c_tgl.pd abstractions shows how to do that. It compares an incoming<br>
slot-number with [== $1] where $1 is the slot-id passed as argument. It<br>
has a global receiver in it to simplify patching a bit.<br>
<br>
Ciao<br>
--<br>
<font color="#888888">Frank<br>
</font><br>_______________________________________________<br>
<a href="mailto:Pd-list@iem.at">Pd-list@iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -> <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
<br></blockquote></div><br></div></div></div>