/**@public @memberof t_OMax_learn * @brief Bind the learner with FO and Data Sequence */ bool OMax_learn_bind(t_OMax_learn *x) { ///@remarks Do this binding only once if (x->obound == FALSE) { ///@details Check if FO name points to an existing @link t_OMax_oracle OMax.oracle @endlink object. If so, binds t_OMax_learn::oname with the actual FO structure (t_OMax_oracle::oracle member). if ((x->oname->s_thing) && (ob_sym(x->oname->s_thing) == gensym("OMax.oracle"))) { x->builder.set_oracle((((t_OMax_oracle*)(x->oname->s_thing))->oracle)); object_post((t_object *)x,"Learner bound to Oracle %s", x->oname->s_name); } else { object_error((t_object *)x,"No oracle %s declared", x->oname->s_name); } /// Do the same for Data Sequence with member t_OMax_learn::dataname and the related @link t_OMax_data OMax.data @endlink object. if ((x->dataname->s_thing) && (ob_sym(x->dataname->s_thing) == gensym("OMax.data"))) { x->builder.set_data((((t_OMax_data*)(x->dataname->s_thing))->data)); x->obound = TRUE; x->datatype = ((t_OMax_data*)(x->dataname->s_thing))->datatype; if (x->datatype == SPECTRAL) x->nbcoeffs = ((t_OMax_data*)(x->dataname->s_thing))->nbcoeffs; ((t_OMax_data*)(x->dataname->s_thing))->noDelete = FALSE; object_post((t_object *)x,"Learner bound to Data of Oracle %s", x->oname->s_name); } else { object_error((t_object *)x,"No data for oracle %s declared", x->oname->s_name); } } // If binding is ok, then don't do it next time. return x->obound; }
static void LookupMyBuffer(SDIFlistpoke *x) { #ifdef THE_S_THING_KLUDGE void *thing; thing = x->t_bufferSym->s_thing; if (thing) { if (ob_sym(thing) = ps_SDIFbuffer) { x->t_buffer = thing; return; } } x->t_buffer = 0; #else SDIFBufferLookupFunction f; f = (SDIFBufferLookupFunction) ps_SDIF_buffer_lookup->s_thing; if (f == 0) { /* No SDIF buffer has ever been created yet. */ x->t_buffer = 0; } else { x->t_buffer = (*f)(x->t_bufferSym); } #endif // get access to the SDIFbuf_Buffer instance if (x->t_buffer) x->t_buf = (x->t_buffer->BufferAccessor)(x->t_buffer); else x->t_buf = NULL; }
void simpwave_dblclick(t_simpwave *x) { t_buffer *b; if ((b = (t_buffer *)(x->w_name->s_thing)) && ob_sym(b) == ps_buffer) mess0((struct object *)b,gensym("dblclick")); }
t_max_err buffer_set(t_HoaConvolve *x, t_object *attr, long argc, t_atom *argv) { t_buffer *b; t_symbol *name; t_atom channel[1]; if(argc && argv && atom_gettype(argv) == A_SYM) { if(argc > x->f_numberOfHarmonics) argc = x->f_numberOfHarmonics; name = atom_getsym(argv); if(x->f_name != name) { if ((b = (t_buffer *)(name->s_thing)) && ob_sym(b) == gensym("buffer~")) { if(x->f_name && x->f_buffer != NULL) { globalsymbol_dereference((t_object*)x, x->f_name->s_name, "buffer~"); } x->f_name = name; x->f_buffer = (t_buffer*)globalsymbol_reference((t_object*)x, x->f_name->s_name, "buffer~"); } else { x->f_buffer = NULL; x->f_name= gensym("none"); } } atom_setlong(channel, x->f_channel); channel_set(x, attr, 2, channel); } return 0; }
void HoaConvolve_dblclick(t_HoaConvolve *x) { t_buffer *b; if ((b = (t_buffer *)(x->f_name->s_thing)) && ob_sym(b) == gensym("buffer~")) mess0((t_object *)b,gensym("dblclick")); }
// this lets us double-click on index~ to open up the buffer~ it references void index_dblclick(t_index *x) { t_buffer *b; if ((b = (t_buffer *)(x->l_sym->s_thing)) && ob_sym(b) == ps_buffer) mess0((t_object *)b,gensym("dblclick")); }
t_buffer_write_error buffer_write_float(t_symbol *buffer, float *in, AH_SIntPtr write_length, long resize, long chan, double sample_rate, float mul) { AH_SIntPtr length; long n_chans, format; void *samps; AH_SIntPtr i; float *samples; void *b = ibuffer_get_ptr(buffer); if (!b) return BUFFER_WRITE_ERR_NOT_FOUND; if (ob_sym(b) != ps_buffer) return BUFFER_WRITE_ERR_NOT_FOUND; if (!ibuffer_info(b, &samps, &length, &n_chans, &format)) return BUFFER_WRITE_ERR_INVALID; if (chan >= n_chans) return BUFFER_WRITE_ERR_CHANNEL_INVALID; if (resize) { t_atom temp_atom[2]; atom_setlong(temp_atom, write_length); object_method_typed ((t_object *)b, gensym("sizeinsamps"), 1L, temp_atom, temp_atom + 1); ibuffer_info(b, &samps, &length, &n_chans, &format); } if (length < write_length) return BUFFER_WRITE_ERR_TOO_SMALL; ibuffer_increment_inuse(b); samples = (float *) samps; chan = chan % n_chans; for (i = 0; i < write_length; i++) samples[i * n_chans + chan] = in[i] * mul; if (!resize) for (i = write_length; i < length; i++) samples[i * n_chans + chan] = 0.f; if (sample_rate) { t_atom temp_atom[2]; atom_setfloat(temp_atom, sample_rate); object_method_typed ((t_object *)b, gensym("sr"), 1L, temp_atom, temp_atom + 1); } object_method ((t_object *)b, gensym("dirty")); ibuffer_decrement_inuse(b); return BUFFER_WRITE_ERR_NONE; }
void poki_dblclick(t_poki *x) { t_buffer *b; if ((b = (t_buffer *)(x->p_sym->s_thing)) && ob_sym(b) == ps_buffer) { mess0((t_object *)b, gensym("dblclick")); } }
void bvplay_dblclick(t_bvplay *x) { t_buffer *b; t_symbol *wavename = x->l_sym; if ((b = (t_buffer *)(wavename->s_thing)) && ob_sym(b) == gensym("buffer~")) mess0((t_object *)b,gensym("dblclick")); }
t_buffer *SymbolToBuffer(t_symbol *s) { t_buffer *b; if ((b = (t_buffer *)(s->s_thing)) && ob_sym(b) == ps_buffer) { return b; } else { return 0; } }
// msp arcana to extract t_buffer* from a t_symbol* t_buffer* _sym_to_buffer(t_symbol* s) { t_buffer *b; if ((b = (t_buffer *)(s->s_thing)) && ob_sym(b) == ps_buffer_tilde) { return b; } else { return 0; } }
void terrain_set(t_terrain *x, t_symbol *s) { t_buffer *b; x->l_sym = s; if ((b = (t_buffer *)(s->s_thing)) && ob_sym(b) == ps_buffer) { x->l_buf = b; } else { error("terrain~: no buffer~ %s", s->s_name); x->l_buf = 0; } }
void bvplay_set(t_bvplay *x, t_symbol *s) { t_buffer *b; x->l_sym = s; if ((b = (t_buffer *)(s->s_thing)) && ob_sym(b) == ps_buffer) { x->l_buf = b; } else { error("bvplay~: no buffer~ %s", s->s_name); x->l_buf = 0; } }
void simpwave_setup(t_simpwave *x, t_symbol *s, double sr) { t_buffer *b; if (sr) x->w_msr = sr * .001; if (s != ps_nothing) { if ((b = (t_buffer *)(s->s_thing)) && ob_sym(b) == ps_buffer) { simpwave_limits(x,b); x->w_buf = b; } else x->w_buf = 0; } else x->w_buf = 0; x->w_name = s; }
// here's where we set the buffer~ we're going to access void index_set(t_index *x, t_symbol *s) { t_buffer *b; if (s) { x->l_sym = s; if ((b = (t_buffer *)(s->s_thing)) && ob_sym(b) == ps_buffer) { x->l_buf = b; } else { object_error((t_object *)x, "no buffer~ %s", s->s_name); x->l_buf = 0; } } else { // this will reappear every time the dsp is restarted; do we really want it? object_error((t_object *)x, "no buffer~ object specified"); } }
/* The object-specific methods ************************************************/ int bed_attach_buffer(t_bed *x) { t_object *o; o = x->b_name->s_thing; if (o == NULL) { post("bed • \"%s\" is not a valid buffer", x->b_name->s_name); return 0; } if (ob_sym(o) == gensym("buffer~")) { x->buffer = (t_buffer *)o; return 1; } else { return 0; } }
void poki_set(t_poki *x, t_symbol *s) { t_buffer *b; if (s) { x->p_sym = s; if ((b = (t_buffer *)(s->s_thing)) && ob_sym(b) == ps_buffer) { x->p_buf = b; } else { object_error((t_object *)x, "buffer not found", s->s_name); x->p_buf = 0; } } else { object_error((t_object *)x, "no buffer argument?"); } }
int vd_setdestbuf(t_vd *x, t_symbol *wavename) { t_buffer *b; if ((b = (t_buffer *)(wavename->s_thing)) && ob_sym(b) == gensym("buffer~")) { if( b->b_nchans > 1 ){ error("%s; wavetable must be a mono",OBJECT_NAME); return(0); } else { x->destbuf = b; return(1); } } else { error("%s: no such buffer~ %s",OBJECT_NAME, wavename->s_name); return(0); } }
int bed_attach_any_buffer(t_buffer **b, t_symbol *b_name) { t_object *o; o = b_name->s_thing; if (o == NULL) { return 0; } if (ob_sym(o) == gensym("buffer~")) { *b = (t_buffer *)o; if (*b == NULL) { post("bed • \"%s\" is not a valid buffer", b_name->s_name); return 0; } return 1; } else { post("bed • \"%s\" is not a valid buffer", b_name->s_name); return 0; } }
int vdb_attach_buffer(t_vdb *x) { t_buffer *b; t_symbol *wavename = x->buffername; if ((b = (t_buffer *)(wavename->s_thing)) && ob_sym(b) == gensym("buffer~")) { if(b->b_frames <= 0){ error("%s: zero length buffer~ %s",OBJECT_NAME, wavename->s_name); x->b_valid = 0; return(0); } /* if(x->b_frames != b->b_frames){ post("updating buffer sIze from %d to %d",x->b_frames, b->b_frames); } */ x->delay_buffer = b; x->b_nchans = b->b_nchans; x->b_frames = b->b_frames; x->b_samples = b->b_samples; x->b_valid = b->b_valid; x->len = x->b_frames; if(x->maxdelay_len > x->len){ x->maxdelay_len = x->len; post("%s: shortened maxdelay to %d frames",OBJECT_NAME,x->maxdelay_len); } return(1); } else { error("%s: no such buffer~ %s",OBJECT_NAME, wavename->s_name); return(0); } }