void smoov_float(t_smoov *x, double f) { t_atom av; atom_setfloat(&av,f); smoov_set(x,NULL,1,&av); smoov_bang(x); }
void iter_float(t_iter *x, double f) { iter_resize(x,1); x->i_ac = 1; atom_setfloat(x->i_av,f); outlet_float(x->i_ob.o_outlet,f); }
MaxErr OpGetOperand(OpPtr self, ObjectPtr attr, AtomCount* argc, AtomPtr* argv) { TTValue v; self->audioGraphObject->getUnitGenerator()->getAttributeValue(TT("operand"), v); *argc = v.getSize(); if (!(*argv)) // otherwise use memory passed in *argv = (t_atom *)sysmem_newptr(sizeof(t_atom) * v.getSize()); for (int i=0; i<v.getSize(); i++) { if(v.getType(i) == kTypeFloat32 || v.getType(i) == kTypeFloat64){ TTFloat64 value; v.get(i, value); atom_setfloat(*argv+i, value); } else if(v.getType(i) == kTypeSymbol){ TTSymbol value; v.get(i, value); atom_setsym(*argv+i, gensym((char*)value.c_str())); } else{ // assume int TTInt32 value; v.get(i, value); atom_setlong(*argv+i, value); } } return MAX_ERR_NONE; }
static void featureMean_length(t_featureMean *x, int len) { int i, j; if(len) { x->x_listOut = (t_atom *)t_resizebytes_(x->x_listOut, x->featureLength*sizeof(t_atom), len*sizeof(t_atom)); // free the database memory for(i=0; i<x->numFrames; i++) t_freebytes_(x->instances[i].instance, x->featureLength*sizeof(float)); t_freebytes_(x->instances, x->numFrames*sizeof(t_instance)); x->instances = (t_instance *)t_getbytes_(x->numFrames*sizeof(t_instance)); x->featureLength = len; x->currentFrame = 0; for(i=0; i<x->featureLength; i++) atom_setfloat(x->x_listOut+i, 0.0); for(i=0; i<x->numFrames; i++) x->instances[i].instance = (float *)t_getbytes_(x->featureLength*sizeof(float)); for(i=0; i<x->numFrames; i++) for(j=0; j<x->featureLength; j++) x->instances[i].instance[j] = 0.0; } }
void map_float(TTPtr self, double value) { t_atom a; atom_setfloat(&a, value); map_list(self, _sym_float, 1, &a); }
void send_float(t_send *x, double value) { t_atom a; atom_setfloat(&a, value); send_list(x, _sym_float, 1, &a); }
void radio_output(t_radio *x) { int i; t_atom av[256]; if(x->f_mode) { for(i = 0; i < x->f_nitems; i++) atom_setfloat(av+i, (float)x->f_items[i]); outlet_list(x->f_out, &s_list, x->f_nitems, av); if(ebox_getsender((t_ebox *) x)) pd_list(ebox_getsender((t_ebox *) x), &s_list, x->f_nitems, av); } else { for(i = 0; i < x->f_nitems; i++) { if(x->f_items[i] != 0) { outlet_float(x->f_out, (float)i); if(ebox_getsender((t_ebox *) x)) pd_float(ebox_getsender((t_ebox *) x), (float)i); } } } }
void hoa_space_rotate_points(t_hoa_space *x, t_object *patcherview, t_pt pt, long modifiers) { double loudspeaker_angle = CICM_2PI / (double)x->f_number_of_microphones; double mapped_x = (pt.x - x->f_center.x) / x->f_center.x; double mapped_y = (pt.y - x->f_center.y) / x->f_center.y * -1.; double rotation = Tools::angle(mapped_x, mapped_y) - CICM_PI2; double offset = rotation - x->f_reference_angle; offset *= -1.; while(offset < 0.) offset += CICM_2PI; int nbDecalage = offset / loudspeaker_angle; double decimal = (offset - loudspeaker_angle * nbDecalage) / loudspeaker_angle; double newcoeff; int index1, index2; for(int i = 0; i < x->f_number_of_microphones; i++) { index1 = ((i + nbDecalage) + x->f_number_of_microphones) % x->f_number_of_microphones; index2 = ((i + 1 + nbDecalage) + x->f_number_of_microphones) % x->f_number_of_microphones; newcoeff = x->f_mode_values[index2] * decimal + x->f_mode_values[index1] * (1. - decimal); atom_setfloat(x->f_tempory_values+i ,newcoeff); } hoa_space_coefficients_set(x, NULL, x->f_number_of_microphones, x->f_tempory_values); hoa_space_output(x); }
void out_float(TTPtr self, t_float value) { t_atom a; atom_setfloat(&a, value); out_list(self, _sym_float, 1, &a); }
static void featureMean_accum(t_featureMean *x, t_symbol *s, int argc, t_atom *argv) { int i, j; float sum; if(x->featureLength != argc) error("featureMean: input length does not match current length setting. input ignored."); else for(i=0; i<x->featureLength; i++) x->instances[x->currentFrame].instance[i] = atom_getfloat(argv+i); x->currentFrame++; if (x->currentFrame==x->numFrames) { for(i=0; i<x->featureLength; i++) { sum = 0; for(j=0; j<x->currentFrame; j++) { sum = sum + x->instances[j].instance[i]; } sum = sum / x->currentFrame; atom_setfloat(x->x_listOut+i, sum); } outlet_list(x->featureList, 0, x->featureLength, x->x_listOut); x->currentFrame = (x->currentFrame==x->numFrames)?0:x->currentFrame; } }
void hoa_space_draw_points(t_hoa_space *x, t_object *patcherview, t_pt pt, long modifiers) { double loudspeaker_angle = CICM_2PI / (double)x->f_number_of_microphones; double loudspeaker_angle_mid = loudspeaker_angle / 2.; double mapped_x = (pt.x - x->f_center.x); double mapped_y = (pt.y - x->f_center.y); double angle = Tools::radian_wrap(Tools::angle(mapped_x, -mapped_y) - CICM_PI2); double radius = Tools::radius(mapped_x, mapped_y); if(radius < x->f_radius_circle) { if(angle > CICM_2PI - loudspeaker_angle_mid || angle < loudspeaker_angle_mid) atom_setfloat(x->f_tempory_values, 0.); else { for(int i = 1; i < x->f_number_of_microphones; i++) { if(angle > i * loudspeaker_angle - loudspeaker_angle_mid && angle < i * loudspeaker_angle + loudspeaker_angle_mid) atom_setfloat(x->f_tempory_values+i, 0.); } } } else { double center_x = Tools::abscissa(x->f_radius_circle, angle - CICM_PI2 + CICM_PI); mapped_x = mapped_x - center_x; double center_y = Tools::ordinate(x->f_radius_circle, angle - CICM_PI2 + CICM_PI); mapped_y = -mapped_y - center_y; double radius = Tools::radius(mapped_x, mapped_y) / (4. * x->f_radius_circle); if(angle > CICM_2PI - loudspeaker_angle_mid || angle < loudspeaker_angle_mid) atom_setfloat(x->f_tempory_values, radius); else { for(int i = 1; i < x->f_number_of_microphones; i++) { if(angle > i * loudspeaker_angle - loudspeaker_angle_mid && angle < i * loudspeaker_angle + loudspeaker_angle_mid) atom_setfloat(x->f_tempory_values+i, radius); } } } hoa_space_coefficients_set(x, NULL, x->f_number_of_microphones, x->f_tempory_values); hoa_space_output(x); }
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 MidiGainUnit::convertFromNeutral(long inputNumArgs, double *input, long *outputNumArgs, t_atom **outputAtoms) { *outputNumArgs = 1; // This is the old formula behaving the same as the gain~ object: // atom_setfloat(*outputAtoms, log10(*input)*33.333333333333+127.); // Now substituted for: atom_setfloat(*outputAtoms, 100.*pow((*input),kGainMidiPowerInv)); }
void send_configuration(t_hoa_decoder *x) { t_object *patcher; t_object *decoder; t_object *object; t_object *line; t_max_err err; if(!x->f_send_config) return; err = object_obex_lookup(x, gensym("#P"), (t_object **)&patcher); if (err != MAX_ERR_NONE) return; err = object_obex_lookup(x, gensym("#B"), (t_object **)&decoder); if (err != MAX_ERR_NONE) return; t_atom nchannels; t_atom offset; t_atom *argv = new t_atom[x->f_decoder->getNumberOfChannels()]; atom_setlong(&nchannels, x->f_decoder->getNumberOfChannels()); atom_setfloat(&offset, x->f_decoder->getChannelsOffset() / HOA_2PI * 360.); for(int i = 0; i < x->f_decoder->getNumberOfChannels(); i++) atom_setfloat(argv+i, x->f_decoder->getChannelAzimuth(i) / HOA_2PI * 360.); for (line = jpatcher_get_firstline(patcher); line; line = jpatchline_get_nextline(line)) { if (jpatchline_get_box1(line) == decoder) { object = jpatchline_get_box2(line); t_symbol* classname = object_classname(jbox_get_object(object)); if(classname == gensym("hoa.2d.meter~") || classname == gensym("hoa.meter~") || classname == gensym("hoa.2d.vector~")) { object_method_typed(jbox_get_object(object), gensym("channels"), 1, &nchannels, NULL); object_method_typed(jbox_get_object(object), gensym("angles"), x->f_decoder->getNumberOfChannels(), argv, NULL); object_method_typed(jbox_get_object(object), gensym("offset"), 1, &offset, NULL); } else if(classname == gensym("hoa.gain~")) object_method_typed(jbox_get_object(object), gensym("channels"), 1, &nchannels, NULL); } } free(argv); }
void SDIFranges_GetColumnRange(SDIFranges *x, long columnArg, t_symbol *matrixTypeSym) { char matrixType[4]; sdif_int32 numCols; int i; SDIFresult r; long column = columnArg -1; /* Max user numbers columns from 1; internally it's zero-origin. */ if (columnArg <= 0) { object_error((t_object *)x, NAME ": column_range: illegal column number %ld (must be >= 1)", columnArg); return; } if (!resolveBufferAndMatrixType(x, matrixTypeSym, matrixType)) { object_error((t_object *)x, "Couldn't resolve SDIF-buffer and/or matrix type."); return; } if (!doGetMaxNumColumns(x, matrixType, &numCols)) { object_error((t_object *)x, "Couldn't get max num columns"); } // post("* numCols %ld, want column %ld", numCols, column); if (column >= numCols) { error(NAME ": SDIF-buffer %s has only %ld columns; can't give column-range of column %ld", x->t_bufferSym->s_name, numCols, columnArg); return; } else { t_atom outputArgs[3]; sdif_float64 min, max; if (r = SDIFbuf_GetColumnRange(x->t_buf, matrixType, column, &min, &max)) { post("¥ %s: Couldn't get column range: %s", NAME, SDIF_GetErrorString(r)); return; } object_post((t_object *)x, "** min %f, max %f", (float) min, (float) max); atom_setlong(outputArgs, columnArg); atom_setfloat(outputArgs+1, (float) min); atom_setfloat(outputArgs+2, (float) max); outlet_anything(x->t_out, ps_column_range, 3, outputArgs); } }
// FLOATING POINT INPUT // on Windows this object only works if the argument is declared double? void pack_float(t_pack *x, double value) { long inletnum = proxy_getinlet((object *)x); atom_setfloat(&(x->mylist[inletnum]), value); if (x->triggerlist[(x->inletnum)] != 0) outlet_list(x->my_outlet, 0L, x->mylistlen, x->mylist); // output the result }
void maxpd_atom_set_float(t_atom *a, float d) { #ifdef MAXMSP atom_setfloat(a, d); #else SETFLOAT(a, d); #endif }
static t_pd_err plane_bounds_get(t_plane *x, t_object *attr, int* ac, t_atom **av) { *ac = 4; *av = (t_atom *)malloc(4 * sizeof(t_atom)); if(*av) { atom_setfloat(*av, ebox_parameter_getmin((t_ebox *)x, 1)); atom_setfloat(*av+1, ebox_parameter_getmin((t_ebox *)x, 2)); atom_setfloat(*av+2, ebox_parameter_getmax((t_ebox *)x, 1)); atom_setfloat(*av+3, ebox_parameter_getmax((t_ebox *)x, 2)); } else { *ac = 0; } return 0; }
void space_draw_points(t_space *x, t_object *patcherview, t_pt pt, long modifiers) { double loudspeaker_angle = CICM_2PI / (double)x->f_number_of_microphones; double loudspeaker_angle_mid = loudspeaker_angle / 2.; double mapped_x = (pt.x - x->f_center.x); double mapped_y = (pt.y - x->f_center.y); double angle = Tools::angle(mapped_x, -mapped_y) - CICM_PI2; if(angle < 0.) angle += CICM_2PI; if(Tools::radius(mapped_x, mapped_y) < x->f_rayonCircle) { if(angle > CICM_2PI - loudspeaker_angle_mid || angle < loudspeaker_angle_mid) atom_setfloat(x->f_tempory_values, 0.); else { for(int i = 1; i < x->f_number_of_microphones; i++) { if(angle > i * loudspeaker_angle - loudspeaker_angle_mid && angle < i * loudspeaker_angle + loudspeaker_angle_mid) atom_setfloat(x->f_tempory_values+i, 0.); } } } else { double center_x = Tools::abscisse(x->f_rayonCircle, angle - CICM_PI2 + CICM_PI); mapped_x = mapped_x - center_x; double center_y = Tools::ordinate(x->f_rayonCircle, angle - CICM_PI2 + CICM_PI); mapped_y = -mapped_y - center_y; double radius = Tools::radius(mapped_x, mapped_y) / (4. * x->f_rayonCircle); if(angle > CICM_2PI - loudspeaker_angle_mid || angle < loudspeaker_angle_mid) atom_setfloat(x->f_tempory_values, radius); else { for(int i = 1; i < x->f_number_of_microphones; i++) { if(angle > i * loudspeaker_angle - loudspeaker_angle_mid && angle < i * loudspeaker_angle + loudspeaker_angle_mid) atom_setfloat(x->f_tempory_values+i, radius); } } } object_method(x, gensym("coeffs"), x->f_number_of_microphones, x->f_tempory_values); }
void jsusfx_describe(t_jsusfx *x) { post("jsusfx~ script %s : %s", x->scriptname, x->fx->desc); for(int i=0;i<64;i++) { if ( x->fx->sliders[i].exists ) { Slider *s = &(x->fx->sliders[i]); post(" slider%d: %g %g %s", i, s->min, s->max, s->desc); t_atom argv[5]; atom_setlong(argv, i); atom_setfloat(argv+1, s->def); atom_setfloat(argv+2, s->min); atom_setfloat(argv+3, s->max); atom_setsym(argv+4, gensym(s->desc)); outlet_anything(x->outlet1, gensym("slider"), 4, argv); } } }
static void pak_float(t_pak *x, float f) { int index = eobj_getproxy((t_ebox *)x); if(x->f_selectors[index] == 0) { atom_setfloat(x->f_argv+index, f); pak_output(x); } }
void rd_output_all(t_rd *x){ int i; int n = (x->sinusoids ? (x->n * 2) : (x->n * 3)); t_atom buf[x->buffer_size]; for(i = 0; i < n; i++){ atom_setfloat(buf + i, x->buffer[i]); } outlet_list(x->outlet, NULL, n, buf); }
void match_float(t_match *x, double f) { t_atom a; atom_setfloat(&a, f); if (x->m_size) match_atom(x,&a); }
void thresh_float(t_thresh *x, double f) { if (x->t_ac < MAXSIZE - 1) { x->t_time = gettime(); atom_setfloat(x->t_av+x->t_ac,f); x->t_ac++; clock_delay(x->t_clock,x->t_interval); } }
// C Callback from any Graph Source objects we are observing void UnpackGraphCallback(UnpackPtr self, TTValue& arg) { TTDictionaryPtr aDictionary = NULL; TTValue v; long ac; t_atom* ap; TTBoolean firstItemASymbol = NO; TTSymbol firstItem; //arg.get(0, (TTPtr*)(&aDictionary)); aDictionary = (TTDictionaryPtr)(TTPtr)arg[0]; aDictionary->getValue(v); ac = v.size(); if (ac) { ap = new t_atom[ac]; for (int i=0; i<ac; i++) { if (v[i].type() == kTypeInt8 || v[i].type() == kTypeUInt8 || v[i].type() == kTypeInt16 || v[i].type() == kTypeUInt16 || v[i].type() == kTypeInt32 || v[i].type() == kTypeUInt32 || v[i].type() == kTypeInt64 || v[i].type() == kTypeUInt64) { TTInt32 ival; ival = v[i]; atom_setlong(ap+i, ival); } else if (v[i].type() == kTypeFloat32 || v[i].type() == kTypeFloat64) { atom_setfloat(ap+i, v[i]); } else if (v[i].type() == kTypeSymbol) { TTSymbol s; s = v[i]; atom_setsym(ap+i, gensym((char*)s.c_str())); if (i==0) { firstItemASymbol = YES; firstItem = s; } } } if (firstItemASymbol) outlet_anything(self->graphOutlets[0], gensym((char*)firstItem.c_str()), ac-1, ap+1); else if (ac == 1) outlet_float(self->graphOutlets[0], atom_getfloat(ap)); else outlet_anything(self->graphOutlets[0], _sym_list, ac, ap); delete ap; } }
// C Callback from any Graph Source objects we are observing void UnpackGraphCallback(UnpackPtr self, TTValue& arg) { TTDictionaryPtr aDictionary = NULL; TTValue v; AtomCount ac; AtomPtr ap; TTBoolean firstItemASymbol = NO; TTSymbolPtr firstItem = NULL; arg.get(0, (TTPtr*)(&aDictionary)); aDictionary->getValue(v); ac = v.getSize(); if (ac) { ap = new Atom[ac]; for (int i=0; i<ac; i++) { if (v.getType() == kTypeInt8 || v.getType() == kTypeUInt8 || v.getType() == kTypeInt16 || v.getType() == kTypeUInt16 || v.getType() == kTypeInt32 || v.getType() == kTypeUInt32 || v.getType() == kTypeInt64 || v.getType() == kTypeUInt64) { TTInt32 ival; v.get(i, ival); atom_setlong(ap+i, ival); } else if (v.getType() == kTypeFloat32 || v.getType() == kTypeFloat64) { atom_setfloat(ap+i, v.getFloat64(i)); } else if (v.getType() == kTypeSymbol) { TTSymbolPtr s; v.get(i, &s); atom_setsym(ap+i, gensym((char*)s->getCString())); if (i==0) { firstItemASymbol = YES; firstItem = s; } } } if (firstItemASymbol) outlet_anything(self->graphOutlets[0], gensym((char*)firstItem->getCString()), ac-1, ap+1); else if (ac == 1) outlet_float(self->graphOutlets[0], atom_getfloat(ap)); else outlet_anything(self->graphOutlets[0], _sym_list, ac, ap); delete ap; } }
void hoa_space_output(t_hoa_space *x) { for(int i = 0; i < x->f_number_of_microphones; i++) atom_setfloat(x->f_tempory_values+i, x->f_microphonesValues[i]); outlet_list(x->f_out, 0L, x->f_number_of_microphones, x->f_tempory_values); jbox_invalidate_layer((t_object *)x, NULL, gensym("harmonics_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("microphones_layer")); jbox_redraw((t_jbox *)x); }
void prepend_float(t_prepend *x, float f) { if(x->f_argc < 256) { atom_setfloat(x->f_argv+x->f_argc, f); outlet_anything(x->f_out, x->f_selector, x->f_argc + 1, x->f_argv); } else outlet_anything(x->f_out, x->f_selector, x->f_argc, x->f_argv); }
void hoa_out_float(t_hoa_out *x, double f) { t_args_struct args; args.msg = hoa_sym_float; args.index = x->outlet_num; args.argc = 1; args.argv = (t_atom*) malloc(sizeof(t_atom)); atom_setfloat(args.argv, f); object_method(x->parent_processor, hoa_sym_out_message, &args); }
void matrixctrl_preset(t_matrixctrl *x, t_binbuf *b) { t_atom* av = (t_atom *)malloc(x->f_size.x * x->f_size.y * 3 * sizeof(t_atom)); long ac = 0; for(long i = 0; i < (long)x->f_size.y; i++) { for(long j = 0; j < (long)x->f_size.x; j++) { atom_setfloat(av+ac, j); atom_setfloat(av+ac+1, i); atom_setfloat(av+ac+2, x->f_values[i * (long)x->f_size.x + j]); ac += 3; } } binbuf_addv(b, (char *)"s", gensym("list")); binbuf_add(b, x->f_size.x * x->f_size.y * 3, av); free(av); }