how can i import an array instead of lists?


    Apr 09 2013 | 1:04 pm
    Hello again :)
    After a lot of searching, i achieved to pass an amount of lists and put them to an array in programm.
    Now i would like to know how to pass an array directly,without passing the lists of atoms..
    Any idea?
    #include "ext.h"
    #include "ext_obex.h"
    typedef struct _fingertips {
    t_object p_ob;
    Atom f_value;
    void *f_outlet;
    } t_fingertips;
    short image[1000][1000];
    short perimeter[1000];
    long points[5][2];
    long imageWidth;
    long imageHeight;
    void fingertips_bang(t_fingertips *x);
    void fingertips_list(t_fingertips *x, t_symbol *s, short argc, t_atom*argv);
    void fingertips_perimeter(t_fingertips *x);
    void fingertips_points(t_fingertips *x);
    void fingertips_clear(t_fingertips *x);
    void *fingertips_new();
    t_class *fingertips_class;
    int main(void) {
    t_class *c;
    c = class_new("fingertips", (method) fingertips_new, (method) NULL,
    sizeof(t_fingertips), 0L, A_GIMME, 0);
    class_addmethod(c, (method) fingertips_bang, "bang", 0);
    class_addmethod(c, (method) fingertips_list, "list", A_GIMME, 0);
    class_addmethod(c, (method) fingertips_clear, "clear", 0);
    class_register(CLASS_BOX, c);
    fingertips_class = c;
    post("fingertips object loaded...", 0);
    return 0;
    }
    void *fingertips_new() {
    long i, j;
    t_fingertips *x;
    x = (t_fingertips *) object_alloc(fingertips_class);
    x->f_outlet = intout(x);
    for (i = 0; i < 1000; i++) {
    perimeter[i] = 0;
    for (j = 0; j < 1000; j++) {
    if (i == 0)
    image[i][j] = 1;
    else
    image[i][j] = 0;
    }
    }
    for (i = 0; i < 5; i++) {
    points[i][0] = 0;
    points[i][1] = 0;
    }
    imageHeight = 0;
    imageWidth = 0;
    post(" new fingertips object instance added to patch...", 0);
    return (x);
    }
    void fingertips_bang(t_fingertips *x) {
    Atom argv[15];
    atom_setlong(argv, points[0][0]);
    atom_setsym(argv + 1, gensym(","));
    atom_setlong(argv + 2, points[0][1]);
    atom_setlong(argv + 3, points[1][0]);
    atom_setsym(argv + 4, gensym(","));
    atom_setlong(argv + 5, points[1][1]);
    atom_setlong(argv + 6, points[2][0]);
    atom_setsym(argv + 7, gensym(","));
    atom_setlong(argv + 8, points[2][1]);
    atom_setlong(argv + 9, points[3][0]);
    atom_setsym(argv + 10, gensym(","));
    atom_setlong(argv + 11, points[3][1]);
    atom_setlong(argv + 12, points[4][0]);
    atom_setsym(argv + 13, gensym(","));
    atom_setlong(argv + 14, points[4][1]);
    outlet_anything(x->f_outlet, gensym("list"), 15, argv);
    }
    void fingertips_list(t_fingertips *x, t_symbol *s, short ac, t_atom*av) {
    if (s->s_name == "clear") {
    fingertips_bang(x);
    } else {
    if (ac == 3) {
    image[av[1].a_w.w_long][av[0].a_w.w_long] = av[2].a_w.w_long;
    if (imageWidth < av[0].a_w.w_long + 1)
    imageWidth = av[0].a_w.w_long + 1;
    if (imageHeight < av[1].a_w.w_long + 1)
    imageHeight = av[1].a_w.w_long + 1;
    }
    fingertips_perimeter(x);
    }
    }
    void fingertips_clear(t_fingertips *x) {
    fingertips_bang(fingertips_new());
    }
    void fingertips_perimeter(t_fingertips *x) {
    long i, j;
    for (i = 0; i < imageWidth; i++) {
    for (j = 0; j < imageHeight; j++) {
    if (image[j][i] != 0)
    perimeter[i] = j;
    }
    }
    fingertips_points(x);
    }
    void fingertips_points(t_fingertips *x) {
    long i, j = -1, stop = 0, sum = 1, tempSum = 0;
    for (i = 1; i < imageWidth; i++) {
    if (perimeter[i] < perimeter[i - 1] && stop == 0) {
    j++;
    points[j][0] = i - 1;
    points[j][1] = perimeter[i - 1];
    stop = -1;
    if (sum % 2 != 0)
    tempSum = (sum + 1) / 2;
    else
    tempSum = sum / 2;
    points[j][0] = (i - 1) - tempSum;
    points[j][1] = perimeter[i - 1];
    sum = 0;
    tempSum = 0;
    } else if (perimeter[i] > perimeter[i - 1] && stop == -1) {
    stop = 0;
    }
    if (perimeter[i] == perimeter[i - 1]) {
    sum++;
    } else {
    sum = 0;
    }
    fingertips_bang(x);
    }
    }

    • Apr 09 2013 | 3:21 pm
      There are a few things that are very bad in your code ;-)
      #1 you should declare this in your object structure otherwise those variable are shared by all the instances in your patch:
      short image[1000][1000];
      short perimeter[1000];
      long points[5][2];
      long imageWidth;
      long imageHeight;
      #2 your're calling outlet_anything on an inlet declared with intout
      #3 the signature of your fingertips_new is wrong, as you declared the object as an A_GIMME (in your class_new call). It should be something like
      void *fingertips_new(t_symbol *s, long argc, t_atom *argv)
    • Apr 09 2013 | 3:37 pm
      I undersatnt that thare are some errors but my main concern is how to pass a matrix directly without passing lists of atoms...
      This would be quite useful :)
    • Apr 09 2013 | 11:09 pm
      The problem with the provided code is that i dont know what i have to put in my first struct and the main functions in the start and i believe that these parts are standards...
      But now i think that your answer will be useful from here and on :)
    • Apr 10 2013 | 12:51 pm
      Hi i tryed your code but i get this error undefined reference to `__imp___jit_sym_class_jit_matrix'
    • Apr 10 2013 | 2:29 pm
      1. I did include "jit-includes".
      2. I dont understand what you mean by: ( Do not forget to link against the "JitterAPI.framework").
      3. I use MaxSDK-6.0.4.
      4. I pasted the code in flopMatrix.c into my code
    • Apr 10 2013 | 4:04 pm
      I changed my SDK to SDK 5.1.7
      but i still get errors
    • Apr 11 2013 | 9:37 am
      Hello again ;)
      After trying hard i cannot resolve these spesific errors :( Any idea?? I really need help...
      Description Resource Path Location
      Symbol 'mode' could not be resolved max.jit.iter.c /My_Proj2 line 47
      Symbol 'JIT_ATTR_SET_USURP_LOW' could not be resolved max.jit.iter.c /My_Proj2 line 44
      Symbol 'JIT_ATTR_GET_DEFER_LOW' could not be resolved max.jit.iter.c /My_Proj2 line 44
      Symbol 'obex' could not be resolved max.jit.iter.c /My_Proj2 line 39
      Symbol 'JIT_MATRIX_MAX_DIMCOUNT' could not be resolved max.jit.iter.c /My_Proj2 line 70
      Symbol 'A_CANT' could not be resolved max.jit.iter.c /My_Proj2 line 56
      Symbol 'JIT_MATRIX_MAX_PLANECOUNT' could not be resolved max.jit.iter.c /My_Proj2 line 109
      Symbol 'A_GIMME' could not be resolved max.jit.iter.c /My_Proj2 line 42
      Symbol 'A_GIMME' could not be resolved max.jit.iter.c /My_Proj2 line 37
      Symbol 'JIT_MATRIX_MAX_DIMCOUNT' could not be resolved max.jit.iter.c /My_Proj2 line 66
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_char'
      undefined reference to `__imp___jit_sym_err_calculate'
      undefined reference to `__imp___jit_sym_lock'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_long'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_lock'
      undefined reference to `__imp___jit_sym_class_jit_matrix'
      undefined reference to `__imp___jit_sym_symbol'
      undefined reference to `__imp___jit_sym_symbol'
      undefined reference to `__imp___jit_sym_lock'
      undefined reference to `__imp___jit_sym_err_calculate'
      undefined reference to `__imp___jit_sym_getdata'
      undefined reference to `__imp___jit_sym_getinfo'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_long'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_float64'
      undefined reference to `__imp___jit_sym_float32'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_float64'
      undefined reference to `__imp___jit_sym_float32'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_char'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_list'
      undefined reference to `__imp___jit_sym_char'
      undefined reference to `__imp___jit_sym_jit_attr_offset'
      undefined reference to `__imp___jit_sym_symbol'
      undefined reference to `__imp___jit_sym_symbol'
      undefined reference to `__imp___jit_sym_long'
    • Apr 11 2013 | 10:47 am
      I wanna add that i m working with eclipse and not with XCode :)
    • Apr 11 2013 | 3:03 pm
      the mistakes have decrased the main problem is not your code but libraries...
      I think that the problem is the linker and that i dont know how to use XCode...
      I would like to say that you have been very helpful and thank you a lot for your interest...
      I m tottaly new in max development and cannot find information easily :(