Class-Like Behaviour In a Max Patch?

Joe Kaplan's icon

Hi! Does anyone have an suggestions in Max for how get a behaviour similar to instantiating a class in object-oriented programming?

Example, I have a [jit.gl.gridshape] and I'm feeding it a bunch of attributes values.

As my patch runs, some event occurs, and when this event occurs I want to programmatically create a new [jit.gl.gridshape] with it's own attribute values.

Various events in the patch will create, remove, and adjust the attributes of these gridshapes independently.

In an object-oriented language, I would create a class called gridsphape, and then instantiate instances of that class, each with unique names, and then manipulate them.

MAX doesn't seem to lend itself to working in this way as far as I can tell.
One solution i can think of is to create a subpatch that manages my gridsphaes. Save the subpatcher as a file, and then use Patcher Scripting to create and manipulate instances of it.

Before I embark in that direction, I'm curious if there are any different or better solutions I might be missing. Thanks in advance!

2K's icon

Check either jit.gl.multiple or put your stuff inside a poly~

Joe Kaplan's icon

jit.gl.multiple is cool. But i think poly~ is exactly what is needed here.

Wow, there's a lot more power in that object than what is suggested in the simple polyphony example. In case there was any doubt that max is great... THANK YOU!

Roman Thilenius's icon

it is not so common to use poly~ for data rate, but it absolutely works, and more or less does what you describe what you would do it in C++.