1

A varying number of lists are stored in a coll object. Then a series of bangs is provided to a random integer generator. With each bang the generated integer will decide which list will go out of the coll. Obviously, this number must be between 1 and the varying length of the coll. This means that the RND generator has to take into account any changed length of the coll before generating the integer. So, I guess we have a circuit like the following:

  1. A loadbang-ed messagelength’ must enter the coll object to make it output its length.
  2. This length number must get into the right inlet of a ‘between’ (RND gen.) object to set its maximum.
  3. A bang in the left input of the ‘between’ object will generate a random integer.
  4. The integer will go back into the coll and make it output the corresponding stored list.
  5. The output list will be sent to an iteration mechanism that will read and output its atoms one by one.
  6. When the last atom of the current list is output, a new bang will be sent to the ‘between’ object so that a new list will be picked and the process will be repeated (stages #3 – 6).

The problem with the above process is that it stumbles on the functionality of the coll object: a coll outputs both its length and any stored data from the same outlet (why, I wonder?), but in processes like the above, the length of the coll must be output only once (in the beginning of the session) and it should only feed the ‘between’ object (it should never reach the iteration mechanism, since it is irrelevant). Therefore the routes of the coll's length and its data must be different, although they are all integers and they are all coming out of the same outlet.

Any ideas please?

JohnH
  • 2,713
  • 12
  • 21
spra
  • 19
  • 5

3 Answers3

1

Have you investigated the grab object? It's wiring is a bit counterintuitive, but it's a useful object for many things, including acting as a 'circuit breaker' in the kind of situation you're describing.

Setting up a grab object enables you to direct a message to an object's inlet, and then collect only the output associated with that message, without affecting any other patchcords that may be connected to the same outlet.

RiqueW
  • 212
  • 1
  • 12
  • grab does the job indeed. For some reason, I had ignored it until now. Never too late. Thank you. – spra Apr 20 '19 at 09:58
  • Hey @spra… just noticed your response (yikes, 2 months later!) Could you upvote and mark my answer as accepted, please? – RiqueW Jun 20 '19 at 16:32
  • Hi RiqueW, Just noticed your comment 7 months later! :-) So, now, I have the record! I thought I was not permitted to vote due to my... non existent credentials (I had seen such a message a long time ago). But I just clicked on that arrow up and now it shows 1 vote. Sorry for being so late and thanks again. – spra Jan 04 '20 at 10:00
1

I posted a reply with a solution I knocked up for you but a moderator deleted it.

So I've taken a screen shot, and hopefully that helps.

Essentially you can have loads of different messages (adding entries, selecting entries, deleting, renumbering...) go into coll, and just the ones coming out of coll go through the 1-in-2-out switch.

The default setting for the switch would be to route the output of coll to a multislider, or message box or where ever.

However in the case you want to capture the length output from the coll, use: [trigger 0 length 1] - 0 and 1 go to the left input of the switch, and 'length' goes to the coll.

  • first send the switch a 1 to route the coll output to the place you need it to go
  • then send the coll the length prompt - it'll pass out the second output of the switch
  • then close the gate with a 0 - routing coll's output back to it's normal place

Any time you need the length updated (like after adding or deleting an entry) you just send that trigger module a bang. patch screenshot

Peter O.
  • 32,158
  • 14
  • 82
  • 96
  • Now I see how you mean. Yes, this is a good solution, too. Thanks for the screenshot. – spra Jan 05 '20 at 20:27
0

I solved this over the last few days by using a gswitch2 and a trigger object to open and close it either side of the message: [t 0 length 1]

The coll is plugged into the gswitch so it's messages are routed to the length functions just for that moment they're needed, and otherwise routed to the objects that need the coll contents.

-exeterdown

  • I am not sure how this works. Trigger object = [t 0 length 1] means that with each incoming signal it will open gswitch's first outlet, then it will output 'length' and then open gswitch's second outlet. But the next incoming signal will do the same, which is not what we want. What we do want is a switching mechanism that outputs the coll's length only once, not on every signal. So I was not able to solve the problem your way. Maybe I have not understood your circuit. If you think you can describe it more analytically then I might be able to reproduce it. – spra Jan 04 '20 at 14:42