Forums > Dev

instantiating and accessing abstraction inlets/outlets

December 26, 2012 | 1:51 am

(These questions might keep coming. looks like I’ll be a noob for a minute.)

I’m instantiating abstractions with the included code. I’m looking to create a static object that lets you access a single abstraction from a number of named objects. (similar to buffer~ or coll.) I’m thinking this could make the oo.* objects very useful.

my tasks are
A) counting the inlets and outlets so that I can give the wrapper object the same number of inlets and outlets. (I know this is stored in t_object but it’s "subject to change")
B) sending incoming messages to specific inlets in the abstraction
C) listening to specific outlets of the abstraction

I’ve figured out how to make a centralized struct that’s shared amongst objects. And I stole the following code from the scriptto example. But I’m unsure where to look in the documentation for the rest of this information

Any fingers pointing in the right direction would be much appreciated.

t_dictionary *d = dictionary_new();
char parsebuf[256];
t_atom a;
long ac = 0;
t_atom *av = NULL;

// create a patcher without scroll bars and a toolbar
sprintf(parsebuf,"@defrect 0 0 300 400 @title scripto @enablehscroll 0 @enablevscroll 0 @presentation 0 @toolbarid """);
atom_setparse(&ac,&av,parsebuf);
attr_args_dictionary(d,ac,av);
atom_setobj(&a,d);
sysmem_freeptr(av);
myData->s_patcher=(t_object *)object_new_typed(CLASS_NOBOX,atom_getsym(argv+1),1, &a);
freeobject((t_object *)d);	// we created this dictionary and we don't need it anymore
object_method(myData->s_patcher,gensym("vis"));
object_attach_byptr_register(x, myData->s_patcher, CLASS_NOBOX);// attach our UI object to us

December 26, 2012 | 9:56 am

UG!!! That hour I'll never get back! I've just noticed that the tables of patcher and box attributes run off the edge of the page in the PDF version. The HTML version is complete.

Thanks for your clue!

As for B/C it looks like I'll have to put my static object inside a static patcher, count the inlets and outlets and script little mat.static.in/out objects.

[attachment=211203,4796]

Attachments:
  1. screenshot.jpg

December 26, 2012 | 12:05 pm

I have. In fact I use them a lot. The goal here is different. I’d like to be able to access a single data structure from anywhere in any patcher hierarchy. I also think the patching is going to be more elegant. Here’s a sketch of what I’m thinking in pseudocode. Adding a refer message would be off the hook too.

– Pasted Max Patch, click to expand. –

December 27, 2012 | 7:44 pm

It works with both abstractions and C objects. Now you can even switch between named structures like coll!

The only thing I can’t quite get working is a double click function that would open the internal object.

Right now it opens the patcher that contains the internal object which is kind of ghetto. Also if you close that window, the patcher is freed for some reason which makes the external unstable.

is there a way to determine if an object has a subpatcher inside it and also a way to get that subpatcher?

Give it a shot. I can upload the xcode project if you want it.

Attachments:
  1. matstatic.zip

December 29, 2012 | 2:50 pm

See if it this compiles (or if it’s even written correctly) It’s working nicely for me for what it’s worth.

I don’t know what’s Max 5 or 6 API or 10.4 or 10.6. I don’t even know how to reliably change the compile location :-)


December 29, 2012 | 3:00 pm

I just realized that’s fairly uncommented. I can do that. If you’re actually interested in picking it apart let me know.


January 4, 2013 | 9:33 pm

See what you think. I’ve heavily commented this and included a help file. It’s already been super helpful in patching. I don’t think I’m doing anything over the line here but then again I don’t know where the line is.

http://dl.dropbox.com/u/45041437/MatStaticWithSource.zip


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