void track_proxy_save(t_gobj *z, t_binbuf *b) { t_track_proxy *x = (t_track_proxy*)z; Track *t = x->track; Song *s = t->getSong(); binbuf_addv(b, "ssiisss;", gensym("#X"), gensym("obj"), (t_int)x->x_obj.te_xpix, (t_int)x->x_obj.te_ypix, gensym("track"), gensym(s->getName().c_str()), gensym(t->getName().c_str())); // save paterns for(Track::pattern_iterator i = t->pattern_begin(); i != t->pattern_end(); i++) { Pattern *pattern = i->second; binbuf_addv(b, "ss", gensym(TRACK_SELECTOR), gensym("data")); t_int r = pattern->getRows(); t_int c = pattern->getColumns(); binbuf_addv(b, "sii", gensym(pattern->getName().c_str()), r, c); t_atom tmp; for(unsigned int j = 0; j < r; j++) { for(unsigned int k = 0; k < c; k++) { tmp = pattern->getCell(j, k); switch(tmp.a_type) { case A_SYMBOL: binbuf_addv(b, "s", tmp.a_w.w_symbol); break; case A_FLOAT: binbuf_addv(b, "f", tmp.a_w.w_float); break; default: binbuf_addv(b, "s", gensym("?")); break; } } } binbuf_addv(b, ";"); } // save metadata for(Track::meta_iterator i = t->meta_begin(); i != t->meta_end(); i++) { binbuf_addv(b, "ssssss;", gensym(TRACK_SELECTOR), gensym("meta"), gensym("track"), gensym("set"), gensym(i->first.c_str()), gensym(i->second.c_str())); } binbuf_addv(b, "sss;", gensym(TRACK_SELECTOR), gensym("data"), gensym("end")); }
int track_proxy_getpatterns(t_track_proxy *x) { SETSYMBOL(&result_argv[0], gensym("patternnames")); result_argc = 1; Track *t = x->track; for(Track::pattern_iterator i = t->pattern_begin(); i != t->pattern_end(); i++) { if(result_argc >= MAX_RESULT_SIZE) { pd_error(x, "getpatternnames: result too long"); return -2; } Pattern *pattern = i->second; SETSYMBOL(&result_argv[result_argc], gensym(pattern->getName().c_str())); result_argc++; } return 0; }