void split_path_symbol(t_split_path *x, t_symbol *s) { int length = strlen(s->s_name); char path_buffer[MAXPATHLEN] = ""; while (length--) if (*(s->s_name + length) == '/') break; if (length < MAXPATHLEN) outlet_symbol(x->x_filename_outlet,gensym(s->s_name + length + 1)); else error("[split_path] filename name too long. The limit is %d characters",MAXPATHLEN); while (length > 0) { length--; if(*(s->s_name + length) != '/') break; } if (length < MAXPATHLEN) { strncpy(path_buffer, s->s_name, length + 1); outlet_symbol(x->x_path_outlet,gensym(path_buffer)); } else { error("[split_path] path name too long. The limit is %d characters",MAXPATHLEN); } }
static void ossmixer_get_source(t_ossmixer *x) { int fd = -1; int channel = -1; fd = open(x->device->s_name, O_WRONLY); if (fd > 0){ if ( ioctl(fd, SOUND_MIXER_READ_RECSRC, &channel) ){ post ("ossmixer: could not get recording source"); }else{ t_symbol* s_ch = gensym("no_source_found"); if (channel & SOUND_MASK_VOLUME) s_ch = gensym("main"); if (channel & SOUND_MASK_PCM) s_ch = gensym("pcm"); if (channel & SOUND_MASK_MIC) s_ch = gensym("mic"); if (channel & SOUND_MASK_CD) s_ch = gensym("cd"); if (channel & SOUND_MASK_SYNTH) s_ch = gensym("synth"); if (channel & SOUND_MASK_LINE) s_ch = gensym("line"); if (channel & SOUND_MASK_LINE1) s_ch = gensym("line1"); if (channel & SOUND_MASK_LINE2) s_ch = gensym("line2"); if (channel & SOUND_MASK_LINE3) s_ch = gensym("line3"); if (channel & SOUND_MASK_ALTPCM) s_ch = gensym("altpcm"); outlet_symbol (x->x_out1,s_ch); outlet_symbol (x->x_obj.ob_outlet,gensym("source")); } close (fd); }else{ post ("ossmixer: could not open mixer device"); } }
static void stripfilename_symbol(t_stripfilename *x, t_symbol *s) { if(x->x_nr_char < 0)/* cuts the string from the back */ { int len = strlen(s->s_name); int i=len + x->x_nr_char; if(len > (MAXPDSTRING - 2)) strncpy(x->x_mem, s->s_name, MAXPDSTRING - 2 - len); else strcpy(x->x_mem, s->s_name); if(i < 0) i = 0; x->x_mem[i] = 0; outlet_symbol(x->x_obj.ob_outlet, gensym(x->x_mem)); } else if(x->x_nr_char > 0)/* starts the string at this new offset */ { int len = strlen(s->s_name); int i=x->x_nr_char; if(len > (MAXPDSTRING - 2)) strncpy(x->x_mem, s->s_name, MAXPDSTRING - 2 - len); else strcpy(x->x_mem, s->s_name); if(i > len) i = len; outlet_symbol(x->x_obj.ob_outlet, gensym(x->x_mem+i)); } else outlet_symbol(x->x_obj.ob_outlet, s); }
static void trigger2_list(t_trigger2 *x, t_symbol *s, int argc, t_atom *argv){ t_trigger2out *u; int i; for(i = x->x_n, u = x->x_vec + i; u--, i--;){ if (u->u_type == TR_FLOAT) outlet_float(u->u_outlet, (argc ? atom_getfloat(argv) : 0)); else if (u->u_type == TR_BANG) outlet_bang(u->u_outlet); else if (u->u_type == TR_SYMBOL) outlet_symbol(u->u_outlet, (argc ? atom_getsymbol(argv) : (s != NULL ? s : &s_symbol))); else if (u->u_type == TR_ANYTHING) outlet_anything(u->u_outlet, s, argc, argv); else if (u->u_type == TR_POINTER){ if (!argc || argv->a_type != TR_POINTER) pd_error(x, "unpack: bad pointer"); else outlet_pointer(u->u_outlet, argv->a_w.w_gpointer); } else if (u->u_type == TR_STATIC_FLOAT) outlet_float(u->u_outlet, u->u_float); else if (u->u_type == TR_STATIC_SYMBOL) outlet_symbol(u->u_outlet, u->u_sym); else outlet_list(u->u_outlet, &s_list, argc, argv); } }
void listUnfold_anything(t_listUnfold *x, t_symbol* s, int ac, t_atom* av) { if ( x->mode == 0) { // Output all int i =0; int offset =0; x->iterating = 1; if ( s != &s_list && s != &s_float && s != &s_symbol ) { outlet_float(x->outlet2,0); outlet_symbol(x->outlet1,s); offset=1; } for ( ; i < ac && x->iterating; i++ ) { outlet_float(x->outlet2,i+offset); if ( IS_A_FLOAT(av,0) ) { outlet_float(x->outlet1,atom_getfloat(av)); } else { outlet_symbol(x->outlet1,atom_getsymbol(av)); } av++; } } else { x->iterating = 0; // Copy and wait for bangs to output int do_selector = ( s != &s_list && s != &s_float && s != &s_symbol ); x->ac = ac + do_selector; //One more for the selector // Resize memory if required and add 3 atoms just in case if(x->ac > x->memSize) { x->av = resizebytes(x->av, x->memSize * sizeof(*(x->av)), (3 + x->ac) * sizeof(*(x->av))); x->memSize = 3 + x->ac; } t_atom* dst = x->av; // Copy selector if ( do_selector ) { SETSYMBOL(dst, s); dst++; } // Copy atoms while(ac--) *dst++ = *av++; } }
static void iem_append_kernel_out(t_iem_append_kernel *x) { int off=0; if(x->x_type1 == A_GIMME) { if(x->x_type2 == A_COMMA) off = 1; else off = 0; iem_append_kernel_merge(x, off); outlet_list(x->x_obj.ob_outlet, &s_list, x->x_ac1+x->x_ac2+off, x->x_at12); } else if(x->x_type1 == A_COMMA) { if(x->x_type2 == A_COMMA) off = 1; else off = 0; iem_append_kernel_merge(x, off); outlet_anything(x->x_obj.ob_outlet, x->x_sym1, x->x_ac1+x->x_ac2+off, x->x_at12); } else if(x->x_type1 == A_NULL)/*depends on 2.part*/ { iem_append_kernel_merge(x, 0); if(x->x_type2 == A_GIMME) outlet_list(x->x_obj.ob_outlet, &s_list, x->x_ac2, x->x_at12); else if(x->x_type2 == A_COMMA) outlet_anything(x->x_obj.ob_outlet, x->x_sym2, x->x_ac2, x->x_at12); else if(x->x_type2 == A_FLOAT) outlet_float(x->x_obj.ob_outlet, atom_getfloat(x->x_at12)); else if(x->x_type2 == A_SYMBOL) outlet_symbol(x->x_obj.ob_outlet, atom_getsymbol(x->x_at12)); else if(x->x_type2 == A_NULL) outlet_bang(x->x_obj.ob_outlet); else if(x->x_type2 == A_POINTER) outlet_pointer(x->x_obj.ob_outlet, (t_gpointer *)x->x_at12->a_w.w_gpointer); } else { if(x->x_type2 == A_COMMA) off = 1; else off = 0; iem_append_kernel_merge(x, off); if(x->x_type2 == A_NULL) { if(x->x_type1 == A_FLOAT) outlet_float(x->x_obj.ob_outlet, atom_getfloat(x->x_at12)); else if(x->x_type1 == A_SYMBOL) outlet_symbol(x->x_obj.ob_outlet, atom_getsymbol(x->x_at12)); else if(x->x_type1 == A_POINTER) outlet_pointer(x->x_obj.ob_outlet, (t_gpointer *)x->x_at12->a_w.w_gpointer); } else outlet_list(x->x_obj.ob_outlet, &s_list, x->x_ac1+x->x_ac2+off, x->x_at12); } }
/* CHECKED: both floats and symbols */ static void iter_dobang(t_iter *x, t_symbol *s, int ac, t_atom *av) { if (s && s != &s_) outlet_symbol(((t_object *)x)->ob_outlet, s); while (ac--) { if (av->a_type == A_FLOAT) outlet_float(((t_object *)x)->ob_outlet, av->a_w.w_float); else if (av->a_type == A_SYMBOL) outlet_symbol(((t_object *)x)->ob_outlet, av->a_w.w_symbol); av++; } }
/* * Q.3 - Comportement en cas de message bang */ void multipouet_bang(t_multipouet *x){ x->i_count = x->i_count + x->step; char pouet[1024]; strcpy(pouet,""); int i; for(i=0 ; i<x->i_count ; i++){ strcat(pouet, "pouet "); } outlet_symbol(x->p_out, gensym(pouet)); if(x->i_count >= x->i_max){ outlet_symbol(x->b_out, gensym("bang")); x->i_count=x->i_min; } }
static void trigger2_anything(t_trigger2 *x, t_symbol *s, int argc, t_atom *argv){ t_atom *av2 = NULL; t_trigger2out *u; int i, j = 0; for (i = x->x_n, u = x->x_vec + i; u--, i--;){ if (u->u_type == TR_BANG) outlet_bang(u->u_outlet); else if (u->u_type == TR_ANYTHING) outlet_anything(u->u_outlet, s, argc, argv); else if (u->u_type == TR_STATIC_FLOAT) outlet_float(u->u_outlet, u->u_float); else if (u->u_type == TR_STATIC_SYMBOL) outlet_symbol(u->u_outlet, u->u_sym); else{ // copying trigger2_list behavior except that here we keep // the outlet number and therefore avoid redundant printouts if (u->u_type == TR_FLOAT) outlet_float(u->u_outlet, (argc ? atom_getfloat(argv) : 0)); else if (u->u_type == TR_BANG) outlet_bang(u->u_outlet); else if (u->u_type == TR_SYMBOL) outlet_symbol(u->u_outlet, (s != NULL ? s : (argc ? atom_getsymbol(argv) : &s_symbol))); else if (u->u_type == TR_ANYTHING) outlet_anything(u->u_outlet, s, argc, argv); else if (u->u_type == TR_POINTER) if (!argc || argv->a_type != TR_POINTER) pd_error(x, "unpack: bad pointer"); else outlet_pointer(u->u_outlet, argv->a_w.w_gpointer); else if (u->u_type == TR_STATIC_FLOAT) outlet_float(u->u_outlet, u->u_float); else if (u->u_type == TR_STATIC_SYMBOL) outlet_symbol(u->u_outlet, u->u_sym); else{ // Ico: don't have to worry about zero element case (AFAICT) av2 = (t_atom *)getbytes((argc + 1) * sizeof(t_atom)); SETSYMBOL(av2, s); if (argc == 0) outlet_list(u->u_outlet, &s_symbol, argc+1, av2); else{ for (j = 0; j < argc; j++) av2[j + 1] = argv[j]; SETSYMBOL(av2, s); outlet_list(u->u_outlet, &s_list, argc+1, av2); } freebytes(av2, (argc + 1) * sizeof(t_atom)); } } } }
static void mergefilename_anything(t_mergefilename *x, t_symbol *s, int ac, t_atom *av) { char flt_buf[30]; t_int i, length, accu_size=0; x->x_mem[0] = 0; length = strlen(s->s_name); if(length > (MAXPDSTRING - 2)) { strncat(x->x_mem, s->s_name, MAXPDSTRING - 2); accu_size = MAXPDSTRING - 2; i = ac + 1; } else { strcat(x->x_mem, s->s_name); accu_size = length; } if(ac > 0) { for(i=0; i<ac; i++) { strcat(x->x_mem, x->x_sep); if(IS_A_SYMBOL(av, 0)) { length = strlen(av->a_w.w_symbol->s_name); if((accu_size + length) > (MAXPDSTRING - 2)) { strncat(x->x_mem, av->a_w.w_symbol->s_name, MAXPDSTRING - 2 - accu_size); accu_size = MAXPDSTRING - 2; i = ac + 1; } else { strcat(x->x_mem, av->a_w.w_symbol->s_name); accu_size += length; } } else if(IS_A_FLOAT(av, 0)) { sprintf(flt_buf, "%g", av->a_w.w_float); length = strlen(flt_buf); if((accu_size + length) > (MAXPDSTRING - 2)) { strncat(x->x_mem, flt_buf, MAXPDSTRING - 2 - accu_size); accu_size = MAXPDSTRING - 2; i = ac + 1; } else { strcat(x->x_mem, flt_buf); accu_size += length; } } av++; } } outlet_symbol(x->x_obj.ob_outlet, gensym(x->x_mem)); }
static void sarray_get(t_sarray *x,t_float i) { t_symbol *s=scommon_get(x->x_c,i); if(s==&s_) outlet_bang(x->x_obj.ob_outlet); else outlet_symbol(x->x_obj.ob_outlet,scommon_get(x->x_c,i)); }
static void canvas_name_bang(t_canvas_name *x) { /* actually get the canvas name each time to make sure we get * accurate info in case of changes. If we cache the result, a * canvas could have been deleted or renamed. */ outlet_symbol(x->x_obj.ob_outlet, get_canvas_name(x)); }
static void h_deque_front(t_h_deque *x) { if(x->hdeque->getSize() == 0) { post("h_deque, front: size is 0 !"); return; } Element output = x->hdeque->front(); if(output.getLength() == 1) // symbol or float { if (output.getAtom()[0].a_type == A_FLOAT) outlet_float(x->out0, output.getAtom()[0].a_w.w_float); if (output.getAtom()[0].a_type == A_SYMBOL) outlet_symbol(x->out0, output.getAtom()[0].a_w.w_symbol); if (output.getAtom()[0].a_type == A_POINTER) outlet_pointer(x->out0, output.getAtom()[0].a_w.w_gpointer); return; } if(output.getLength() > 1) // list { outlet_list(x->out0,&s_list,output.getLength(),output.getAtom()); return; } // if there was no Element found, put out a bang at the right outlet outlet_bang(x->out2); }
static void routeOSC_symbol(t_routeOSC *x, t_symbol *s) { /* output non-OSC data on rightmost outlet */ if (x->x_verbosity) post("routeOSC_symbol (%p) %s", x, s->s_name); outlet_symbol(x->x_outlets[x->x_num], s); }
/* CHECKME */ static void iter_symbol(t_iter *x, t_symbol *s) { outlet_symbol(((t_object *)x)->ob_outlet, s); x->x_selector = 0; x->x_natoms = 1; SETSYMBOL(x->x_message, s); }
static void ctw_output(struct _ctw *common, struct _memory_struct *out_memory, FILE *fp) { CURLMsg *msg; int msgs_left; while ((msg = curl_multi_info_read(common->multi_handle, &msgs_left))) { if (msg->msg == CURLMSG_DONE) { long http_status; /* output status */ curl_easy_getinfo(common->easy_handle, CURLINFO_RESPONSE_CODE, &http_status); if (http_status >= 200 && http_status < 300) { if (msg->data.result == CURLE_OK) { if (fp == NULL) { outlet_symbol(common->x_ob.ob_outlet, gensym((*out_memory).memory)); } /* Free memory */ string_free((*out_memory).memory, &(*out_memory).size); outlet_bang(common->status_out); } else { ctw_output_curl_error(common, msg); } } else { if (msg->data.result == CURLE_OK){ t_atom http_status_data; SETFLOAT(&http_status_data, (float)http_status); pd_error(common, "HTTP error while performing request: %li", http_status); outlet_float(common->status_out, atom_getfloat(&http_status_data)); } else { ctw_output_curl_error(common, msg); } } curl_easy_cleanup(common->easy_handle); curl_multi_cleanup(common->multi_handle); } } }
static void h_list_front(t_h_list *x) { if(x->hlist->getSize() == 0) { outlet_bang(x->out3); return; } Element output = x->hlist->front(); if(output.getLength() == 1) // symbol or float { if (output.getAtom()[0].a_type == A_FLOAT) outlet_float(x->out0, output.getAtom()[0].a_w.w_float); if (output.getAtom()[0].a_type == A_SYMBOL) outlet_symbol(x->out0, output.getAtom()[0].a_w.w_symbol); if (output.getAtom()[0].a_type == A_POINTER) outlet_pointer(x->out0, output.getAtom()[0].a_w.w_gpointer); return; } if(output.getLength() > 1) // list { outlet_list(x->out0,&s_list,output.getLength(),output.getAtom()); return; } outlet_bang(x->out3); }
static void hang_tick(t_hang *h) { t_pipe *x = h->h_owner; t_hang *h2, *h3; t_pipeout *p; int i; union word *w; if (x->x_hang == h) x->x_hang = h->h_next; else for (h2 = x->x_hang; (h3 = h2->h_next); h2 = h3) { if (h3 == h) { h2->h_next = h3->h_next; break; } } for (i = x->x_n, p = x->x_vec + (x->x_n - 1), w = h->h_vec + (x->x_n - 1); i--; p--, w--) { switch (p->p_atom.a_type) { case A_FLOAT: outlet_float(p->p_outlet, w->w_float); break; case A_SYMBOL: outlet_symbol(p->p_outlet, w->w_symbol); break; case A_POINTER: if (gpointer_check(w->w_gpointer, 1)) outlet_pointer(p->p_outlet, w->w_gpointer); else pd_error(x, "pipe: stale pointer"); break; default: break; } } hang_free(h); }
/*-------------------------------------------------------------------- * outlet_cur * + outlets current element to outlet-1, if non-NULL * + otherwise, bangs to outlet-2 */ static void pd_deque_outlet_cur(t_pd_deque *x) { if (x->x_cur) { --x->x_size; if (x->x_cur->argc == 1) { switch (x->x_cur->argv->a_type) { case A_FLOAT: outlet_float(x->elt_out, x->x_cur->argv->a_w.w_float); return; case A_SYMBOL: outlet_symbol(x->elt_out, x->x_cur->argv->a_w.w_symbol); return; case A_POINTER: outlet_pointer(x->elt_out, x->x_cur->argv->a_w.w_gpointer); return; default: error("Error: deque: unrecognized atom type '%d' defaults to 'bang'.", x->x_cur->argv->a_type); outlet_bang(x->elt_out); } } else { outlet_anything(x->elt_out, atom_getsymbol(x->x_cur->argv), x->x_cur->argc-1, x->x_cur->argv+1 ); } } else { outlet_bang(x->eoq_out); } }
static void buddy_check(t_buddy *x) { t_buddy_proxy **p = (t_buddy_proxy **)x->x_proxies; int i = x->x_nslots; while (i--) if (!(*p++)->p_selector) return; p = (t_buddy_proxy **)x->x_proxies; i = x->x_nslots; while (i--) { t_symbol *s = p[i]->p_selector; if (s == &s_bang) outlet_bang(x->x_outs[i]); else if (s == &s_float) outlet_float(x->x_outs[i], p[i]->p_float); else if (s == &s_symbol && p[i]->p_symbol) outlet_symbol(x->x_outs[i], p[i]->p_symbol); else if (s == &s_pointer) { /* LATER */ } else if (s == &s_list) outlet_list(x->x_outs[i], s, p[i]->p_natoms, p[i]->p_message); else if (s) outlet_anything(x->x_outs[i], s, p[i]->p_natoms, p[i]->p_message); } buddy_clear(x); }
static void trigger_list(t_trigger *x, t_symbol *s, int argc, t_atom *argv) { #ifdef ROCKBOX (void) s; #endif t_triggerout *u; int i; t_atom at; if (!argc) { argc = 1; SETFLOAT(&at, 0); argv = &at; } for (i = x->x_n, u = x->x_vec + i; u--, i--;) { if (u->u_type == TR_FLOAT) outlet_float(u->u_outlet, atom_getfloat(argv)); else if (u->u_type == TR_BANG) outlet_bang(u->u_outlet); else if (u->u_type == TR_SYMBOL) outlet_symbol(u->u_outlet, atom_getsymbol(argv)); else if (u->u_type == TR_POINTER) { if (argv->a_type != TR_POINTER) pd_error(x, "unpack: bad pointer"); else outlet_pointer(u->u_outlet, argv->a_w.w_gpointer); } else outlet_list(u->u_outlet, &s_list, argc, argv); } }
static void scrolllist_output_current(t_scrolllist* x) { if ( x->x_items && x->x_itemselected < x->x_nitems && x->x_itemselected >= 0 ) { outlet_symbol( x->x_item, gensym( x->x_items[x->x_itemselected] ) ); } }
static void pitch_float(t_pitch *x, t_floatarg f) { char buf[8]; int r, c, interval = 0, pitch; char* notes_up[12] = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; char* notes_down[12] = {"C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B"}; pitch = (t_int)f; if(pitch < 1) pitch = 0; if(pitch > 127) pitch = 127; if(x->x_lastpitch != 0)interval = pitch - x->x_lastpitch; x->x_lastpitch = pitch; r = (pitch / 12) - 1; c = pitch % 12; if(interval >= 0) { sprintf(buf, "%s%d", notes_up[c], r); } else { sprintf(buf, "%s%d", notes_down[c], r); } // post("note: %s %d", notes[c], r); /* output values from right to left */ outlet_float(x->x_outregister, r); outlet_float(x->x_outintv, interval); outlet_float(x->x_outpitchclass, c); outlet_symbol(x->x_outpitchname, gensym(buf)); outlet_float(x->x_outpitchval, pitch); }
static void bondo_doit(t_bondo *x) { t_bondo_proxy **p = (t_bondo_proxy **)x->x_proxies; int i = x->x_nslots; p = (t_bondo_proxy **)x->x_proxies; i = x->x_nslots; while (i--) { t_symbol *s = p[i]->p_selector; /* LATER consider complaining about extra arguments (CHECKED) */ if (s == &s_bang) outlet_bang(x->x_outs[i]); else if (s == &s_float) outlet_float(x->x_outs[i], p[i]->p_float); else if (s == &s_symbol && p[i]->p_symbol) { /* LATER rethink */ if (x->x_multiatom) outlet_symbol(x->x_outs[i], p[i]->p_symbol); else outlet_anything(x->x_outs[i], p[i]->p_symbol, 0, 0); } else if (s == &s_pointer) { /* LATER */ } else if (s == &s_list) outlet_list(x->x_outs[i], s, p[i]->p_natoms, p[i]->p_message); else if (s) /* CHECKED: a slot may be inactive (in multiatom mode) */ outlet_anything(x->x_outs[i], s, p[i]->p_natoms, p[i]->p_message); } }
static void mergefilename_float(t_mergefilename *x, t_floatarg f) { char flt_buf[30]; flt_buf[0] = 0; sprintf(flt_buf, "%g", f); outlet_symbol(x->x_obj.ob_outlet, gensym(flt_buf)); }
static void pdsymbol_anything(t_pdsymbol *x, t_symbol *s, int ac, t_atom *av) { #ifdef ROCKBOX (void) ac; (void) av; #endif outlet_symbol(x->x_obj.ob_outlet, x->x_s = s); }
static void tosymbol_flushbuffer(t_tosymbol *x) { if (*x->x_buffer) { x->x_entered = 1; outlet_symbol(((t_object *)x)->ob_outlet, gensym(x->x_buffer)); x->x_entered = 0; } }
/* output the entry at a given index */ static void index_float(t_index *x, t_float findex) { int iindex = (int)findex; if ((iindex > 0) && (iindex <= x->maxentries) && (x->names[iindex-1])) { /* TB: output symbol to outlet */ outlet_symbol (x->x_obj.ob_outlet,x->names[iindex-1]); } }
static void nchange_bang(t_nchange *x) { if (x->x_type == A_FLOAT) outlet_float(x->x_obj.ob_outlet, x->x_a->a_w.w_float); else if (x->x_type == A_SYMBOL) outlet_symbol(x->x_obj.ob_outlet, x->x_a->a_w.w_symbol); else outlet_list(x->x_obj.ob_outlet, NULL, x->x_c, x->x_a); }
static void makefilename_symbol(t_makefilename *x, t_symbol *s) { char buf[MAXPDSTRING]; #ifdef ROCKBOX snprintf(buf, sizeof(buf), x->x_format->s_name, s->s_name); #else sprintf(buf, x->x_format->s_name, s->s_name); #endif outlet_symbol(x->x_obj.ob_outlet, gensym(buf)); }