Get poly~ instance number?

Nov 26, 2007 at 9:10pm

Get poly~ instance number?

I’ve found the poly~ I’m in, can I also find the instance number I’m in?

#34767
Nov 27, 2007 at 10:05pm

One option (although you may not like it) may be to load an instance of thispoly~ inside your external and interact with that. Although you may be opposed to this approach I have a feeling that anything else may involve undocumented bits of the API or the poly~/thispoly~ code. The other advantage of this approach is that it will work in Max 5 as any necessary changes will have been made by Cycling ’74.

You can always load up thispoly~ get the instance, store the result and then free your thispoly~, all in your new routine to conserve resources….

Regards,

Alex

#117815
Nov 27, 2007 at 10:32pm

Given a poly~ object, and a t_patcher *:

method m = zgetfn(x, gensym(“getindex”));
if (m) {
long index = (*m)(x, p);
}

This is undocumented, top seeeekret and might change at any time.

jb

Am 27.11.2007 um 23:05 schrieb Alex Harker:

>
> One option (although you may not like it) may be to load an
> instance of thispoly~ inside your external and interact with that.
> Although you may be opposed to this approach I have a feeling that
> anything else may involve undocumented bits of the API or the poly~/
> thispoly~ code. The other advantage of this approach is that it
> will work in Max 5 as any necessary changes will have been made by
> Cycling ’74.
>
> You can always load up thispoly~ get the instance, store the result
> and then free your thispoly~, all in your new routine to conserve
> resources….
>
> Regards,
>
> Alex

#117816
Nov 27, 2007 at 10:52pm

Quote: Jeremy Bernstein wrote on Wed, 28 November 2007 11:32
—————————————————-
> method m = zgetfn(x, gensym(“getindex”));
> if (m) {
> long index = (*m)(x, p);

Hah! I’d tried various things very close to that, but wasn’t guessing the right incantation – “getindex”. Thanks Jeremy.

Alex: Yes, I’d do that, but I’m already using the secret hacky stuff to find parentpatchers etc, so this is a simple addition to the same code. I’m aware it’s gonna break, hopefully Max 5 will make this stuff easier and more reliable (get parentpatcher at loadbang, get patcher args, are we in an abstraction, etc).

#117817
Dec 19, 2007 at 3:47am

Quote: Jeremy Bernstein wrote on Wed, 28 November 2007 11:32
—————————————————-
> Given a poly~ object, and a t_patcher *:
>
> method m = zgetfn(x, gensym(“getindex”));
> if (m) {
> long index = (*m)(x, p);
> }

One small addition – you must cast the method return to a long or XCode will complain that the return is a pointer:

m = zgetfn(poly, gensym(“getindex”));
if (m)
{
index = (long)(*m)(poly, patcher);
}

#117818

You must be logged in to reply to this topic.