see attachment uses tabdumb and list-idx chooses one of 18 'onn/off states' in a table randomly and flips it gr, Tim
2010/8/17 Frank Barknecht <[email protected]> > Hi João, > > On Tue, Aug 17, 2010 at 04:30:00PM +0100, João de Brito Rocha Reis Vidigal > wrote: > > Here's what I wanna do: > > > > I have 18 slot for audio and video to play. There can be one playing, > none or even um to the 18. > > These slots are to be triggered randomly. > > 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?). > > 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! > > As well I need to know witch ones are OFF to randomly select and turn one > on. > > A brute-force approach to your problem is attached: It uses [select] to > re-trigger the random selection if you get a slot-value that already is > off. > If instead you get a usable slot-value, it stores this in a [f] object > by using the cold, right inlet, so it can be switched off later, then > also updates the [select] via its right inlet to watch for the new "ON" > slot. > > There is a small risk to get a lot of the same values from [random] but > this is very, very unlikely. > > You should remember the > > [t f b] > \/ > /\ > [f ] > > idiom to delay the output of a float value by one execution step. It's > often useful, and also the use of [select] to filter out unwanted > values. > > You can also do all this without storing the OFF value by transferring > the logic of switching off or on into your "slot" abstractions. The > c_tgl.pd abstractions shows how to do that. It compares an incoming > slot-number with [== $1] where $1 is the slot-id passed as argument. It > has a global receiver in it to simplify patching a bit. > > Ciao > -- > Frank > > _______________________________________________ > [email protected] mailing list > UNSUBSCRIBE and account-management -> > http://lists.puredata.info/listinfo/pd-list > >
#N canvas 50 347 563 424 10; #X obj 70 39 random 18; #X obj 70 105 tabdump statelist; #X obj 70 198 tabwrite statelist; #X obj 70 68 t b f; #X obj 70 136 list-idx; #X obj 70 15 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1 -1; #X obj 70 165 == 0; #N canvas 0 0 450 300 (subpatch) 0; #X array statelist 18 float 3; #A 0 0 1 0 0 0 1 1 1 1 1 0 0 1 1 1 1 1 0; #X coords 0 1 17 -1 200 140 1; #X restore 212 59 graph; #X connect 0 0 3 0; #X connect 1 0 4 0; #X connect 3 0 1 0; #X connect 3 1 2 1; #X connect 3 1 4 1; #X connect 4 0 6 0; #X connect 5 0 0 0; #X connect 6 0 2 0;
_______________________________________________ [email protected] mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
