can't get valid mop outmatrix data pointer

Feb 24, 2008 at 2:26am

can't get valid mop outmatrix data pointer

hello,

i’m struggling with a problem concerning the data pointer of a mop
outmatrix.

i’ve set up everything according to a template project from the SDK.
the ouput matrix has to have a different type and planecount from the
input matrix.

i’m unsure whether if have to set any more flags of mop to produce a
correct output matrix.

i was also wondering if it was really necessary to use a mop, since
i’m doing fairly complex calulations on the input matrix data, and
output only a few results in the outmatrix. how would i use normal
matrix calls instead?

any help is greatly appreciated

/*j

below is part of my code:
after setting the * out_bp, the debugger tells me that it points to
0×0…

t_jit_err jit_myobject_init(void)
{
long attrflags=0;
t_jit_object *attr;
t_jit_object *mop, *o;

_jit_myobject_class = jit_class_new(“jit_myobject”,
(method)jit_myobject_new,(method)jit_myobject_free,
sizeof(t_jit_myobject),0L);

//add mop
mop = jit_object_new(_jit_sym_jit_mop, 1, 1); //#inputs, #outputs
o = jit_object_method(mop,_jit_sym_getoutput,1);
jit_attr_setlong(o,_jit_sym_planelink,0);
jit_class_addadornment(_jit_myobject_class, mop);

//add methods
jit_class_addmethod(_jit_myobject_class,
(method)jit_myobject_matrix_calc, “matrix_calc”, A_CANT, 0L);

//add attributes
attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;
jit_class_register(_jit_myobject_class);

return JIT_ERR_NONE;
}

t_jit_err jit_myobject_matrix_calc(t_jit_myobject *x, void *inputs,
void *outputs)
{
t_jit_err err = JIT_ERR_NONE;
long in_savelock, out_savelock;
t_jit_matrix_info in_minfo, out_minfo;
char *in_bp;
long *out_bp;
char *ip;
long *op;

void *in_matrix;
void *out_matrix;

in_matrix = jit_object_method(inputs, _jit_sym_getindex, 0);
out_matrix = jit_object_method(outputs, _jit_sym_getindex, 0);

if (x && in_matrix && out_matrix) {

in_savelock = (long)jit_object_method(in_matrix, _jit_sym_lock, 1);
out_savelock = (long)jit_object_method(out_matrix, _jit_sym_lock, 1);

jit_object_method(in_matrix,_jit_sym_getinfo, &in_minfo);
jit_object_method(out_matrix,_jit_sym_getinfo, &out_minfo);

jit_matrix_info_default(&out_minfo);
out_minfo.size = 2048 * 4;
out_minfo.type = _jit_sym_long;

if(in_minfo.type == _jit_sym_char && in_minfo.planecount == 1 &&
in_minfo.dimcount == 2) {

jit_object_method(in_matrix,_jit_sym_getdata, &in_bp);
jit_object_method(out_matrix,_jit_sym_getdata, &out_bp);

#36016
Feb 24, 2008 at 11:33am

Hi Jash,

I’ve always defined the outputmatrix in the max wrapper, like with the
rgb2luma example. Don’t know if its mandatory. I only have every limited
experience with MOP, but it worked for me.

if (o=jit_object_new(gensym(“jit_rgb2luma”))) {
max_jit_mop_setup_simple(x,o,argc,argv);
//1-plane char out
m = max_jit_mop_getoutput(x,1);
jit_object_method(m,_jit_sym_getinfo,&info);
info.type = _jit_sym_char;
info.planecount = 1;
info.dimcount = 2;
jit_object_method(m,_jit_sym_setinfo,&info);

Make sure you use the setinfo after you changed the matrix info struct. The
info object is a separate thing, so if you change it, the matrix you got it
from is not changed at all.

I did 2 externals where I was in a similar situation and dropped MOP because
I only needed a matrix as input. Look at the jit.gl.videoplane example. You
can simply add a method that listens to the jit_matrix message and take it
from there.

If you want to post lists and messages back to the patcher through the
dumpoutlet you best use the notify mechanism. A jitter object shouldn’t be
aware of any physical outlets. For this you can have a look at jit.notify. I
think its missing from the windows sdk, but you can find it in the mac
1.6sdk download.

Hope this helps.

Thijs

On Sun, Feb 24, 2008 at 2:26 AM, jasch wrote:

> hello,
>
> i’m struggling with a problem concerning the data pointer of a mop
> outmatrix.
>
> i’ve set up everything according to a template project from the SDK.
> the ouput matrix has to have a different type and planecount from the
> input matrix.
>
> i’m unsure whether if have to set any more flags of mop to produce a
> correct output matrix.
>
> i was also wondering if it was really necessary to use a mop, since
> i’m doing fairly complex calulations on the input matrix data, and
> output only a few results in the outmatrix. how would i use normal
> matrix calls instead?
>
> any help is greatly appreciated
>
> /*j
>
> below is part of my code:
> after setting the * out_bp, the debugger tells me that it points to
> 0×0…
>
> t_jit_err jit_myobject_init(void)
> {
> long attrflags=0;
> t_jit_object *attr;
> t_jit_object *mop, *o;
>
> _jit_myobject_class = jit_class_new(“jit_myobject”,
> (method)jit_myobject_new,(method)jit_myobject_free,
> sizeof(t_jit_myobject),0L);
>
> //add mop
> mop = jit_object_new(_jit_sym_jit_mop, 1, 1); //#inputs, #outputs
> o = jit_object_method(mop,_jit_sym_getoutput,1);
> jit_attr_setlong(o,_jit_sym_planelink,0);
> jit_class_addadornment(_jit_myobject_class, mop);
>
> //add methods
> jit_class_addmethod(_jit_myobject_class,
> (method)jit_myobject_matrix_calc, “matrix_calc”, A_CANT, 0L);
>
> //add attributes
> attrflags = JIT_ATTR_GET_DEFER_LOW | JIT_ATTR_SET_USURP_LOW;
> jit_class_register(_jit_myobject_class);
>
> return JIT_ERR_NONE;
> }
>
> t_jit_err jit_myobject_matrix_calc(t_jit_myobject *x, void *inputs,
> void *outputs)
> {
> t_jit_err err = JIT_ERR_NONE;
> long in_savelock, out_savelock;
> t_jit_matrix_info in_minfo, out_minfo;
> char *in_bp;
> long *out_bp;
> char *ip;
> long *op;
>
> void *in_matrix;
> void *out_matrix;
>
> in_matrix = jit_object_method(inputs, _jit_sym_getindex, 0);
> out_matrix = jit_object_method(outputs, _jit_sym_getindex, 0);
>
> if (x && in_matrix && out_matrix) {
>
> in_savelock = (long)jit_object_method(in_matrix,
> _jit_sym_lock, 1);
> out_savelock = (long)jit_object_method(out_matrix,
> _jit_sym_lock, 1);
>
> jit_object_method(in_matrix,_jit_sym_getinfo, &in_minfo);
> jit_object_method(out_matrix,_jit_sym_getinfo, &out_minfo);
>
> jit_matrix_info_default(&out_minfo);
> out_minfo.size = 2048 * 4;
> out_minfo.type = _jit_sym_long;
>
> if(in_minfo.type == _jit_sym_char && in_minfo.planecount ==
> 1 &&
> in_minfo.dimcount == 2) {
>
> jit_object_method(in_matrix,_jit_sym_getdata,
> &in_bp);
> jit_object_method(out_matrix,_jit_sym_getdata,
> &out_bp);
>

#123339
Feb 24, 2008 at 11:38am

On Sun, Feb 24, 2008 at 11:33 AM, Thijs Koerselman <
thijskoerselman@gmail.com> wrote:

> Hi Jash,
>
>
Your name appears in my max window on a regular basis, and I still manage to
misspell it :-/ Sorry about that.

Thijs

#123340
Feb 24, 2008 at 1:35pm

thanks thijs,

you set me on the right track. indeed, setting up the mop the same way
as the jit.rgb2luma object did the trick!
not that i fully understand what’s going on, but now at least i have a
valid outmatrix, data-pointer and a functioning external!

> Your name appears in my max window on a regular basis, and I still
> manage to misspell it :-/ Sorry about that.

no problem, yours seems is even harder to spell, let alone pronounce ;)

thanks again

/*j

#123341
Feb 24, 2008 at 9:40pm

Moving this thread to jitter-dev.

#123342

You must be logged in to reply to this topic.