Forums > MaxMSP

SIMPLE PROBLEM: Send a bang to one of many bpatchers

February 10, 2013 | 1:10 pm

here’s the idea.

I have a live.knob with a range of 0-127. I also have 128 bpatchers. I want to send a bang to the bpatcher selected by the knob.

preferably without having to connect 128 different objects maybe using ‘send’/'receive’ or ‘forward’.


February 10, 2013 | 3:28 pm

thinking also about how to do that some elegant way, but maybe worth mentioning that connecting route object to even 128 object can be done in a minute or two using the [thispatcher] scripting / "script connect" message + a counter and uzi…


February 10, 2013 | 6:56 pm

I would send the value of the knob, and select for it in the bpatcher. This assumes that one of the arguments to the bpatcher is what instance it is.


February 10, 2013 | 8:24 pm

One possible solution:

– Pasted Max Patch, click to expand. –

February 11, 2013 | 12:17 am

Django that is pretty nice and succinct coding! before I start manually connecting 128 bpatchers to receivers…is it possible to create one bpatcher with ‘receiver#’ (not sure of syntax) embedded with code so that as I duplicate it in the parent, max increments it with a unique identifier?

I think i’ve seen this before in other patches but i’m uneducated with syntax…

You’re totally getting credit for this bit of code! Thanks!


February 11, 2013 | 12:31 am

@Chris Muir …not sure how to do that easily for 128 bpatchers.

@Dnk777 … can you post an example?


February 11, 2013 | 1:44 am

django: nice!

mssngmrblz: ok, it took me bit more than 1-2 minutes, because messages won’t replace $1 with number, if the $1 is closed in []. so i had to use combine object. but maybe 3-4 minutes and when you have it built, you can reuse. I think this is a must, if you work on a patch with 128 bpatchers…

(please note one stupid thing i did in this example was giving the scripting names starting with [1]. that was stupid, because the inlets/outlets are numbers from 0 and you usually want to connect first of the many objects to first of the many inlets/outlets. so you better start with [0] on end of the scripting name, and then just duplicating or copy/pasting will create [1], [2], …[n])

– Pasted Max Patch, click to expand. –

February 11, 2013 | 9:41 am

I’d do this with pattrforward.

Give each of your bpatchers a scripting name containing some numeric/index element, e.g. myBpatcher[3]

Use the value from the live.dial to set which bpatcher the pattrforward is currently routing to

Send a bang to the pattrforward object (which will forward the message to the currently targeted bpatcher), using an ‘in0′ prefix to ensure your bang goes the correct inlet of th bpatcher.

Example below

– Pasted Max Patch, click to expand. –

February 11, 2013 | 1:56 pm

or use Nathanael Decaude’s max toolbox.


February 11, 2013 | 11:34 pm

+1 for the toolbox…connecting 128 objects can be done with one mouse selection and a keystroke.

When you originally create the bpatchers, give them the array name: my_bpatcher[1]
…then when you duplicate, they’ll auto-name with [2] [3] etc.
Problem: How to give each one an argument? Arguments won’t auto-increment with this method.
Possible solution: [thispatcher] to [sprintf script sendbox my_patcher[%u] argument %u]

Can’t test it now, but can [thispatcher] send a message to [bpatcher] to set its arguments?
If so, you’re done with a [route #1] in the bpatcher.


February 12, 2013 | 3:34 am

seejayjames: i don’t think there is a way to add argument(s) to existing object using thispatcher, but you could use it to create new 128 objects with arguments…


February 12, 2013 | 4:44 am

The patcher scripting name does auto-increment, so you could get that name from within the bpatcher, and then use that number to select the number to bang.
Here’s an example:

Attachments:
  1. bpatcherbang.zip

Viewing 12 posts - 1 through 12 (of 12 total)