SIMPLE PROBLEM: Send a bang to one of many bpatchers

Feb 10, 2013 at 1:10pm

SIMPLE PROBLEM: Send a bang to one of many bpatchers

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’.

#66434
Feb 10, 2013 at 3:28pm

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…

#239152
Feb 10, 2013 at 6:56pm

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.

#239153
Feb 10, 2013 at 8:24pm

One possible solution:

– Pasted Max Patch, click to expand. –
#239154
Feb 11, 2013 at 12:17am

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!

#239155
Feb 11, 2013 at 12:31am

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

@Dnk777 … can you post an example?

#239156
Feb 11, 2013 at 1:44am

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. –
#239157
Feb 11, 2013 at 9:41am

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. –
#239158
Feb 11, 2013 at 1:56pm

or use Nathanael Decaude’s max toolbox.

#239159
Feb 11, 2013 at 11:34pm

+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.

#239160
Feb 12, 2013 at 3:34am

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…

#239161
Feb 12, 2013 at 4:44am

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
#239162

You must be logged in to reply to this topic.