static void lifop_bang(t_lifop *x) { t_lifop_prioritylist*plifo=0; t_lifop_list*lifo=0; t_atom*argv=0; int argc=0; if(!(plifo=getLifo(x->lifo_list))){ outlet_bang(x->x_infout); return; } if(!(lifo=plifo->lifo_start)){ outlet_bang(x->x_infout); return; } x->counter--; plifo->lifo_start=lifo->next; /* get the list from the entry */ argc=lifo->argc; argv=lifo->argv; lifo->argc=0; lifo->argv=0; lifo->next=0; /* destroy the lifo-entry (important for recursion! */ freebytes(lifo, sizeof(t_lifop_list)); /* output the list */ outlet_list(x->x_out, &s_list, argc, argv); /* free the list */ freebytes(argv, argc*sizeof(t_atom)); }
static int oggread_decode_input(t_oggread *x) { long ret; /* bytes per channel returned by decoder */ int i; float **pcm; x->x_vi = ov_info(&x->x_ov, x->x_current_section); while(!x->x_eos) { ret = ov_read_float(&x->x_ov, &pcm, READ, &x->x_current_section); if (ret == 0) { /* EOF */ x->x_eos = 1; x->x_stream = 0; clock_unset(x->x_clock); // post("oggread~: end of file detected, stopping"); outlet_bang(x->x_out_end); } else if (ret < 0) { /* error in the stream. Not a problem, just reporting it in case we (the app) cares. In this case, we don't. */ } else { /* we don't bother dealing with sample rate changes, etc, but you'll have to */ long j; for(j = 0; j < ret; j++) { for(i = 0; i < x->x_vi->channels; i++) { x->x_outbuffer[x->x_outwriteposition] = pcm[i][j]; x->x_outwriteposition = (x->x_outwriteposition + 1)%x->x_outbuffersize; } } x->x_outunread += (t_int)ret * x->x_vi->channels; } break; } x->x_decoded = (t_int)ret * x->x_vi->channels; /* num. of samples we got from decoder */ x->x_position = (t_float)ov_time_tell(&x->x_ov); /* exit decoding 'loop' here, we'll get called again by perform() */ return 1; }
/*------------------------------------ x10ProcessQueue ---*/ static void x10ProcessQueue(X10ControlData * xx) { if (xx && (! xx->fStopping)) { short prevLock = lockout_set(1); outlet_bang(xx->fPollerOut); clock_delay(xx->fPollClock, xx->fPollRate); lockout_set(prevLock); #if USE_EVNUM evnum_incr(); #endif /* USE_EVNUM */ } } // x10ProcessQueue
///////////////////////////////////////////////////////// // postrender // ///////////////////////////////////////////////////////// void pix_filmOS :: postrender(GemState *state) { if(state) { // state->image=m_oldImage; state->set(GemState::_PIX, m_oldImage); } m_pixBlock.newimage = 0; if (m_numFrames>0 && m_reqFrame>m_numFrames){ m_reqFrame = m_numFrames; outlet_bang(m_outEnd); } m_newFilm = 0; m_pixBlock.newfilm = m_newFilm; }
static t_int *aubioquiet_tilde_perform(t_int *w) { t_aubioquiet_tilde *x = (t_aubioquiet_tilde *)(w[1]); t_sample *in = (t_sample *)(w[2]); int n = (int)(w[3]); int j; for (j=0;j<n;j++) { /* write input to datanew */ fvec_set_sample(x->vec, in[j], x->pos); /*time for fft*/ if (x->pos == x->hopsize-1) { /* block loop */ if (aubio_silence_detection(x->vec, x->silence)==1) { if (x->wassilence==1) { x->issilence = 1; } else { x->issilence = 2; outlet_bang(x->quietbang); } x->wassilence=1; } else { if (x->wassilence<=0) { x->issilence = 0; } else { x->issilence = -1; outlet_bang(x->noisybang); } x->wassilence=0; } /* end of block loop */ x->pos = -1; /* so it will be zero next j loop */ } x->pos++; } return (w+4); }
//the method when a bang is received void counter_bang(t_extCounter* x) { t_float f=x->i_count; t_int step = x->step; x->i_count+=step; if (x->i_down-x->i_up) { if ((step>0) && (x->i_count > x->i_up)) { x->i_count = x->i_down; // so if we're reseting output a bang on the second outlet outlet_bang(x->b_out); } else if (x->i_count < x->i_down) { x->i_count = x->i_up; // so if we're reseting output a bang on the second outlet outlet_bang(x->b_out); } } outlet_float(x->f_out, f); post("extCounter banging"); }
static void sel2_symbol(t_sel2 *x, t_symbol *s) { t_selectelement *e; int nelement; if (x->x_type == A_SYMBOL) { for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) if (e->e_w.w_symbol == s) { outlet_bang(e->e_outlet); return; } } outlet_symbol(x->x_rejectout, s); }
void Catmullrom3D::spline_exec(t_spline *x) { long i; double inc; t_point delta; spline_make_endpoints(x); // prep for hermite etc: calculate helper points spline_stepthrough(x); x->b_result[0].a_w.w_float = x->b_control[x->b_size - 1].x; // output the last point x->b_result[1].a_w.w_float = x->b_control[x->b_size - 1].y; x->b_result[2].a_w.w_float = x->b_control[x->b_size - 1].z; outlet_list(x->b_outlet1, 0L, x->b_dim, x->b_result); outlet_bang(x->b_outlet2); }
static void sel2_float(t_sel2 *x, t_float f) { t_selectelement *e; int nelement; if (x->x_type == A_FLOAT) { for (nelement = x->x_nelement, e = x->x_vec; nelement--; e++) if (e->e_w.w_float == f) { outlet_bang(e->e_outlet); return; } } outlet_float(x->x_rejectout, f); }
void posit_getinfo(t_posit *x) { t_object *jp; t_object *jb; t_object *pbox; t_rect jr; t_symbol *scriptingname = ps_none; t_symbol *patchername = ps_none; t_symbol *patcherscriptingname = ps_none; t_max_err err; t_symbol *classname; t_atom *outlist; outlist = x->p_outlist; err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp); // get the object's parent patcher if (err != MAX_ERR_NONE) return; err = object_obex_lookup(x, gensym("#B"), (t_object **)&jb); // get the object's wrapping box if (err != MAX_ERR_NONE) return; patchername = jpatcher_get_name(jp); classname = jbox_get_maxclass(jb); // class name scriptingname = jbox_get_varname(jb); // scripting name if (scriptingname == NULL || scriptingname == ps_nothing) { scriptingname = ps_none; } pbox = jpatcher_get_box(jp); if(pbox) patcherscriptingname = jbox_get_varname(pbox); // scripting name if (patcherscriptingname == NULL || patcherscriptingname == ps_nothing) { patcherscriptingname = ps_none; } jbox_get_patching_rect(jb, &jr); // x, y, width, height (double) atom_setsym(outlist+0, classname); // class name atom_setsym(outlist+1, scriptingname); // scripting name atom_setlong(outlist+2, (long)((long)jr.x)); atom_setlong(outlist+3, (long)((long)jr.y)); atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height)); atom_setsym(outlist+6, patchername); // patcher name atom_setsym(outlist+7, patcherscriptingname); outlet_list(x->p_outlet,0L,8,outlist); outlet_bang(x->p_outlet2); //bang to notify of end of dump }
/*-------------------------------------------------------------------- * bang : output the next klatt frame as a list */ void holmes_bang(t_holmes *x) { // -- get the next frame holmes_compute_next_frame(&(x->hg),&(x->hs)); if (dsqueue_empty(x->hs.eltq)) { // -- report end-of-queue outlet_bang(x->eoq_out); } // -- reset end-of-utterance flag x->hs.flags &= ~(HOLMES_FLAG_EOU|HOLMES_FLAG_EOW); // -- finally, output the klatt frame klatt_frame_to_alist((long *)&(x->hs.pars), x->aframe); outlet_list(x->kfr_out, &s_list, NPAR, x->aframe); }
/* this is the actual performance routine which acts on the samples. It's called with a single pointer "w" which is our location in the DSP call list. We return a new "w" which will point to the next item after us. Meanwhile, w[0] is just a pointer to dsp-perform itself (no use to us), w[1] and w[2] are the input and output vector locations, and w[3] is the number of points to calculate. */ static t_int *fileosc_perform(t_int *w) { t_float *in = (t_float *)(w[1]); t_float *out = (t_float *)(w[2]); int n = (int)(w[3]); t_fileosc *x = (t_fileosc *)(w[4]); double y,ind; int z,v; if (x->stat) { while (n--) { /* trata o inicio de eventos */ if (x->n==0) { /* testa se acabou arquivo */ z=fscanf(x->arq,"%lf",&y); x->freq=y; if (feof(x->arq)) { x->stat=0; x->n = 0; post("...acabou o arquivo!"); outlet_bang(x->bangoutlet); return (w+5); } z=fscanf(x->arq,"%d",&v); x->dur=v; post("novo evento: frequencia=%lf, duracao=%d",x->freq,x->dur); x->delta = x->freq*x->S/sys_getsr(); } /* Aqui esta' sendo feita a leitura truncada da tabela */ ind = x->ind+x->n*x->delta; *out = x->SENO[(int)(ind-((int)ind/x->S)*x->S)]; x->n++; if (x->n==x->dur) { x->n=0; x->ind = x->ind+x->n*x->delta; } *out++; } } return (w+5); }
/*------------------------------------ spaceballProcessQueue ---*/ static void spaceballProcessQueue(SpaceballData * xx) { if (xx && (! xx->fStopping)) { short prevLock = lockout_set(1); if (! xx->fReset) { static unsigned char resetString[] = "@RESET\015\015"; if (! xx->fDelayCounter) { spaceballPerformWriteCommand(xx, sizeof(resetString) - 1, resetString); ++xx->fDelayCounter; } else if (xx->fDelayCounter++ >= xx->fResetDuration) { xx->fReset = true; xx->fDelayCounter = 0; } } else if (! xx->fInited) { static unsigned char initString[] = "CB\015NT\015FR?\015P@r@r\015MSSV\015Z\015BcCcCc\015"; if (! xx->fDelayCounter) { spaceballPerformWriteCommand(xx, sizeof(initString) - 1, initString); spaceballZeroValues(xx); ++xx->fDelayCounter; } else if (xx->fDelayCounter++ >= xx->fInitDuration) { xx->fInited = true; xx->fDelayCounter = 0; } } outlet_bang(xx->fSampleBangOut); clock_delay(xx->fPollClock, xx->fPollRate); lockout_set(prevLock); #if USE_EVNUM evnum_incr(); #endif /* USE_EVNUM */ } } // spaceballProcessQueue
/*------------------------------------ cmd_Anything ---*/ Pvoid cmd_Anything(RcxControlPtr xx, PSymbol message, short argc, PAtom argv) { EnterCallback(); LOG_ERROR_2(OUTPUT_PREFIX "Unknown message '%s' seen", message->s_name) outlet_bang(xx->fErrorBangOut); for (short ii = 0; ii < argc; ++ii) { switch (argv[ii].a_type) { case A_LONG: LOG_POST_3(" argument %hd is a long (%ld)", ii, argv[ii].a_w.w_long) break; case A_SYM: LOG_POST_3(" argument %hd is a symbol (%s)", ii, argv[ii].a_w.w_sym->s_name) break; case A_FLOAT: LOG_POST_3(" argument %hd is a float (%g)", ii, double(argv[ii].a_w.w_float)) break; case A_SEMI: LOG_POST_2(" argument %hd is a semicolon", ii) break; case A_COMMA: LOG_POST_2(" argument %hd is a comma", ii) break; case A_DOLLAR: LOG_POST_2(" argument %hd is a dollar sign", ii) break; default: LOG_POST_3(" argument %hd is an unknown type (%hd)", ii, argv[ii].a_type) break; } } ExitMaxMessageHandler() } /* cmd_Anything */
void posit_boxes(t_posit *x) // ok: done { t_object *jp; t_object *jb; t_object *mybox; t_rect jr; t_symbol *scriptingname; t_symbol *patchername; t_max_err err; t_symbol *classname; t_atom *outlist; outlist = x->p_outlist; err = object_obex_lookup(x, gensym("#P"), (t_object **)&jp); // get the object's parent patcher if (err != MAX_ERR_NONE) return; err = object_obex_lookup(x, gensym("#B"), (t_object **)&mybox); // get the object's wrapping box if (err != MAX_ERR_NONE) return; jb = jpatcher_get_firstobject(jp); // get the first BOX in the object list patchername = jpatcher_get_name(jp); while(jb) { // iterate through patcher classname = jbox_get_maxclass(jb); // class name scriptingname = jbox_get_varname(jb); // scripting name if (scriptingname == NULL || scriptingname == ps_nothing) { scriptingname = ps_none; } jbox_get_patching_rect(jb, &jr); // x, y, width, height (double) atom_setsym(outlist+0, classname); // class name atom_setsym(outlist+1, scriptingname); // scripting name atom_setlong(outlist+2, (long)((long)jr.x)); atom_setlong(outlist+3, (long)((long)jr.y)); atom_setlong(outlist+4, (long)((long)jr.x + (long)jr.width)); atom_setlong(outlist+5, (long)((long)jr.y + (long)jr.height)); atom_setsym(outlist+6, patchername); // patcher name outlet_list(x->p_outlet,0L,7,outlist); jb = jbox_get_nextobject(jb); // iterate } outlet_bang(x->p_outlet2); //bang to notify of end of dump }
static void rawin_close(t_rawin *x) { if (!x->x_active) return; /* stop thread: set giveup + wait */ x->x_giveup = 1; if (x->x_mode) pthread_join(x->x_thread, NULL); x->x_active = 0; /* close pipe */ close(x->x_pipefd); /* notify */ outlet_bang(x->x_sync_outlet); pdp_post("pdp_rawin: connection to %s closed", x->x_pipe->s_name); }
void past_int(t_past *x, long n) { t_atom a; atom_setlong(&a, n); if (x->p_size==1) { if (past_compare(x,&a,0) > 0) { if (!x->p_set) { x->p_set = 1; outlet_bang(x->p_out); } } else { x->p_set = 0; } } else { if (past_compare(x,&a,0) < 0) x->p_set = 0; } }
static int image_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) { //printf("doit=%d\n", doit); t_image *x = (t_image *)z; if (doit && x->x_click) outlet_bang(x->x_obj.ob_outlet); // LATER: figure out how to do click on and click off // and provide a toggle button behavior insteadS /*{ x->x_clicked = 1; outlet_float(x->x_obj.ob_outlet, x->x_clicked); } else if (x->x_clicked) { x->x_clicked = 0; outlet_float(x->x_obj.ob_outlet, x->x_clicked); }*/ return(1); }
void past_float(t_past *x, double f) { t_atom a; atom_setfloat(&a, f); if (x->p_size==1) { if (past_compare(x,&a,0) > 0) { if (!x->p_set) { x->p_set = 1; outlet_bang(x->p_out); } } else { x->p_set = 0; } } else { if (past_compare(x,&a,0) < 0) x->p_set = 0; } }
/* LATER rethink */ static void substitute_dooutput(t_substitute *x, t_symbol *s, int ac, t_atom *av, int pass) { t_outlet *out = (pass ? x->x_passout : ((t_object *)x)->ob_outlet); if (s == &s_float) { if (ac > 1) outlet_list(out, &s_list, ac, av); else outlet_float(out, av->a_w.w_float); } else if (s == &s_bang && !ac) /* CHECKED */ outlet_bang(out); else if (s == &s_symbol && ac == 1 && av->a_type == A_SYMBOL) outlet_symbol(out, av->a_w.w_symbol); else if (s) outlet_anything(out, s, ac, av); else if (ac) outlet_list(out, &s_list, ac, av); }
/*-------------------------------------------------------------------- * anything */ static void bytes2any_anything(t_bytes2any *x, MOO_UNUSED t_symbol *sel, int argc, t_atom *argv) { int i0=0, i; /*-- scan & output --*/ if (x->x_eos >= 0) { for (i=i0; i < argc; i++) { if (((int)atom_getfloatarg(i,argc,argv))==((int)x->x_eos)) { bytes2any_atoms(x, i-i0, argv+i0); i0=i+1; } } } if (i0 < argc) { bytes2any_atoms(x, argc-i0, argv+i0); } outlet_bang(x->x_outlet_done); }
static void imagebang_bang(t_imagebang *x) { t_glist* glist = glist_getcanvas(x->glist); if(x->flashing) { sys_vgui(".x%lx.c itemconfigure %lximage -image %lx_imagebang \n", glist, x,x->image_a); clock_delay(x->clock_brk, x->clockbrk); //x->flashed = 1; } else { sys_vgui(".x%lx.c itemconfigure %lximage -image %lx_imagebang \n", glist, x,x->image_b); x->flashing = 1; } clock_delay(x->clock_flash, x->clockflash); outlet_bang(x->outlet); if(x->send && x->send->s_thing ) pd_bang(x->send->s_thing); }
void OSCroute_list(t_OSCroute *x, t_symbol *s, int argc, t_atom *argv) { // EnterCallback(); if (argc > 0 && argv[0].a_type == A_SYMBOL) { /* Ignore the fact that this is a "list" */ OSCroute_doanything(x, argv[0].a_w.w_symbol, argc-1, argv+1); } else if (argc > 0) { // post("* OSC-route: invalid list beginning with a number"); // output on unmatched outlet jdl 20020908 if (argv[0].a_type == A_FLOAT) { outlet_float(x->x_outlets[x->x_num], argv[0].a_w.w_float); } else { post("* OSC-route: unrecognized atom type!"); } } else { // output a bang on the rejected outlet if no arguments outlet_bang(x->x_outlets[x->x_num]); } // ExitCallback(); }
void myobject_FullPacket(MyObject *x, long size, long ref) { Atom a; EnterCallback(); a.a_type=A_SYM; a.a_w.w_sym=gensym((char *) ref); // here is where any arguments would go, // but for VAMP's purposes at least. // "the argument is the message." x->m_value = size; outlet_int(x->m_out,x->m_value); outlet_bang(x->m_out_b); outlet_anything(x->m_out_s,gensym("VAMP"),1, &a); // so in the VAMP external (whenever that happens), there needs just be a // void my_object_VAMP(MyObject *x, symbol * message)... ExitCallback(); }
/* generates a formant */ static t_int *formant_perform(t_int *w) { t_formant *x = (t_formant *)(w[1]); t_float *out = (t_float *)(w[2]); int n = (int)(w[3]); /* number of samples */ while (n--) { if ( !x->x_gendata && x->x_play) { *out=*(x->x_data+x->x_readpos); x->x_readpos = (x->x_readpos+1)%x->x_size; if ( x->x_readpos == 0 ) { x->x_play=0; outlet_bang(x->x_end); } } else { *out=0.0; } out++; } return (w+4); }
static void funbuff_next(t_funbuff *x) { t_hammernode *np; if (!x->x_tree.t_root) return; if (!(np = x->x_pointer)) { outlet_bang(x->x_bangout); /* CHECKED banging until reset */ return; } if (x->x_pointerset) x->x_lastdelta = 0; else if (np->n_prev) x->x_lastdelta = np->n_key - np->n_prev->n_key; else x->x_lastdelta = 0; /* CHECKED corrupt delta sent here... */ funbuff_dooutput(x, HAMMERNODE_GETFLOAT(np), x->x_lastdelta); x->x_pointer = np->n_next; x->x_pointerset = 0; }
static void loadmess_output(t_loadmess *x) { if(!x->l_argc) { outlet_bang(x->l_out); } else if(x->l_argc == 1) { if(atom_gettype(x->l_argv) == A_FLOAT) outlet_float(x->l_out, atom_getfloat(x->l_argv)); else if (atom_gettype(x->l_argv) == A_SYMBOL) outlet_symbol(x->l_out, atom_getsymbol(x->l_argv)); } else { if(atom_gettype(x->l_argv) == A_FLOAT) outlet_list(x->l_out, &s_list, (int)x->l_argc, x->l_argv); else if (atom_gettype(x->l_argv) == A_SYMBOL) outlet_anything(x->l_out, atom_getsymbol(x->l_argv), (int)x->l_argc-1, x->l_argv+1); } }
/*------------------------------------ cmd_Stop ---*/ Pvoid cmd_Stop(ListenPtr xx) { EnterCallback(); if (xx) { #if SPEECH_RECOGNITION_SUPPORTED if (xx->fStarted) { SRStopListening(xx->fRecognizer); xx->fStarted = false; } else { LOG_ERROR_1(OUTPUT_PREFIX "not started") outlet_bang(xx->fErrorBangOut); } #endif /* SPEECH_RECOGNITION_SUPPORTED */ } ExitMaxMessageHandler() } /* cmd_Stop */
static void tab_lt_bang(t_tab_lt *x) { int i, n; int ok_src1, ok_src2, ok_dst; iemarray_t *vec_src1, *vec_src2, *vec_dst; ok_src1 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr1, &x->x_beg_mem_src1, &x->x_size_src1, 0); ok_src2 = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_scr2, &x->x_beg_mem_src2, &x->x_size_src2, 0); ok_dst = iem_tab_check_arrays(gensym("tab_lt"), x->x_sym_dst, &x->x_beg_mem_dst, &x->x_size_dst, 0); if(ok_src1 && ok_src2 && ok_dst) { if(x->x_size_src1 < x->x_size_dst) n = x->x_size_src1; else n = x->x_size_dst; if(x->x_size_src2 < n) n = x->x_size_src2; vec_src1 = x->x_beg_mem_src1; vec_src2 = x->x_beg_mem_src2; vec_dst = x->x_beg_mem_dst; if(n) { t_garray *a; for(i=0; i<n; i++) { if(iemarray_getfloat(vec_src1, i) < iemarray_getfloat(vec_src2, i)) iemarray_setfloat(vec_dst, i, 1.0f); else iemarray_setfloat(vec_dst, i, 0.0f); } outlet_bang(x->x_obj.ob_outlet); a = (t_garray *)pd_findbyclass(x->x_sym_dst, garray_class); garray_redraw(a); } } }
///////////////////////////////////////////////////////// // postrender // ///////////////////////////////////////////////////////// void pix_movieOS :: postrender(GemState *state) { state->texCoords = m_oldTexCoords; state->numTexCoords= m_oldNumCoords; state->texture = m_oldTexture; state->image = m_oldImage; // post("postrender"); m_pixBlock.newimage = 0; if ( !GemMan::texture_rectangle_supported) { glDisable(GL_TEXTURE_2D); } else { glDisable(GL_TEXTURE_RECTANGLE_EXT); } if (m_numFrames>0 && m_reqFrame>m_numFrames) { m_reqFrame = m_numFrames; outlet_bang(m_outEnd); } }