Get poly~ instance number?


    Nov 26 2007 | 9:10 pm
    I've found the poly~ I'm in, can I also find the instance number I'm in?

    • Nov 27 2007 | 10:05 pm
      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
    • Nov 27 2007 | 10:32 pm
      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
    • Nov 27 2007 | 10:52 pm
      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).
    • Dec 19 2007 | 3:47 am
      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); }