Created
September 20, 2020 10:49
-
-
Save esnho/c6a86d82e8f18a812c9edef4448a529c to your computer and use it in GitHub Desktop.
jitter set array to matrix issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// init some variables | |
t_jit_matrix_info out2_minfo; | |
char* out2_bp; | |
jit_object_method(out2_matrix, _jit_sym_getinfo, &out2_minfo); | |
jit_object_method(out2_matrix, _jit_sym_getdata, &out2_bp); | |
// the array | |
long total = 30; | |
long* array = new long[total * 3]; | |
// set mock data | |
long longCounter = 0; | |
for (longCounter = 0; longCounter < total * 3; longCounter++) { | |
array[longCounter] = longCounter; | |
} | |
// change matrix info | |
out2_minfo.dim[1] = 1; | |
out2_minfo.dim[0] = total; | |
out2_minfo.type = _jit_sym_long; | |
out2_minfo.planecount = 3; | |
// set matrix info, set array to matrix, retreive data from matrix | |
jit_object_method(out2_matrix, _jit_sym_setinfo_ex, &out2_minfo); | |
jit_object_method(out2_matrix, _jit_sym_data, array); | |
jit_object_method(out2_matrix, _jit_sym_getdata, &out2_bp); | |
// print matrix data to console | |
char *ip; | |
long i, j; | |
for (i=0; i < out2_minfo.dim[1]; i++) { | |
ip = out2_bp + i * out2_minfo.dimstride[1]; | |
for (j=0; j < out2_minfo.dim[0]; j++) { | |
// you are now retrieving values for cell j i | |
long plane0val = (*ip++); | |
long plane1val = (*ip++); | |
long plane2val = (*ip++); | |
c74::max::object_post(in_matrix, "matrix val [%d, %d]: %d %d %d", j, i, plane0val, plane1val, plane2val); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
as suggested int the forum updating the code to this make it works
https://cycling74.com/forums/how-to-set-an-array-of-long-to-jitter-matrix-properly/replies/1#reply-5f68ffd91ae2675932cd7e84