Forums > MaxMSP

can patcher find out what it's outlet is connected to?

December 18, 2010 | 11:34 am

is there any way, from inside a patcher file, to get any info about whether or not it’s outlets/inlets are connected in the parent patch? thanks.

December 18, 2010 | 11:36 am

not at all, at least not non-idiosyncratic.

December 20, 2010 | 3:17 pm

First of all, you should think carefully if you really want to do this. A situation where a patcher needs to know what its outlets are attached to is breaking the vaguely-object-oriented, black-box model patchers in Max/MSP follow. I’m not trying to be the thought police, I’m just saying that the patching model where you do this tends to create more problems then it solves.

Believe me, I’ve done this with externals I’ve developed, and lived to regret it.

One way to get this information is to have your object send a special ‘request’ message through its outlets that the recipient objects reply to by sending a ‘response’ message. So you’ve got to build the recipient objects to respond in some way. As a practical matter, the request message will include a symbol identifying the sender and the responding objects will use that identifier to set the target of a [forward] object to use for sending the responses.

It’s all pretty fragile. And, obviously, will only work with patchers that you’ve built to handle your request/response protocol.

January 14, 2011 | 8:05 am

You could also read in the source text of the parent patcher and write a parser. Though there is not too much documentation about the format, its much more readable since Max 5 and pretty self explanatory.

1. get the coordinates of your object and the file name of the parent with javascript.
2. read the source.
3. parse for "patching_rect" of your object.
4. go back to until you get the id of your box.
5. search for patchline destinations with your id as source.
If there is none, its not connected.

I bet its not worth the hassle…
What are you after, that you need it? There might be better ways to achieve the same…


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