Getting matrix type


    Jun 17 2006 | 7:28 pm
    This is probably for Jeremy or Joshua.
    I have an object that wants to query its type as part of a custom
    attribute set method. I have tried to find sample code doing this in
    the SDK projects without success.
    Here's what I want to do in pseudo-code, starting with a stripped
    down Jitter initialization function:
    ===================
    t_jit_err InitializeJitterObject(void)
    {
    jit_class_new(...);
    jit_object_new(...);
    jit_class_addadomrnment(...);
    jit_class_addmethod(...); // repeat for all methods
    // AddAttributes -- This is the interesting part
    attr = jit_object_new(_jit_sym_jit_attr_offset_array,
    "loc", _jit_sym_float64,
    JIT_MATRIX_MAX_PLANECOUNT, kAttrRWFlags,
    (method) NIL,
    (method) ExpoSetLoc, // SEE BELOW
    calcoffset(jcobExpo, planeCount),
    calcoffset(jcobExpo, loc)
    );
    // Finish off
    jit_class_register(gExpoJitClass);
    return JIT_ERR_NONE;
    }
    ...
    static void ExpoSetLoc(
    objExpo* me, // This is the Jitter object
    void* attr, // Unused
    long iArgC,
    Atom iArgVec[])
    {
    Symbol typeSym = GetObjectType(me); // HOW DO I DO THIS??
    if (typeSym == _jit_sym_char) {
    // Clip input values in iArgVec to 0 .. 256 and store
    }
    else if (typeSym == _jit_sym_long) {
    // Clip input values to kLongMin .. kLongMax and store
    // A little anal retentive, but just to be safe
    }
    // otherwise just store without clipping
    }
    ===================
    Is this reasonable to want to do? If so, how?
    It seems likely that the pseudo-function GetObjectType() will do
    something like
    jit_object_method(me, _jit_sym_gettype, ...);
    but I can't find an example of how this would work.
    Thanks,
    Peter
    -------------- http://www.bek.no/~pcastine/Litter/ -------------
    Peter Castine +--> Litter Power & Litter Bundle for Jitter
    iCE: Sequencing, Recording & |home | chez nous|
    Interface Building for |bei uns | i nostri|
    Max/MSP Extremely cool http://www.castine.de

    • Jun 17 2006 | 7:47 pm
      What do you mean by type? Do you mean like if the object is say
      jit.wake that the type will be "jit_wake"? If this is the case, you
      just need the function
      t_symbol *jit_object_classname(void *x);
      Hopefully this helps you out. Otherwise, I need some clarification.
      best,
      wes
    • Jun 17 2006 | 7:53 pm
      On Jun 17, 2006, at 12:28 PM, Peter Castine wrote:
      > This is probably for Jeremy or Joshua.
      >
      > jit_object_method(me, _jit_sym_gettype, ...);
      t_symbol *mytype = jit_attr_getsym(me,_jit_sym_type);
      Or if you really prefer, here's how you would accomplish with
      jit_object_method:
      t_atom *av=NULL;
      long ac=0;
      t_symbol *mytype;
      jit_object_method(me,_jit_sym_gettype,∾,&av);
      if (ac&&av) {
      mytype = jit_atom_getsymbol(av);
      jit_freebytes(av);
      }
      Lastly, we typically look at this with matrices using the standard
      getinfo with the matrixinfo struct.
      -Joshua
    • Jun 18 2006 | 5:56 am
      On 17-Jun-2006, at 21:53, Joshua Kit Clayton wrote:
      > t_symbol *mytype = jit_attr_getsym(me,_jit_sym_type);
      That's pretty easy. Thanks.
      > Or if you really prefer, here's how you would accomplish with
      > jit_object_method:
      [schnipp]
      Useful to know.
      > Lastly, we typically look at this with matrices using the standard
      > getinfo with the matrixinfo struct.
      You mean a t_jit_matrix_info? That's the way I do it in my
      matrix_calc method. But I'm not sure how to get a pointer to a
      t_jit_matrix_info in the situation I was describing, namely inside a
      custom set-attribute method.
      It might actually be better to clip the attribute values inside the
      matrix_calc method anyway. I'm not sure.
      --
      Thanks also to Wes. The issue is whether my Jitter object is dealing
      with a char/long/float32/float64 matrix (ie "type" as in the
      attribute "type" that shows up in the "messages for " popup
      menu). Sorry if there was confusion.
      -- P.
      -------------- http://www.bek.no/~pcastine/Litter/ -------------
      Peter Castine +--> Litter Power & Litter Bundle for Jitter
      iCE: Sequencing, Recording & |home | chez nous|
      Interface Building for |bei uns | i nostri|
      Max/MSP Extremely cool http://www.castine.de
    • Jun 18 2006 | 6:40 am
      I think so, since if your object is adapting, the output matrix type
      could change with each inoming matrix.
      Here's some untested code for getting the type on the fly from an
      arbitrary point in your code, given the Jitter object pointer.
      void *mop = jit_class_adornment_get(_myobject_class, _jit_sym_jit_mop);
      void *o = jit_object_method(mop, _jit_sym_getoutput, 1);
      void *m = jit_object_method(o, _jit_sym_getmatrix);
      t_jit_matrix_info info;
      jit_object_method(m, _jit_sym_getinfo, &info);
      t_symbol *type = info.type;
      Am 18.06.2006 um 07:56 schrieb Peter Castine:
      > It might actually be better to clip the attribute values inside the
      > matrix_calc method anyway. I'm not sure.
    • Jun 18 2006 | 6:57 am
      On 18-Jun-2006, at 8:40, Jeremy Bernstein wrote about when to check
      matrix type:
      > I think so, since if your object is adapting, the output matrix
      > type could change with each inoming matrix.
      That was what was concerning me, although I wasn't able to formulate
      the concern succinctly last night. I was trying to shave a
      performance improvement by clipping at set-attribute time (happens
      typically less often than process-matrix time), but that's a false
      economy.
      > Here's some untested code for getting the type on the fly from an
      > arbitrary point in your code, given the Jitter object pointer.
      The snippet gets filed under "Very Good to Know". Cool, vielen Dank!
      -- P.
      PS: You're up and about early on a Sunday morning!
      -------------- http://www.bek.no/~pcastine/Litter/ -------------
      Peter Castine +--> Litter Power & Litter Bundle for Jitter
      iCE: Sequencing, Recording & |home | chez nous|
      Interface Building for |bei uns | i nostri|
      Max/MSP Extremely cool http://www.castine.de