Is there an object, that bangs a specified outlet when given a number?

gpvillamil's icon

I am looking for an object with a single inlet and multiple outlets, than when given a number as input would send a bang out the corresponding outlet.

This is for controlling a step sequencer.

As far as I can tell, people who have done this mostly use a router object (router 1 2 3 4) and then send it a # followed by a bang or else they send lists of 0 0 0 1 0 into an unpack object.

Seems like a simple thing. Is there an object like what I describe?

Luke Hall's icon

The [select] object will do this if you instantiate it with the amount of outlets you need. For example: [sel 1 2 3 4 5 6 7 8].

lh

gpvillamil's icon

Aha! Peter Elsea's Banger object seems to do this exactly. Kind of surprising that it doesn't exist in Max directly.

Tim Lloyd's icon

It kind of does exist in [spray].

Max Patch
Copy patch and select New From Clipboard in Max.

Tim Lloyd's icon

actually nevermind, [select] does exactly that

gpvillamil's icon

Yeah, I saw select used that way, but you have to fill in the list values (eg. 0 1 2 3 4) to get the outlets, whereas Elsea's banger object you just give it the number of outlets (eg. (banger 5)) and then it will spit out a bang when you feed it an integer.

seejayjames's icon

Here's an example using [gate], which lets you specify the number of outlets. The caveat is the triggering order: first open the outlet you want, then send the bang through.

I guarantee this will be (at least a little bit) fun to play with

Max Patch
Copy patch and select New From Clipboard in Max.

gpvillamil's icon

That's smart! I think (trigger b i) followed by a (gate) is exactly what I've been looking for.

Also, in your patch, you can replace all the set + number boxes by sticking a (switch) object right below the number boxes.

Then the trigger object that opens the gate can also open the switch, before sending the bang, and then sends a 0 to close the switch. See below.

Max Patch
Copy patch and select New From Clipboard in Max.

Luke Hall's icon

Another method would be to use [pak] and [zl lookup]. Then you can deal with your sequenced pattern as a list and use [vexpr] and [zl rot], [zl scramble] etc to modify them as well as storing the individual values with [preset] or the [pattr] system.

lh

Max Patch
Copy patch and select New From Clipboard in Max.

gpvillamil's icon

Thanks! Every post on this thread has been inspiring and useful.

What is a good way to get the pattern back into the number boxes after going through the zl scramble operation?

seejayjames's icon

Looking at it again, it's even easier to use [i ] at the end, before banging it into a note. This eliminates the need for the set or switch and is maybe faster, not sure.

For the [zl scramble] or [zl rot] getting back into the number boxes, that depends on how you set things up. I usually have some sort of cascade where the last list is what's utilized, but is read-only or hidden. Otherwise you do need some sort of set operation, which you'd think would be straightforward, but if you "re-set $1" for elements of a list that you've just rotated, you'll get some bizarre offseting results.

Try the multisliders in the ZL subpatch to see what I mean... if you set the rotated values back into the list, it's not what you might expect, but on the other hand can be used to easily generate cool repeating patterns, based on the rotate amount and the number of sliders.

I'm sure there are other solutions for the "setting values back into themselves", maybe with [v] or [pvar].

Max Patch
Copy patch and select New From Clipboard in Max.