How to set an array of long to jitter matrix properly?
Hello,
I'm trying to set an array of long to a jitter matrix but looks like the values have a weird offset.
I've wrote a gist with a snippet of code that can reproduce the isse.
It basically fills the matrix with a counter value.
https://gist.github.com/esnho/c6a86d82e8f18a812c9edef4448a529c
And attached below you can see the difference between reading the matrix from a Max object and printing the values directly from C, what's going on?
Any help would be very appreciated.
i believe you need to set 2 flags in the matrix info struct in order to successfully execute your code
info.flags = JIT_MATRIX_DATA_REFERENCE | JIT_MATRIX_DATA_PACK_TIGHT;
since your creating as data-reference, you also need to explicitly set the matrix size:
info.size = info.dim[0] * info.planecount * SIZE_INT32;
the other tricky bit is long as your data array type is not correct on all platforms. long data type in jitter is actually implemented as int (actually t_int32). and not on all platforms is sizeof(long) == sizeof(int).
so you should create an int array instead of long, and pass that to the matrix data call.
give that a try and let us know if that works.
That's works well, I've commented the gist to reflect the changes.
It also works well using float as type.
Many thanks!