setcell jit_object_method


    Oct 30 2006 | 7:10 pm
    Hi. I'm stuck again... Finally I'm talking to a matrix in my patch. x->pos_mx is a valid pointer to a t_jit_matrix. The atom array is filled with valid arguments. The setall() function works fine, the setcell() function does nothing.
    I'm using the windows sdk, while reading the new mac sdk. Is this maybe the problem? I noticed that jit_object_method_typed is also not available for windows....(?).
    What the hell am I missing here? I don't get any errors from max or my compiler. If setcell() is not available what methods can I use for fast matrix access? In this case I want to write xyz values to a 3 plane matrix.
    cheers, -thijs
    void jit_csvs_stream(t_jit_csvs *x, long offset) { long mrk_id = 5, tmplong; t_mrk *m = NULL; long argc = 5; t_atom argv[5]; t_atom tmpatom;
    if(flags.pos_mx_isset) { m = jit_csvs_get_marker(x, mrk_id, offset); if(m) { jit_atom_setlong(argv, offset); jit_atom_setlong(argv+1, mrk_id); jit_atom_setfloat(argv+2,(m->x)*0.001f); jit_atom_setfloat(argv+3,(m->y)*0.001f); jit_atom_setfloat(argv+4,(m->z)*0.001f);
    // ----------this one works fine ---------------------------------------------- jit_atom_setfloat(&tmpatom, (float)(offset/128.f)); jit_object_method(x->pos_mx, gensym("setall"),0L,1,&tmpatom);
    // -------- this seems to do nothing ------------------------------------ jit_object_method(x->pos_mx, gensym("setcell"),0L,argc,argv);
    }else{ post("marker pointer null"); } } }

    • Oct 30 2006 | 8:35 pm
      After some further investigation I drew the conclusion that you probably have to access the matrix data directly. Although the scalebias example is still a bit confusing to me, its in there, so I guess I will figure it out. I think it would still be very convenient to have an interface like setcell(). So if its available please let me know.
      -thijs
      On 10/30/06, Thijs Koerselman wrote: > > Hi. I'm stuck again... Finally I'm talking to a matrix in my patch. > x->pos_mx is a valid pointer to a t_jit_matrix. The atom array is filled > with valid arguments. The setall() function works fine, the setcell() > function does nothing. > > I'm using the windows sdk, while reading the new mac sdk. Is this maybe > the problem? I noticed that jit_object_method_typed is also not available > for windows....(?). > > What the hell am I missing here? I don't get any errors from max or my > compiler. If setcell() is not available what methods can I use for fast > matrix access? In this case I want to write xyz values to a 3 plane matrix. > > cheers, -thijs > > > > void jit_csvs_stream(t_jit_csvs *x, long offset) > { > long mrk_id = 5, tmplong; > t_mrk *m = NULL; > long argc = 5; > t_atom argv[5]; > t_atom tmpatom; > > if(flags.pos_mx_isset) > { > m = jit_csvs_get_marker(x, mrk_id, offset); > if(m) > { > jit_atom_setlong(argv, offset); > jit_atom_setlong(argv+1, mrk_id); > jit_atom_setfloat(argv+2,(m->x)*0.001f); > jit_atom_setfloat(argv+3,(m->y)*0.001f); > jit_atom_setfloat(argv+4,(m->z)*0.001f); > > // ----------this one works fine > ---------------------------------------------- > jit_atom_setfloat(&tmpatom, (float)(offset/128.f)); > jit_object_method(x->pos_mx, gensym("setall"),0L,1,&tmpatom); > > // -------- this seems to do nothing > ------------------------------------ > jit_object_method(x->pos_mx, gensym("setcell"),0L,argc,argv); > > }else{ > post("marker pointer null"); > } > } > } >
    • Oct 30 2006 | 10:24 pm
      On Oct 30, 2006, at 12:35 PM, Thijs Koerselman wrote:
      > After some further investigation I drew the conclusion that you > probably have to access the matrix data directly. Although the > scalebias example is still a bit confusing to me, its in there, so > I guess I will figure it out. I think it would still be very > convenient to have an interface like setcell(). So if its available > please let me know.
      From your code sample, it appears that you're forgetting to use the "val" delimiter required by the "setcell" method to identify where the cell position ends and the value begins. If you're only using a 1/2/3D matrix, you can use the setcell1d, setcell2d, setcell3d utility methods which don't require the val delimiter.
      However, if you're going to set lots of values in your matrix, it's definitely faster to access the matrix data directly. You could to make a macro for matrix cell random access given t_jit_matrix_info and a data pointer. Something like the following email client code (might be typos) should get you going in the right direction
      #define CELL_PTR_1D (info,data,x) (((uchar *)(data))+(info)->dimstride [0]*(x)) #define CELL_PTR_2D (info,data,x,y) (CELL_PTR_1D(info,data,x)+(info)- >dimstride[1]*(y)) #define CELL_PTR_3D (info,data,x,y,z) (CELL_PTR_2D(info,data,x,y)+ (info)->dimstride[2]*(z))
      float *f;
      f = (float *) CELL_PTR_2D(info,data,x,y); f[0] = 0.f; f[1] = 1/2.f; f[2] = 666.f;
      -Joshua
    • Oct 30 2006 | 10:45 pm
      Thanks Joshua, didn't know about the delimiters. I guess I'm used to js too much. I don't have much experience with macros, but I'll look into it.
      It turned out to be quite easy to access my matrix directly. As it is always 3plane float32 2d matrix. I finally got it working, and its FAST. I replaced a max patch using 100 % cpu with an external that uses only 3%... or maybe I'm really bad at patching;-)
      cheers, -thijs
      On 10/30/06, Joshua Kit Clayton wrote: > > > On Oct 30, 2006, at 12:35 PM, Thijs Koerselman wrote: > > > After some further investigation I drew the conclusion that you > > probably have to access the matrix data directly. Although the > > scalebias example is still a bit confusing to me, its in there, so > > I guess I will figure it out. I think it would still be very > > convenient to have an interface like setcell(). So if its available > > please let me know. > > From your code sample, it appears that you're forgetting to use the > "val" delimiter required by the "setcell" method to identify where > the cell position ends and the value begins. If you're only using a > 1/2/3D matrix, you can use the setcell1d, setcell2d, setcell3d > utility methods which don't require the val delimiter. > > However, if you're going to set lots of values in your matrix, it's > definitely faster to access the matrix data directly. You could to > make a macro for matrix cell random access given t_jit_matrix_info > and a data pointer. Something like the following email client code > (might be typos) should get you going in the right direction > > #define CELL_PTR_1D (info,data,x) (((uchar *)(data))+(info)->dimstride > [0]*(x)) > #define CELL_PTR_2D (info,data,x,y) (CELL_PTR_1D(info,data,x)+(info)- > >dimstride[1]*(y)) > #define CELL_PTR_3D (info,data,x,y,z) (CELL_PTR_2D(info,data,x,y)+ > (info)->dimstride[2]*(z)) > > float *f; > > f = (float *) CELL_PTR_2D(info,data,x,y); > f[0] = 0.f; > f[1] = 1/2.f; > f[2] = 666.f; > > -Joshua >