void *olistenumerate_new(t_symbol *msg, short argc, t_atom *argv) { t_olistenumerate *x; if((x = (t_olistenumerate *)object_alloc(olistenumerate_class))){ x->address = NULL; if(argc){ if(atom_gettype(argv) == A_SYM){ t_symbol *s = atom_getsym(argv); if(s->s_name[0] != '/'){ object_error((t_object *)x, "address must begin with a slash"); return NULL; } x->address = s; }else{ object_error((t_object *)x, "argument must be an OSC address (symbol)"); return NULL; } x->outlets = osc_mem_alloc(2 * sizeof(void *)); x->outlets[0] = outlet_new((t_object*)x, NULL); x->outlets[1] = outlet_new((t_object*)x, NULL); critical_new(&(x->lock)); } else { object_error((t_object*)x, "o.listenumerate needs an OSC address as its first argument"); return NULL; } } return x; }
void *oudpsend_new(t_symbol *s, int argc, t_atom *argv) { t_oudpsend *x; x = (t_oudpsend *)object_alloc(oudpsend_class); if(!x){ return NULL; } x->outlet = outlet_new(&x->ob, NULL); x->x_fd = -1; x->icount = 0; x->istate = 0; critical_new(&(x->lock)); if(argc == 2 && atom_gettype(argv) == A_SYMBOL && atom_gettype(argv+1) == A_FLOAT) { t_symbol *ss = atom_getsym(argv); if (ss == gensym("localhost")) { ss = gensym("127.0.0.1"); } udpsend_connect(x, ss, atom_getfloat(argv+1)); } return x; }
void *ouniform_new(t_symbol *msg, short argc, t_atom *argv) { t_ouniform *x; if((x = (t_ouniform *)object_alloc(ouniform_class))){ x->address = NULL; if(argc){ if(atom_gettype(argv) == A_SYM){ t_symbol *s = atom_getsym(argv); if(s->s_name[0] != '/'){ object_error((t_object *)x, "address must begin with a slash"); return NULL; } x->address = s; }else{ object_error((t_object *)x, "argument must be an OSC address (symbol)"); return NULL; } } x->outlet = outlet_new((t_object *)x, NULL); x->seed = time(NULL); x->state = 0; srand(x->seed); critical_new(&(x->lock)); } return x; }
void *oudpreceive_new(t_symbol *s, int argc, t_atom *argv) { t_oudpreceive *x; x = (t_oudpreceive *)object_alloc(oudpreceive_class); if(!x) return NULL; int i, result = 0, portno = 0; x->x_addr_name[0] = '\0'; for (i = 0; i < 5; ++i) { x->x_addrbytes[i].a_type = A_FLOAT; x->x_addrbytes[i].a_w.w_float = 0; } #ifdef DEBUG post("udpreceive_new:argc is %d s is %s", argc, s->s_name); #endif for (i = 0; i < argc ;++i) { if (argv[i].a_type == A_FLOAT) { // float is taken to be a port number #ifdef DEBUG post ("argv[%d] is a float: %f", i, argv[i].a_w.w_float); #endif portno = (int)argv[i].a_w.w_float; } else if (argv[i].a_type == A_SYMBOL) { // symbol is taken to be an ip address (for multicast) #ifdef DEBUG post ("argv[%d] is a symbol: %s", i, argv[i].a_w.w_symbol->s_name); #endif atom_string(&argv[i], x->x_addr_name, 256); } } #ifdef DEBUG post("Setting port %d, address %s", portno, x->addr); #endif x->outlet = outlet_new(&x->ob, NULL); // << output received bundle x->x_addrout = outlet_new(&x->ob, &s_anything); x->x_connectsocket = -1; // no socket result = udpreceive_new_socket(x, x->x_addr_name, portno); // ------- from slip.decode --------- x->icount = 0; x->istate = 0; critical_new(&(x->lock)); return x; }
void *oO_new(t_symbol *msg, short argc, t_atom *argv) { t_oO *x = NULL; if((x = (t_oO *)object_alloc(oO_class))){ x->outlet = outlet_new((t_object *)x, "FullPacket"); critical_new(&(x->lock)); } return x; }
void *rd_new(t_symbol *msg, int argc, t_atom *argv){ t_rd *x; t_dictionary *d = NULL; long boxflags; // box setup if(!(d = object_dictionaryarg(argc, argv))){ return NULL; } boxflags = 0 | JBOX_DRAWFIRSTIN //| JBOX_NODRAWBOX | JBOX_DRAWINLAST //| JBOX_TRANSPARENT // | JBOX_NOGROW //| JBOX_GROWY | JBOX_GROWBOTH // | JBOX_HILITE | JBOX_BACKGROUND | JBOX_DRAWBACKGROUND // | JBOX_NOFLOATINSPECTOR // | JBOX_MOUSEDRAGDELTA // | JBOX_TEXTFIELD ; if((x = (t_rd *)object_alloc(rd_class))){ jbox_new((t_jbox *)x, boxflags, argc, argv); x->ob.b_firstin = (void *)x; x->outlet = outlet_new(x, NULL); critical_new(&(x->lock)); x->buffer_size = 1024 * 3; x->n = 0; x->buffer = (double *)calloc(x->buffer_size, sizeof(double)); x->num_partials_selected = 0; attr_dictionary_process(x, d); x->selection = (t_range){x->freqmin, x->freqmax}; jbox_ready((t_jbox *)x); return x; } return NULL; }
t_jit_pcl_freenect *jit_pcl_freenect_new(void) { t_jit_pcl_freenect *x = NULL; x = (t_jit_pcl_freenect*)jit_object_alloc(s_jit_pcl_freenect_class); if (x) { x->enable = 0; critical_new(&(x->lock)); x->kinect = NULL; x->rgb_frame = NULL; x->depth_frame = NULL; x->ir_frame = NULL; } return x; }
void *oudpsend_new(long arg) { t_oudpsend *x; x = (t_oudpsend *) object_alloc(oudpsend_class); if(!x){ return NULL; } x->outlet = outlet_new(x, NULL); x->icount = 0; x->istate = 0; critical_new(&(x->lock)); return x; }
void *polywave_new(t_symbol *s, long argc, t_atom *argv) { t_polywave *x = (t_polywave *)object_alloc(polywave_class); if(x) { x->buf_proxy = (t_buffer_proxy **)sysmem_newptr(POLYWAVE_MAX_BUFFERS * sizeof(t_buffer_proxy *)); critical_new(&x->lock); int n = POLYWAVE_MAX_BUFFERS; while (--n) { x->buf_proxy[n] = NULL; } x->dims = ONE_D; x->interp_type = LINEAR; x->backup = x->interp_type; x->numbufs = 0; t_dictionary *d = NULL; d = dictionary_new(); if (d) { attr_args_dictionary(d, argc, argv); attr_dictionary_process(x, d); //calls appropriate class_attr_accessors object_free(d); } int numlets = 0; switch (x->dims) { case ONE_D: numlets = 2; break; case TWO_D: numlets = 5; break; default: object_error((t_object *)x, "dimention attribute set to unknown value, cannont create inlets"); break; } dsp_setup((t_pxobject *)x, numlets); outlet_new((t_object *)x, "signal"); } return x; }
void *fton_new(t_symbol *s, long argc, t_atom *argv) { t_fton *x = NULL; t_dictionary *d = NULL; if(!(d = object_dictionaryarg(argc, argv))){ return NULL; } if (x = (t_fton *)object_alloc(fton_class)) { x->outlet = outlet_new((t_object *)x,NULL); } critical_new(&x->lock); attr_dictionary_process(x, d); return (x); }
void *match_new(t_symbol *s, short ac, t_atom *av) { t_match *x; x = object_alloc(match_class); x->m_out = outlet_new((t_object *)x,0); critical_new(&x->m_critical); if (ac) { x->m_want = (t_atom *)sysmem_newptr((long)ac * sizeof(t_atom)); match_setwant(x->m_want,ac,av); x->m_seen = (t_atom *)sysmem_newptr((long)ac * sizeof(t_atom)); x->m_size = ac; match_clear(x); } else { x->m_seen = 0; x->m_want = 0; x->m_size = 0; } return x; }
t_jit_realsense_grab *jit_realsense_grab_new(void) { t_jit_realsense_grab *x = NULL; x = (t_jit_realsense_grab*)jit_object_alloc(s_jit_realsense_grab_class); if (x) { x->gain = 0.0; critical_new(&x->lock); x->sm = PXCSenseManager::CreateInstance(); x->sm->EnableStream(PXCCapture::STREAM_TYPE_DEPTH, 640, 480, 60); x->sm->Init(); if (!x->sm) { wprintf_s(L"Unable to create the SenseManager\n"); return NULL; } } return x; }
void *ocoll_new(t_symbol *msg, short argc, t_atom *argv){ t_ocoll *x; if((x = (t_ocoll *)object_alloc(ocoll_class))){ x->outlet = outlet_new((t_object *)x, NULL); x->buffer_len = 1024; if(argc){ if(atom_gettype(argv) == A_LONG){ //x->buffer_len = atom_getlong(argv); object_error((t_object *)x, "o.collect no longer takes an argument to specify its internal buffer size."); object_error((t_object *)x, "The buffer will expand as necessary."); } } x->buffer = (char *)osc_mem_alloc(x->buffer_len * sizeof(char)); memset(x->buffer, '\0', x->buffer_len); x->buffer_pos = OSC_HEADER_SIZE; osc_bundle_s_setBundleID(x->buffer); critical_new(&(x->lock)); } return(x); }
void *oedge_new(t_symbol *msg, short argc, t_atom *argv) { t_oedge *x = NULL; if((x = (t_oedge *)object_alloc(oedge_class))){ dsp_setup((t_pxobject *)x, 1); x->outlet = outlet_new((t_object *)x, "FullPacket"); critical_new(&(x->lock)); x->ac = 0; x->av = NULL; x->lastx = 0; x->gettime = 0; x->time_onset = osc_message_u_alloc(); osc_message_u_setAddress(x->time_onset, "/zerotononzero/time"); x->block_sample_onset = osc_message_u_alloc(); osc_message_u_setAddress(x->block_sample_onset, "/zerotononzero/sample/withinblock"); x->global_sample_onset = osc_message_u_alloc(); osc_message_u_setAddress(x->global_sample_onset, "/zerotononzero/sample/sincedspstart"); x->value_onset = osc_message_u_alloc(); osc_message_u_setAddress(x->value_onset, "/zerotononzero/value"); x->time_zero = osc_message_u_alloc(); osc_message_u_setAddress(x->time_zero, "/nonzerotozero/time"); x->block_sample_zero = osc_message_u_alloc(); osc_message_u_setAddress(x->block_sample_zero, "/nonzerotozero/sample/withinblock"); x->global_sample_zero = osc_message_u_alloc(); osc_message_u_setAddress(x->global_sample_zero, "/nonzerotozero/sample/sincedspstart"); x->bundle = osc_bundle_u_alloc(); osc_bundle_u_addMsg(x->bundle, x->time_onset); osc_bundle_u_addMsg(x->bundle, x->block_sample_onset); osc_bundle_u_addMsg(x->bundle, x->global_sample_onset); osc_bundle_u_addMsg(x->bundle, x->value_onset); osc_bundle_u_addMsg(x->bundle, x->time_zero); osc_bundle_u_addMsg(x->bundle, x->block_sample_zero); osc_bundle_u_addMsg(x->bundle, x->global_sample_zero); } return x; }
void *jsusfx_new(t_symbol *notused, long argc, t_atom *argv) { if ( argc < 1 || atom_gettype(argv) != A_SYM ) { error("jsusfx~: missing script name"); return NULL; } t_jsusfx *x = reinterpret_cast<t_jsusfx *>(object_alloc(jsusfx_class)); t_symbol *s = atom_getsym(argv); t_fourcc filetype = 'TEXT', outtype; short path; char filename[MAX_PATH_CHARS]; strcpy(filename, s->s_name); if (locatefile_extended(filename, &path, &outtype, &filetype, 1)) { t_object *mypatcher; object_obex_lookup(x, gensym("#P"), &mypatcher); t_symbol *checkExists = object_attr_getsym(mypatcher, gensym("filepath")); if ( checkExists->s_name[0] == 0 ) { error("jsusfx~: patch needs to be saved in order to create new jsusfx script file"); return NULL; } path = path_getdefault(); t_fourcc type = 'TEXT'; t_filehandle ref; if ( path_createsysfile(filename, path, type, &ref) ) { error("jsusfx~: unable to create file"); return NULL; } char initText[] = "@sample\nspl0=1\nspl1=-1\n"; t_handle h = sysmem_newhandle(0); sysmem_ptrandhand(initText,h,strlen(initText)); if ( sysfile_writetextfile(ref, h, TEXT_LB_NATIVE) ) { error("jsusfx~: unable to write file"); return NULL; } sysfile_close(ref); sysmem_freehandle(h); } strcpy(x->scriptname, filename); x->path = path; char fullpath[MAX_PATH_CHARS]; path_toabsolutesystempath(path, filename, fullpath); std::ifstream is(fullpath); if ( ! is.is_open() ) { error("jsusfx~: error opening file %s", fullpath); return NULL; } x->bypass = false; dsp_setup((t_pxobject *)x, 2); x->outlet1 = outlet_new((t_object *)x, NULL); outlet_new((t_object *)x, "signal"); outlet_new((t_object *)x, "signal"); critical_new(&(x->critical)); x->m_editor = NULL; JsusFxMax *fx = new JsusFxMax(); fx->compile(is); x->fx = fx; /*if ( argc >= 2 && atom_gettype(argv+1) == A_LONG ) { x->fx->normalizeSliders = atom_getlong(argv+1); } else { x->fx->normalizeSliders = 1; } post("normalizer sl %x", x->fx->normalizeSliders);*/ return (x); }
void *odisplay_new(t_symbol *msg, short argc, t_atom *argv){ t_odisplay *x; t_dictionary *d = NULL; long boxflags; // box setup if(!(d = object_dictionaryarg(argc, argv))){ return NULL; } boxflags = 0 | JBOX_DRAWFIRSTIN | JBOX_NODRAWBOX | JBOX_DRAWINLAST | JBOX_TRANSPARENT //| JBOX_NOGROW //| JBOX_GROWY //| JBOX_GROWBOTH //| JBOX_HILITE //| JBOX_BACKGROUND //| JBOX_DRAWBACKGROUND //| JBOX_NOFLOATINSPECTOR //| JBOX_MOUSEDRAGDELTA | JBOX_TEXTFIELD ; if((x = (t_odisplay *)object_alloc(odisplay_class))){ jbox_new((t_jbox *)x, boxflags, argc, argv); x->ob.b_firstin = (void *)x; x->outlet = outlet_new(x, NULL); //x->proxy = proxy_new(x, 1, &(x->inlet)); x->bndl_u = NULL; x->bndl_s = NULL; x->newbndl = 0; x->textlen = 0; x->text = NULL; //x->bndl_has_been_checked_for_subs = 0; //x->bndl_has_subs = 0; critical_new(&(x->lock)); x->qelem = qelem_new((t_object *)x, (method)odisplay_refresh); x->new_data_indicator_clock = clock_new((t_object *)x, (method)odisplay_refresh); x->have_new_data = 1; x->draw_new_data_indicator = 0; attr_dictionary_process(x, d); t_object *textfield = jbox_get_textfield((t_object *)x); if(textfield){ object_attr_setchar(textfield, gensym("editwhenunlocked"), 0); textfield_set_readonly(textfield, '1'); textfield_set_selectallonedit(textfield, '1'); textfield_set_textmargins(textfield, 5, 5, 5, 15); textfield_set_textcolor(textfield, &(x->text_color)); } jbox_ready((t_jbox *)x); //odisplay_gettext(x); odisplay_clear(x); return x; } return NULL; }
void *odisplay_new(t_symbol *msg, short argc, t_atom *argv) { t_odisplay *x = (t_odisplay *)pd_new(odisplay_class); if(x) { t_opd_textbox *t = opd_textbox_new(odisplay_textbox_class); t->glist = (t_glist *)canvas_getcurrent();; t->in_new_flag = 1; t->firsttime = 1; t->parent = (t_object *)x; t->draw_fn = (t_gotfn)odisplay_drawElements; t->gettext_fn = (t_gotfn)odisplay_gettext; t->click_fn = (t_gotfn)odisplay_click; t->delete_fn = (t_gotfn)odisplay_delete; t->mouseDown = 0; t->selected = 0; t->editmode = glist_getcanvas(t->glist)->gl_edit; t->textediting = 0; t->margin_t = 1; t->margin_l = 1; t->margin_b = 10; t->margin_r = 1; x->roundpix = 3; t->resizebox_x_offset = 5; t->resizebox_y_offset = 5; t->resizebox_height = 10; t->resizebox_width = 10; x->textbox = t; x->frame_color = (t_opd_rgb *)malloc( sizeof(t_opd_rgb) ); x->background_color = (t_opd_rgb *)malloc( sizeof(t_opd_rgb) ); x->flash_color = (t_opd_rgb *)malloc( sizeof(t_opd_rgb) ); x->text_color = (t_opd_rgb *)malloc( sizeof(t_opd_rgb) ); opd_textbox_fsetRGB(x->frame_color, .216, .435, .7137); opd_textbox_fsetRGB(x->background_color, .884, .884, .884); opd_textbox_fsetRGB(x->flash_color, .761, .349, .306); opd_textbox_setRGB(x->text_color, 0, 0, 0); // post("%s %p glist %x canvas %x\n", __func__, x, t->glist, glist_getcanvas(t->glist)); x->outlet = outlet_new(&x->ob, NULL); x->bndl_u = NULL; x->bndl_s = NULL; x->newbndl = 0; x->textlen = 0; critical_new(&(x->lock)); x->m_clock = clock_new(x, (t_method)odisplay_tick); x->new_data_indicator_clock = clock_new(x, (t_method)odisplay_refresh); x->have_new_data = 1; x->draw_new_data_indicator = 0; x->tk_tag = NULL; //object name heirarchy: char buf[MAXPDSTRING]; sprintf(buf, "%lxBORDER", (long unsigned int)x); x->tk_tag = (char *)malloc(sizeof(char) * (strlen(buf)+1)); if(x->tk_tag == NULL) { printf("out of memory %d\n", __LINE__); return NULL; } strcpy(x->tk_tag, buf); opd_textbox_processArgs(t, argc, argv); t->in_new_flag = 0; t->softlock = 0; } return (void *)x; }