int track_proxy_setrow(t_track_proxy *x, t_symbol *sel, int argc, t_atom *argv) { result_argc = 0; if(argc < 2 || !IS_A_SYMBOL(argv,0) || !IS_A_FLOAT(argv,1)) { pd_error(x, "setrow: usage: setrow <pattern> <row#> <atom0> <atom1> ..."); return -1; } t_symbol *pat = argv[0].a_w.w_symbol; Pattern *pattern = x->track->getPattern(pat->s_name); t_int r = (t_int) argv[1].a_w.w_float; if(!pattern) { pd_error(x, "setrow: no such pattern: %s", pat->s_name); return -2; } unsigned int argc2 = argc - 2; if(argc2 != pattern->getColumns()) { pd_error(x, "setrow: input error: must provide exactly %d elements for a row", pattern->getColumns()); return -3; } for(unsigned int i = 0; i < argc2; i++) { pattern->setCell(r, i, argv[i + 2]); } return 0; }
int track_proxy_setcell(t_track_proxy *x, t_symbol *sel, int argc, t_atom *argv) { result_argc = 0; if(argc != 4 || !IS_A_SYMBOL(argv,0) || !IS_A_FLOAT(argv,1) || !IS_A_FLOAT(argv,2)) { pd_error(x, "setrow: usage: setcell <pattern> <row#> <col#> <atom>"); return -1; } t_symbol *pat = argv[0].a_w.w_symbol; Pattern *pattern = x->track->getPattern(pat->s_name); t_int r = (t_int) argv[1].a_w.w_float; t_int c = (t_int) argv[2].a_w.w_float; if(!pattern) { pd_error(x, "setcell: no such pattern: %s", pat->s_name); return -2; } pattern->setCell(r, c, argv[3]); return 0; }
void track_proxy_data(t_track_proxy *x, t_symbol *s, int argc, t_atom *argv) { if(argc == 1 && IS_A_SYMBOL(argv,0) && argv[0].a_w.w_symbol == gensym("end")) { pd_unbind(&x->x_obj.ob_pd, gensym(TRACK_SELECTOR)); return; } if(argc < 3 || !IS_A_SYMBOL(argv,0) || !IS_A_FLOAT(argv,1) || !IS_A_FLOAT(argv,2)) { pd_error(x, "unrecognized format for in-patch data"); return; } t_symbol *pat = argv[0].a_w.w_symbol; t_int rows = (t_int) argv[1].a_w.w_float; t_int cols = (t_int) argv[2].a_w.w_float; if(argc != (3 + rows * cols)) { pd_error(x, "unrecognized format for in-patch data (malformed data?)"); return; } Track *t = x->track; t->addPattern(rows, cols, pat->s_name); Pattern *p = t->getPattern(pat->s_name); if(!p) { pd_error(x, "fatal error: cannot create patern"); return; } int a = 3; for(int r = 0; r < rows; r++) { for(int c = 0; c < cols; c++) { p->setCell(r, c, argv[a]); a++; } } }