static void mtrack_donext(t_mtrack *tp) { if (tp->tr_ixnext < 0) goto endoftrack; while (1) { int natoms = binbuf_getnatom(tp->tr_binbuf); int ixmess = tp->tr_ixnext; t_atom *atmess; if (ixmess >= natoms) goto endoftrack; atmess = binbuf_getvec(tp->tr_binbuf) + ixmess; while (atmess->a_type == A_SEMI) { if (++ixmess >= natoms) goto endoftrack; atmess++; } if (!tp->tr_atdelta && atmess->a_type == A_FLOAT) { /* delta atom */ float delta = atmess->a_w.w_float; if (delta < 0.) delta = 0.; tp->tr_atdelta = atmess; tp->tr_ixnext = ixmess + 1; if (tp->tr_mode == MTR_PLAYMODE) { clock_delay(tp->tr_clock, tp->tr_clockdelay = delta * tp->tr_tempo); tp->tr_prevtime = clock_getlogicaltime(); } else if (ixmess < 2) /* LATER rethink */ continue; /* CHECKED first delta skipped */ else { /* CHECKED this is not blocked with the muted flag */ t_atom at[2]; SETFLOAT(&at[0], tp->tr_id); SETFLOAT(&at[1], delta); outlet_list(tp->tr_mainout, 0, 2, at); } return; } else { /* message beginning */ int wasrestarted = tp->tr_restarted; /* LATER rethink */ int ixnext = ixmess + 1; t_atom *atnext = atmess + 1; while (ixnext < natoms && atnext->a_type != A_SEMI) ixnext++, atnext++; tp->tr_restarted = 0; if (!tp->tr_muted) { int ac = ixnext - ixmess; if (ac > 1) { if (atmess->a_type == A_FLOAT) outlet_list(tp->tr_trackout, &s_list, ac, atmess); else if (atmess->a_type == A_SYMBOL) outlet_anything(tp->tr_trackout, atmess->a_w.w_symbol, ac-1, atmess+1); } else if (atmess->a_type == A_FLOAT) outlet_float(tp->tr_trackout, atmess->a_w.w_float); else if (atmess->a_type == A_SYMBOL) outlet_symbol(tp->tr_trackout, atmess->a_w.w_symbol); } tp->tr_atdelta = 0; tp->tr_ixnext = ixnext; if (tp->tr_restarted) return; tp->tr_restarted = wasrestarted; } } endoftrack: if (tp->tr_mode == MTR_PLAYMODE) tp->tr_ixnext = 0; /* CHECKED ready to go in step mode after play */ else { if (tp->tr_ixnext > 0) { t_atom at[2]; SETFLOAT(&at[0], tp->tr_id); SETFLOAT(&at[1], -1.); /* CHECKED eot marker */ outlet_list(tp->tr_mainout, 0, 2, at); } tp->tr_ixnext = -1; /* CHECKED no loop-over */ } tp->tr_atdelta = 0; tp->tr_prevtime = 0.; tp->tr_mode = MTR_STEPMODE; }
static void qlist_donext(t_qlist *x, int drop, int automatic) { t_pd *target = 0; while (1) { int argc = binbuf_getnatom(x->x_binbuf), count, onset = x->x_onset, onset2, wasreentered; t_atom *argv = binbuf_getvec(x->x_binbuf); t_atom *ap = argv + onset, *ap2; if (onset >= argc) goto end; while (ap->a_type == A_SEMI || ap->a_type == A_COMMA) { if (ap->a_type == A_SEMI) target = 0; onset++, ap++; if (onset >= argc) goto end; } if (!target && ap->a_type == A_FLOAT) { ap2 = ap + 1; onset2 = onset + 1; while (onset2 < argc && ap2->a_type == A_FLOAT) onset2++, ap2++; x->x_onset = onset2; if (automatic) { clock_delay(x->x_clock, x->x_clockdelay = ap->a_w.w_float * x->x_tempo); x->x_whenclockset = clock_getsystime(); } else outlet_list(x->x_ob.ob_outlet, 0, onset2-onset, ap); return; } ap2 = ap + 1; onset2 = onset + 1; while (onset2 < argc && (ap2->a_type == A_FLOAT || ap2->a_type == A_SYMBOL)) onset2++, ap2++; x->x_onset = onset2; count = onset2 - onset; if (!target) { if (ap->a_type != A_SYMBOL) continue; else if (!(target = ap->a_w.w_symbol->s_thing)) { pd_error(x, "qlist: %s: no such object", ap->a_w.w_symbol->s_name); continue; } ap++; onset++; count--; if (!count) { x->x_onset = onset2; continue; } } wasreentered = x->x_reentered; x->x_reentered = 0; if (!drop) { if (ap->a_type == A_FLOAT) typedmess(target, &s_list, count, ap); else if (ap->a_type == A_SYMBOL) typedmess(target, ap->a_w.w_symbol, count-1, ap+1); } if (x->x_reentered) return; x->x_reentered = wasreentered; } /* while (1); never falls through */ end: x->x_onset = 0x7fffffff; outlet_bang(x->x_bangout); x->x_whenclockset = 0; }
void thresh_bang(t_thresh *x) { if (x->t_ac) outlet_list(x->t_out,ps_list,x->t_ac,x->t_av); x->t_ac = 0; }
// LIST INPUT: STRAIGHT TO OVERFLOW void oscroute_list(t_oscroute *x, t_symbol *msg, long argc, t_atom *argv) { outlet_list(x->outlet_overflow, _sym_list, argc , argv); }
void a_bang(t_toascii *x) { t_atom *outlist; outlist = x->a_outlist; outlet_list(x->a_out, 0L, x->a_len, outlist); }
void meter_output(t_meter *x) { for(int i = 0; i < x->f_meter->getNumberOfChannels(); i++) atom_setfloat(x->f_peaks+i, fabs(x->f_meter->getChannelPeak(i))); outlet_list(x->f_outlet, gensym("list"), x->f_meter->getNumberOfChannels(), x->f_peaks); }
void hoa_in_list(t_hoa_in *x, t_symbol *s, short argc, t_atom *argv) { outlet_list(x->out, s, argc, argv); }
static void pre_inlet_list(t_pre_inlet *x, t_symbol *s, int ac, t_atom *av) { outlet_anything(x->x_obj.ob_outlet, x->x_sym, 1, &x->x_at); outlet_list(x->x_obj.ob_outlet, s, ac, av); }
void pitch_tick_G4(t_pitch *x) { t_int halfFFTSize = x->FFTSize/2; t_float FsOverFFTSize = x->x_Fs/((t_float)x->FFTSize); t_pitchhist *ph; t_int i; // Zero padding for (i=x->BufSize; i<x->FFTSize; i++) x->BufFFT[i] = 0.0f; // Window the samples if (x->x_window != Recta) for (i=0; i<x->BufSize; ++i) x->BufFFT[i] *= x->WindFFT[i]; // Look at the real signal as an interleaved complex vector by casting it. // Then call the transformation function ctoz to get a split complex vector, // which for a real signal, divides into an even-odd configuration. ctoz ((COMPLEX *) x->BufFFT, 2, &x->x_A, 1, x->x_FFTSizeOver2); // Carry out a Forward FFT transform fft_zrip(x->x_setup, &x->x_A, 1, x->x_log2n, FFT_FORWARD); // Fast rescaling required // vsmul( x->x_A.realp, 1, &x->x_scaleFactor, x->x_A.realp, 1, x->x_FFTSizeOver2); // vsmul( x->x_A.imagp, 1, &x->x_scaleFactor, x->x_A.imagp, 1, x->x_FFTSizeOver2); // The output signal is now in a split real form. Use the function // ztoc to get a split real vector. ztoc ( &x->x_A, 1, (COMPLEX *) x->BufFFT, 2, x->x_FFTSizeOver2); // Squared Absolute for (i=0; i<x->FFTSize; i+=2) x->BufPower[i/2] = (x->BufFFT[i] * x->BufFFT[i]) + (x->BufFFT[i+1] * x->BufFFT[i+1]); // Go into fiddle~ code pitch_getit(x); // Output results if (x->x_npeakout) { // Output peaks t_peakout *po; for (i=0, po=x->peakBuf; i<x->x_npeakout; i++, po++) { t_atom at[3]; atom_setlong(at, i+1); atom_setfloat(at+1, po->po_freq); atom_setfloat(at+2, po->po_amp); outlet_list(x->x_peakout, 0, 3, at); } } // Output amplitude outlet_float(x->x_envout, x->x_dbs[x->x_histphase]); // Output fundamental frequencies + amplitudes if (x->x_npitch > 1) { for (i=0, ph=x->x_hist; i<x->x_npitch; i++, ph++) { t_atom at[3]; atom_setlong(at, i+1); atom_setfloat(at+1, ph->h_pitches[x->x_histphase]); atom_setfloat(at+2, ph->h_amps[x->x_histphase]); outlet_list(x->x_pitchout, 0, 3, at); } } else { for (i=0, ph=x->x_hist; i<x->x_npitch; i++, ph++) { t_atom at[2]; atom_setfloat(at, ph->h_pitches[x->x_histphase]); atom_setfloat(at+1, ph->h_amps[x->x_histphase]); outlet_list(x->x_pitchout, 0, 2, at); } } // Output cooked MIDI/Frequency pitch if (x->x_npitch > 1) { for (i=0, ph=x->x_hist; i<x->x_npitch; i++, ph++) if (ph->h_pitch) { t_atom at[3]; atom_setlong(at, i+1); atom_setfloat(at+1, ph->h_pitch); atom_setfloat(at+2, mtof(ph->h_pitch)); outlet_list(x->x_noteout, 0, 3, at); } } else { ph = x->x_hist; if (ph->h_pitch) { t_atom at[2]; atom_setfloat(at, ph->h_pitch); atom_setfloat(at+1, mtof(ph->h_pitch)); outlet_list(x->x_noteout, 0, 2, at); } } // Output attack bang if (x->x_attackvalue) outlet_bang(x->x_attackout); }
static void magSpec_tilde_bang(t_magSpec_tilde *x) { int i, j, window, windowHalf, bangSample; t_atom *listOut; t_sample *signal_R, *signal_I; t_float *windowFuncPtr; double currentTime; window = x->window; windowHalf = window*0.5; // create local memory listOut = (t_atom *)t_getbytes((windowHalf+1)*sizeof(t_atom)); signal_R = (t_sample *)t_getbytes(window*sizeof(t_sample)); signal_I = (t_sample *)t_getbytes((windowHalf+1)*sizeof(t_sample)); currentTime = clock_gettimesince(x->lastDspTime); bangSample = (int)(((currentTime/1000.0)*x->sr)+0.5); // round if (bangSample < 0) bangSample = 0; else if ( bangSample >= x->n ) bangSample = x->n - 1; // construct analysis window using bangSample as the end of the window for(i=0, j=bangSample; i<window; i++, j++) signal_R[i] = x->signal_R[j]; // set window function windowFuncPtr = x->hann; //default case to get rid of compile warning switch(x->windowFunction) { case 0: break; case 1: windowFuncPtr = x->blackman; break; case 2: windowFuncPtr = x->cosine; break; case 3: windowFuncPtr = x->hamming; break; case 4: windowFuncPtr = x->hann; break; default: break; }; // if windowFunction == 0, skip the windowing (rectangular) if(x->windowFunction>0) for(i=0; i<window; i++, windowFuncPtr++) signal_R[i] *= *windowFuncPtr; mayer_realfft(window, signal_R); tIDLib_realfftUnpack(window, windowHalf, signal_R, signal_I); tIDLib_power(windowHalf+1, signal_R, signal_I); if(!x->powerSpectrum) tIDLib_mag(windowHalf+1, signal_R); if(x->normalize) tIDLib_normal(windowHalf+1, signal_R); for(i=0; i<=windowHalf; i++) SETFLOAT(listOut+i, signal_R[i]); outlet_list(x->x_mag, 0, windowHalf+1, listOut); // free local memory t_freebytes(listOut, (windowHalf+1)*sizeof(t_atom)); t_freebytes(signal_R, window*sizeof(t_sample)); t_freebytes(signal_I, (windowHalf+1)*sizeof(t_sample)); }
void pitch_tick(t_pitch *x) { t_int halfFFTSize = x->FFTSize/2; t_float FsOverFFTSize = x->x_Fs/((t_float)x->FFTSize); t_pitchhist *ph; t_int i; // Zero padding for (i=x->BufSize; i<x->FFTSize; i++) x->BufFFT[i] = 0.0f; // Window the samples if (x->x_window != Recta) for (i=0; i<x->BufSize; ++i) x->BufFFT[i] *= x->WindFFT[i]; // FFT fftRealfast(x->FFTSize, x->BufFFT, x->memFFT); // Squared Absolute for (i=0; i<x->FFTSize; i+=2) x->BufPower[i/2] = (x->BufFFT[i] * x->BufFFT[i]) + (x->BufFFT[i+1] * x->BufFFT[i+1]); // Go into fiddle~ code pitch_getit(x); // Output results if (x->x_npeakout) { // Output peaks t_peakout *po; for (i=0, po=x->peakBuf; i<x->x_npeakout; i++, po++) { t_atom at[3]; atom_setlong(at, i+1); atom_setfloat(at+1, po->po_freq); atom_setfloat(at+2, po->po_amp); outlet_list(x->x_peakout, 0, 3, at); } } // Output amplitude outlet_float(x->x_envout, x->x_dbs[x->x_histphase]); // Output fundamental frequencies + amplitudes if (x->x_npitch > 1) { for (i=0, ph=x->x_hist; i<x->x_npitch; i++, ph++) { t_atom at[3]; atom_setlong(at, i+1); atom_setfloat(at+1, ph->h_pitches[x->x_histphase]); atom_setfloat(at+2, ph->h_amps[x->x_histphase]); outlet_list(x->x_pitchout, 0, 3, at); } } else { for (i=0, ph=x->x_hist; i<x->x_npitch; i++, ph++) { t_atom at[2]; atom_setfloat(at, ph->h_pitches[x->x_histphase]); atom_setfloat(at+1, ph->h_amps[x->x_histphase]); outlet_list(x->x_pitchout, 0, 2, at); } } // Output cooked MIDI/Frequency pitch if (x->x_npitch > 1) { for (i=0, ph=x->x_hist; i<x->x_npitch; i++, ph++) if (ph->h_pitch) { t_atom at[3]; atom_setlong(at, i+1); atom_setfloat(at+1, ph->h_pitch); atom_setfloat(at+2, mtof(ph->h_pitch)); outlet_list(x->x_noteout, 0, 3, at); } } else { ph = x->x_hist; if (ph->h_pitch) { t_atom at[2]; atom_setfloat(at, ph->h_pitch); atom_setfloat(at+1, mtof(ph->h_pitch)); outlet_list(x->x_noteout, 0, 2, at); } } // Output attack bang if (x->x_attackvalue) outlet_bang(x->x_attackout); }
///////////////////////////////////////////////////////// // trigger // ///////////////////////////////////////////////////////// void pix_data :: trigger() { // if we don't have a "right hand" image, then just return if (!m_pixRight || !m_pixRight->image.data) { return; } t_float red, green, blue, alpha, grey; t_float maxX= m_pixRight->image.xsize; t_float maxY= m_pixRight->image.ysize; t_float fxPos = m_position[0] * maxX; t_float fyPos = m_position[1] * maxY; if(fxPos<0) { fxPos=0; } if(fxPos>=maxX-1) { fxPos=maxX-1; } if(fyPos<0) { fyPos=0; } if(fyPos>=maxY-1) { fyPos=maxY-1; } int ixPos0 = 0+static_cast<int>(fxPos); int iyPos0 = 0+static_cast<int>(fyPos); switch(m_quality) { default: { int ixPos1 = 1+static_cast<int>(fxPos); int iyPos1 = 1+static_cast<int>(fyPos); if(ixPos1>=maxX-1) { ixPos1=ixPos0; } if(iyPos1>=maxY-1) { iyPos1=iyPos0; } t_float xFrac = fxPos - ixPos0; t_float yFrac = fyPos - iyPos0; unsigned char r[2][2], g[2][2], b[2][2], a[2][2], G[2][2]; m_pixRight->image.getRGB(ixPos0, iyPos0, &r[0][0], &g[0][0], &b[0][0], &a[0][0]); m_pixRight->image.getRGB(ixPos1, iyPos0, &r[1][0], &g[1][0], &b[1][0], &a[1][0]); m_pixRight->image.getRGB(ixPos0, iyPos1, &r[0][1], &g[0][1], &b[0][1], &a[0][1]); m_pixRight->image.getRGB(ixPos1, iyPos1, &r[1][1], &g[1][1], &b[1][1], &a[1][1]); m_pixRight->image.getGrey(ixPos0, iyPos0, &G[0][0]); m_pixRight->image.getGrey(ixPos1, iyPos0, &G[1][0]); m_pixRight->image.getGrey(ixPos0, iyPos1, &G[0][1]); m_pixRight->image.getGrey(ixPos1, iyPos1, &G[1][1]); t_float xy00=(1-xFrac)*(1-yFrac); t_float xy01=(1-xFrac)* yFrac ; t_float xy10= xFrac *(1-yFrac); t_float xy11= xFrac * yFrac ; #define BILIN4(x) (xy00*x[0][0] + xy01*x[0][1] + xy10*x[1][0] + xy11*x[1][1]) red = BILIN4(r) / 255.; green = BILIN4(g) / 255.; blue = BILIN4(b) / 255.; alpha = BILIN4(a) / 255.; grey = BILIN4(G) / 255.; } break; case 0: { unsigned char r, g, b, a, G; m_pixRight->image.getRGB(ixPos0, iyPos0, &r, &g, &b, &a); m_pixRight->image.getGrey(ixPos0, iyPos0, &G); #define NONLIN(x) (x) red = NONLIN(r) / 255.; green = NONLIN(g) / 255.; blue = NONLIN(b) / 255.; alpha = NONLIN(a) / 255.; grey = NONLIN(G) / 255.; } break; } t_atom atom[4]; // send out the color information outlet_float(m_grayOut, grey); SETFLOAT(&atom[0], red); SETFLOAT(&atom[1], green); SETFLOAT(&atom[2], blue); SETFLOAT(&atom[3], alpha); outlet_list(m_colorOut, gensym("list"), 4, atom); }
static t_int *lms2_tilde_perform(t_int *w) { t_sample *x_ = (t_sample *)(w[1]); t_sample *d_ = (t_sample *)(w[2]); t_sample *y_ = (t_sample *)(w[3]); t_sample *e_ = (t_sample *)(w[4]); int n = (int)(w[5]); t_lms2_tilde *x = (t_lms2_tilde *)(w[6]); int i, j, tmp; for(i=0; i<n; i++) { // calc output (filter) x->y_tmp[i]=0; // y_[i] += x->c[j] * x_[i-j]; // so lets split in two halfs, so that // negative indezes get samples from the // last audioblock (x->buf) ... tmp = (i+1 - x->N)*(-1); tmp = tmp<0 ? 0 : tmp; for(j=0; j<x->N-tmp; j++) x->y_tmp[i] += x->c[j] * x_[i-j]; for(j=x->N-tmp; j<x->N; j++) x->y_tmp[i] += x->c[j] * x->buf[(i-j)*(-1)-1]; if(x->adapt) { // error computation x->e_tmp[i] = d_[i] - x->y_tmp[i]; // coefficient adaptation // (split in the same way as above) for(j=0; j<x->N-tmp; j++) x->c[j] = x->c[j] + x->mu * x_[i-j] * x->e_tmp[i]; for(j=x->N-tmp; j<x->N; j++) x->c[j] = x->c[j] + x->mu * x->buf[(i-j)*(-1)-1] * x->e_tmp[i]; } else x->e_tmp[i] = 0; //post("%d: in %f, d: %f, out: %f, e: %f, c1:%f, c2:%f", i, x_[i], d_[i], x->y_tmp[i], x->e_tmp[i], x->c[0], x->c[1]); } // outlet coefficients for(i=0; i<x->N; i++) SETFLOAT(&x->coef[i],x->c[i]); outlet_list(x->c_out, &s_list, x->N, x->coef); // store last samples for next audiobuffer for(i=0; i<x->N-1; i++) x->buf[i] = x_[n-1-i]; // now write tmps to outlets while(n--) { y_[n] = x->y_tmp[n]; e_[n] = x->e_tmp[n]; } return (w+7); }
static void vvplus_lst(t_vvplus *x, t_symbol *s, int argc, t_atom *argv) { t_float *fp; t_atom *ap; int n; if (argc){ if (x->n1 != argc) { freebytes(x->buf1, x->n1 * sizeof(t_float)); x->n1 = argc; x->buf1=(t_float *)getbytes(sizeof(t_float)*x->n1); }; fp = x->buf1; while(argc--)*fp++=atom_getfloat(argv++); } if (x->n1*x->n2==1){ outlet_float(x->x_obj.ob_outlet, *x->buf1+*x->buf2); return; } if (x->n1==1){ t_atom *a; int i = x->n2; t_float f = *x->buf1; fp = x->buf2; n = x->n2; ap = (t_atom *)getbytes(sizeof(t_atom)*n); a = ap; while(i--){ SETFLOAT(a, *fp+++f); a++; } } else if (x->n2==1){ t_float f = *x->buf2; t_atom *a; int i = x->n1; n = x->n1; ap = (t_atom *)getbytes(sizeof(t_atom)*n); a = ap; fp = x->buf1; while(i--){ SETFLOAT(a, *fp+++f); a++; } } else { t_atom *a; int i; t_float *fp2=x->buf2; fp = x->buf1; n = x->n1; if (x->n1!=x->n2){ post("scalar multiplication: truncating vectors to the same length"); if (x->n2<x->n1)n=x->n2; } ap = (t_atom *)getbytes(sizeof(t_atom)*n); a = ap; i=n; while(i--){ SETFLOAT(a, *fp+++*fp2++); a++; } } outlet_list(x->x_obj.ob_outlet, gensym("list"), n, ap); freebytes(ap, sizeof(t_atom)*n); }
// The Big Beef void proximity_coords(t_proximity *x, double xin, double yin) { long i, j;//,j,k,n,maxsize; float tempx, tempy, sum = 100000; float xdifs[250]; float ydifs[250]; t_atom outlist[250]; void *matrix; long dimcount,dim[JIT_MATRIX_MAX_DIMCOUNT]; long in_savelock; t_jit_matrix_info in_minfo; char *in_bp; long coors[2]; coors[0] = xin; coors[1] = yin; // Store a pointer to the specified matrix object matrix = jit_object_findregistered(x->name); // CALCULATION LOOP (assuming the matrix is valid and has data) if (matrix&&jit_object_method(matrix, _sym_class_jit_matrix)){ in_savelock = (long) jit_object_method(matrix,_sym_lock,1); jit_object_method(matrix,_sym_getinfo,&in_minfo); jit_object_method(matrix,_sym_getdata,&in_bp); // ERROR HANDLING FOR DATALESS MATRICES if (!in_bp) { //jit_error_sym(x, gensym("err_calculate")); jit_object_method(matrix, _sym_lock,in_savelock); goto out; } // get dimensions/planecount/etc. dimcount = in_minfo.dimcount; for (i=0;i<dimcount;i++) { dim[i] = in_minfo.dim[i]; } // ************************************ // DO IT! for(i=0; i < dim[1]; i++){ // for the y size of the data matrix tempx = JIT_2D_GET_FLOAT32(in_bp, &in_minfo, 0, 0, i); tempy = JIT_2D_GET_FLOAT32(in_bp, &in_minfo, 0, 1, i); xdifs[i] = fabs(coors[0] - tempx); ydifs[i] = fabs(coors[1] - tempy); } for(j=0; j<i; j++){ if((xdifs[j] + ydifs[j]) < sum){ sum = xdifs[j] + ydifs[j]; atom_setlong(&(outlist[0]),j+1); atom_setfloat(&(outlist[1]), JIT_2D_GET_FLOAT32(in_bp, &in_minfo, 0, 0, j)); atom_setfloat(&(outlist[2]), JIT_2D_GET_FLOAT32(in_bp, &in_minfo, 0, 1, j)); } } outlet_list(x->outlet[0], 0L, 3, &outlist[0]); // ************************************ jit_object_method(matrix, _sym_lock,in_savelock); } else{ //jit_error_sym(x, gensym("err_calculate")); } out: return; }
static void oscparse_list(t_oscparse *x, t_symbol *s, int argc, t_atom *argv) { int i, j, j2, k, outc = 1, blob = 0, typeonset, dataonset, nfield; t_atom *outv; if (!argc) return; for (i = 0; i < argc; i++) if (argv[i].a_type != A_FLOAT) { pd_error(x, "oscparse: takes numbers only"); return; } if (argv[0].a_w.w_float == '#') /* it's a bundle */ { if (argv[1].a_w.w_float != 'b' || argc < 16) { pd_error(x, "oscparse: malformed bundle"); return; } /* we ignore the timetag since there's no correct way to convert it to Pd logical time that I can think of. LATER consider at least outputting timetag differentially converted into Pd time units. */ for (i = 16; i < argc-4; ) { int msize = READINT(argv+i); if (msize <= 0 || msize & 3) { pd_error(x, "oscparse: bad bundle element size"); return; } oscparse_list(x, 0, msize, argv+i+4); i += msize+4; } return; } else if (argv[0].a_w.w_float != '/') { pd_error(x, "oscparse: not an OSC message (no leading slash)"); return; } for (i = 1; i < argc && argv[i].a_w.w_float != 0; i++) if (argv[i].a_w.w_float == '/') outc++; i = ROUNDUPTO4(i+1); if (argv[i].a_w.w_float != ',' || (i+1) >= argc) { pd_error(x, "oscparse: malformed type string (char %d, index %d)", (int)(argv[i].a_w.w_float), i); return; } typeonset = ++i; for (; i < argc && argv[i].a_w.w_float != 0; i++) if (argv[i].a_w.w_float == 'b') blob = 1; nfield = i - typeonset; if (blob) outc += argc - typeonset; else outc += nfield; outv = (t_atom *)alloca(outc * sizeof(t_atom)); dataonset = ROUNDUPTO4(i + 1); /* post("outc %d, typeonset %d, dataonset %d, nfield %d", outc, typeonset, dataonset, nfield); */ for (i = j = 0; i < typeonset-1 && argv[i].a_w.w_float != 0 && j < outc; j++) SETSYMBOL(outv+j, grabstring(argc, argv, &i, 1)); for (i = typeonset, k = dataonset; i < typeonset + nfield; i++) { union { float z_f; uint32_t z_i; } z; float f; int blobsize; switch ((int)(argv[i].a_w.w_float)) { case 'f': if (k > argc - 4) goto tooshort; z.z_i = READINT(argv+k); f = z.z_f; if (PD_BADFLOAT(f)) f = 0; if (j >= outc) { bug("oscparse 1: %d >=%d", j, outc); return; } SETFLOAT(outv+j, f); j++; k += 4; break; case 'i': if (k > argc - 4) goto tooshort; if (j >= outc) { bug("oscparse 2"); return; } SETFLOAT(outv+j, READINT(argv+k)); j++; k += 4; break; case 's': if (j >= outc) { bug("oscparse 3"); return; } SETSYMBOL(outv+j, grabstring(argc, argv, &k, 0)); j++; break; case 'b': if (k > argc - 4) goto tooshort; blobsize = READINT(argv+k); k += 4; if (blobsize < 0 || blobsize > argc - k) goto tooshort; if (j + blobsize + 1 > outc) { bug("oscparse 4"); return; } if (k + blobsize > argc) goto tooshort; SETFLOAT(outv+j, blobsize); j++; for (j2 = 0; j2 < blobsize; j++, j2++, k++) SETFLOAT(outv+j, argv[k].a_w.w_float); k = ROUNDUPTO4(k); break; default: pd_error(x, "oscparse: unknown tag '%c' (%d)", (int)(argv[i].a_w.w_float), (int)(argv[i].a_w.w_float)); } } outlet_list(x->x_obj.ob_outlet, 0, j, outv); return; tooshort: pd_error(x, "oscparse: OSC message ended prematurely"); }
static void xeqithook_stepdelay(t_xeqit *it, int argc, t_atom *argv) { t_xeq *x = (t_xeq *)it->i_owner; outlet_list(((t_object *)x)->ob_outlet, 0, argc, argv); }