void tralala_mouseWheel(t_tll *x, t_object *view, t_pt pt, long m, double x_inc, double y_inc) { long h = object_attr_getlong(x, TLL_SYM_XOFFSET) - (x_inc * 100); long v = object_attr_getlong(x, TLL_SYM_YOFFSET) - (y_inc * 100); object_attr_setlong(x, TLL_SYM_XOFFSET, h); object_attr_setlong(x, TLL_SYM_YOFFSET, v); }
/**************************************************************** * Constructor */ void *strstr_new(t_symbol *sym, long argc, t_atom *argv) { t_strstr *x = NULL; x = (t_strstr *)object_alloc(strstr_class); if (x == NULL) { error("strstr: Allocation failed."); return NULL; } // Set inlets, outlets, and proxy x->inl_proxy_ind = 0; x->inl_proxy = proxy_new((t_object *)x, 1, &x->inl_proxy_ind); x->outl_int = intout((t_object *)x); // Set the left string buffer x->i_dstr1 = dstr_new(); // First argument: right string buffer x->i_dstr2 = dstr_new(); if ((argc >= 1) && (attr_args_offset((short)argc, argv) >= 1)) { x->i_dstr2 = str_cat_atom(x, x->i_dstr2, argv); } // Test the string buffers if (DSTR_IS_NULL(x->i_dstr1) || DSTR_IS_NULL(x->i_dstr2)) { object_error((t_object *)x, "Allocation error."); strstr_free(x); return NULL; } // Second argument: mode long mode = 0; if ((argc >= 2) && (attr_args_offset((short)argc, argv) >= 2)) { if ((atom_gettype(argv + 1) == A_LONG) && (atom_getlong(argv + 1) >= 0) && (atom_getlong(argv + 1) <= 1)) { mode = (long)atom_getlong(argv + 1); } else { object_error((t_object *)x, "Arg 2: Mode: 0 or 1 expected"); } } object_attr_setlong(x, gensym("mode"), mode); // Set the float precision object_attr_setlong(x, gensym("fprecision"), 6); // Set the remaining variables x->o_pos = -1; // Process the attributes attr_args_process(x, (short)argc, argv); return x; }
void *dpoltocar_new(t_symbol *s, short ac, t_atom *av) { t_dpoltocar *x; x = (t_dpoltocar *)object_alloc(dpoltocar_class); if(x) { x->d_outlet = listout(x); t_ptr_size attrstart = attr_args_offset(ac, av); // support normal arguments if((attrstart != 0) && (av)) { int argument = atom_getlong(&av[0]); if(argument == 0){ x->d_mode = 0; }else{ x->d_mode = 1; } } object_attr_setlong(x, gensym("mode"), x->d_mode); attr_args_process(x, ac, av); x->d_operational[0]=0; x->d_operational[1]=0; x->d_operational[2]=0; } return x; }
t_max_err mode_set(t_hoa_decoder *x, t_object *attr, long argc, t_atom *argv) { if(argc && argv && atom_gettype(argv) == A_SYM) { if(atom_getsym(argv) == gensym("ambisonic") && x->f_decoder->getDecodingMode() != Hoa2D::DecoderMulti::Regular) { object_method(gensym("dsp")->s_thing, gensym("stop")); x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Regular); object_attr_setdisabled((t_object *)x, gensym("angles"), 1); object_attr_setdisabled((t_object *)x, gensym("channels"), 0); object_attr_setdisabled((t_object *)x, gensym("offset"), 0); object_attr_setfloat(x, gensym("offset"), (float)x->f_decoder->getChannelsOffset() / HOA_2PI * 360.f); } else if(atom_getsym(argv) == gensym("irregular") && x->f_decoder->getDecodingMode() != Hoa2D::DecoderMulti::Irregular) { object_method(gensym("dsp")->s_thing, gensym("stop")); x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Irregular); object_attr_setdisabled((t_object *)x, gensym("angles"), 0); object_attr_setdisabled((t_object *)x, gensym("channels"), 0); object_attr_setdisabled((t_object *)x, gensym("offset"), 1); } else if(atom_getsym(argv) == gensym("binaural") && x->f_decoder->getDecodingMode() != Hoa2D::DecoderMulti::Binaural) { object_method(gensym("dsp")->s_thing, gensym("stop")); x->f_decoder->setDecodingMode(Hoa2D::DecoderMulti::Binaural); object_attr_setdisabled((t_object *)x, gensym("angles"), 1); object_attr_setdisabled((t_object *)x, gensym("channels"), 1); object_attr_setdisabled((t_object *)x, gensym("offset"), 1); } object_attr_setlong(x, gensym("channels"), x->f_decoder->getNumberOfChannels()); } send_configuration(x); return MAX_ERR_NONE; }
void ui_preset_interface(t_ui *x) { char filename[MAX_FILENAME_CHARS]; short path; t_fourcc type; t_fourcc filetype = 'JSON'; t_dictionary* d; t_object* p; t_atom a; strncpy_zero(filename, "j.preset_interface.maxpat", MAX_FILENAME_CHARS); locatefile_extended(filename, &path, &type, &filetype, 1); dictionary_read(filename, path, &d); atom_setobj(&a, d); p = (t_object*)object_new_typed(_sym_nobox, _sym_jpatcher, 1, &a); object_attr_setlong(p, _sym_locked, 1); // start out locked object_attr_setchar(p, _sym_enablehscroll, 0); // turn off scroll bars object_attr_setchar(p, _sym_enablevscroll, 0); object_attr_setchar(p, _sym_openinpresentation, 1); object_attr_setchar(p, _sym_toolbarvisible, 0); object_attr_setsym(p, _sym_title, gensym("preset_interface")); object_method_parse(p, _sym_window, "constrain 5 320 179 595", NULL); object_attach_byptr_register(x, p, _sym_nobox); object_method(p, _sym_vis); // "vis" happens immediately, "front" is defer_lowed object_attr_setobj(jpatcher_get_firstview(p), _sym_owner, (t_object*)x); // become the owner OBJ_ATTR_SYM(p, "arguments", 0, gensym((char*)x->modelAddress.c_str())); // the patch needs a [j.interfaceArguments.js] object_method(p, _sym_loadbang); }
t_max_err db_query_silent(t_database *db, t_db_result **dbresult, const char *s, ...) { char sql[DATABASE_SQL_MAXLEN+2]; va_list ap; long logging = false; t_max_err err; va_start(ap, s); vsnprintf(sql, DATABASE_SQL_MAXLEN, s, ap); sql[DATABASE_SQL_MAXLEN] = '\0'; logging = object_attr_getlong(db, _sym_log); object_attr_setlong(db, _sym_log, 0); err = db_query(db, dbresult, sql, NULL); object_attr_setlong(db, _sym_log, logging); return err; }
// FREEZE UI for all parameters void hub_ui_freeze(t_hub *x, t_symbol*, long argc, t_atom *argv) { subscriberList *subscriber = x->subscriber; // head of the linked list t_max_err err = MAX_ERR_NONE; // Change freeze status for all messages and parameters subscriberIterator i; t_subscriber* t; // Change freeze attribute for the gui // FIXME: This call is not working!!!! // this means that the ui menu does not always reflect the state correctly err = object_attr_setlong(x->gui_object, gensym("ui_is_frozen"), atom_getlong(argv)); critical_enter(0); for(i = subscriber->begin(); i != subscriber->end(); ++i) { t = *i; if(t->type == jps_subscribe_parameter) object_method_typed(t->object, jps_ui_slash_freeze, 1, argv, NULL); } critical_exit(0); }
int main(void) { common_symbols_init(); PlugtasticInit(); plugtastic_classinit(); sPlugtasticObject = (t_object*)plugtastic_new(); ps_plugtastic = GENSYM("plugtastic"); ps_plugtastic->s_thing = sPlugtasticObject; sMaxObject = _sym_max->s_thing; ps_objectfile = GENSYM("objectfile"); ps_db_object_addinternal = GENSYM("db.object_addinternal"); ps_oblist = GENSYM("oblist"); ps_db_addmetadata = GENSYM("db.addmetadata"); //defer_low(sMaxObject, (method)plug_setup_db, NULL, 0, NULL); plug_setup_db(); post("Plugtastic Version %s | 74Objects.com", PLUGTASTIC_VERSION); // This tells Max 5.0.6 and higher that we want the patcher files to be saved such that they are sorted. // Having the saved this way makes our SVN diffs much more meaningful. object_method_long(sMaxObject, GENSYM("sortpatcherdictonsave"), 1, NULL); // This tells Max 4.5.7 and higher to take any posts to the Max window and also make the // post to the system console, which greatly aids in debugging problems and crashes object_method_long(sMaxObject, GENSYM("setmirrortoconsole"), 1, NULL); // OPEN THE SPLASH if (sPlugtasticSplash) { char name[MAX_FILENAME_CHARS]; short path = 0; long type = 0; long typelist[2] = {'JSON', 'TEXT'}; short err; t_dictionary* d; t_object* p; t_atom a[2]; strncpy_zero(name, "Plugtastic.maxpat", MAX_FILENAME_CHARS); err = locatefile_extended(name, &path, &type, typelist, 2); dictionary_read(name, path, &d); atom_setobj(a, d); p = (t_object*)object_new_typed(_sym_nobox, _sym_jpatcher, 1, a); object_attr_setlong(p, _sym_locked, 1); // start out locked object_attr_setchar(p, _sym_enablehscroll, 0); // turn off scroll bars object_attr_setchar(p, _sym_enablevscroll, 0); object_attr_setchar(p, _sym_toolbarvisible, 0); object_attr_setsym(p, _sym_title, gensym("Welcome to Plugtastic")); object_attr_setparse(p, _sym_rect, "271 170 799 489"); object_attr_setparse(p, _sym_defrect, "271 170 799 489"); object_method(p, _sym_vis); // "vis" happens immediately, "front" is defer_lowed object_method(p, _sym_loadbang); // object_method_parse(p, _sym_window, "constrain 799 489 799 489", NULL); object_method_parse(p, _sym_window, "flags nozoom", NULL); object_method_parse(p, _sym_window, "flags nogrow", NULL); object_method_parse(p, _sym_window, "exec", NULL); } return 0; }
void *cmgrainlabs_new(t_symbol *s, long argc, t_atom *argv) { t_cmgrainlabs *x = (t_cmgrainlabs *)object_alloc(cmgrainlabs_class); // create the object and allocate required memory dsp_setup((t_pxobject *)x, 11); // create 11 inlets if (argc < ARGUMENTS) { object_error((t_object *)x, "%d arguments required (sample/window/voices)", ARGUMENTS); return NULL; } x->buffer_name = atom_getsymarg(0, argc, argv); // get user supplied argument for sample buffer x->window_name = atom_getsymarg(1, argc, argv); // get user supplied argument for window buffer x->grains_limit = atom_getintarg(2, argc, argv); // get user supplied argument for maximum grains // HANDLE ATTRIBUTES object_attr_setlong(x, gensym("stereo"), 0); // initialize stereo attribute object_attr_setlong(x, gensym("w_interp"), 0); // initialize window interpolation attribute object_attr_setlong(x, gensym("s_interp"), 1); // initialize window interpolation attribute object_attr_setlong(x, gensym("zero"), 0); // initialize zero crossing attribute attr_args_process(x, argc, argv); // get attribute values if supplied as argument // CHECK IF USER SUPPLIED MAXIMUM GRAINS IS IN THE LEGAL RANGE (1 - MAXGRAINS) if (x->grains_limit < 1 || x->grains_limit > MAXGRAINS) { object_error((t_object *)x, "maximum grains allowed is %d", MAXGRAINS); return NULL; } // CREATE OUTLETS (OUTLETS ARE CREATED FROM RIGHT TO LEFT) x->grains_count_out = intout((t_object *)x); // create outlet for number of currently playing grains outlet_new((t_object *)x, "signal"); // right signal outlet outlet_new((t_object *)x, "signal"); // left signal outlet // GET SYSTEM SAMPLE RATE x->m_sr = sys_getsr() * 0.001; // get the current sample rate and write it into the object structure /************************************************************************************************************************/ // ALLOCATE MEMORY FOR THE BUSY ARRAY x->busy = (short *)sysmem_newptrclear((MAXGRAINS) * sizeof(short *)); if (x->busy == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE GRAINPOS ARRAY x->grainpos = (long *)sysmem_newptrclear((MAXGRAINS) * sizeof(long *)); if (x->grainpos == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE START ARRAY x->start = (long *)sysmem_newptrclear((MAXGRAINS) * sizeof(long *)); if (x->start == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE T_LENGTH ARRAY x->t_length = (long *)sysmem_newptrclear((MAXGRAINS) * sizeof(long *)); if (x->t_length == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE GR_LENGTH ARRAY x->gr_length = (long *)sysmem_newptrclear((MAXGRAINS) * sizeof(long *)); if (x->gr_length == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE PAN_LEFT ARRAY x->pan_left = (double *)sysmem_newptrclear((MAXGRAINS) * sizeof(double *)); if (x->pan_left == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE PAN_RIGHT ARRAY x->pan_right = (double *)sysmem_newptrclear((MAXGRAINS) * sizeof(double *)); if (x->pan_right == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE GAIN ARRAY x->gain = (double *)sysmem_newptrclear((MAXGRAINS) * sizeof(double *)); if (x->gain == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } /************************************************************************************************************************/ // INITIALIZE VALUES x->startmin_float = 0.0; // initialize float inlet value for current start min value x->startmax_float = 0.0; // initialize float inlet value for current start max value x->lengthmin_float = 150; // initialize float inlet value for min grain length x->lengthmax_float = 150; // initialize float inlet value for max grain length x->pitchmin_float = 1.0; // initialize inlet value for min pitch x->pitchmax_float = 1.0; // initialize inlet value for min pitch x->panmin_float = 0.0; // initialize value for min pan x->panmax_float = 0.0; // initialize value for max pan x->gainmin_float = 1.0; // initialize value for min gain x->gainmax_float = 1.0; // initialize value for max gain x->tr_prev = 0.0; // initialize value for previous trigger sample x->grains_count = 0; // initialize the grains count value x->grains_limit_old = 0; // initialize value for the routine when grains limit was modified x->limit_modified = 0; // initialize channel change flag x->buffer_modified = 0; // initialized buffer modified flag /************************************************************************************************************************/ // BUFFER REFERENCES x->buffer = buffer_ref_new((t_object *)x, x->buffer_name); // write the buffer reference into the object structure x->w_buffer = buffer_ref_new((t_object *)x, x->window_name); // write the window buffer reference into the object structure return x; }
void *cmbuffercloud_new(t_symbol *s, long argc, t_atom *argv) { t_cmbuffercloud *x = (t_cmbuffercloud *)object_alloc(cmbuffercloud_class); // create the object and allocate required memory dsp_setup((t_pxobject *)x, 11); // create 11 inlets if (argc < ARGUMENTS) { object_error((t_object *)x, "%d arguments required (sample buffer / window type / max. voices)", ARGUMENTS); return NULL; } x->buffer_name = atom_getsymarg(0, argc, argv); // get user supplied argument for sample buffer x->window_name = atom_getsymarg(1, argc, argv); // get user supplied argument for window buffer x->grains_limit = atom_getintarg(2, argc, argv); // get user supplied argument for maximum grains // HANDLE ATTRIBUTES object_attr_setlong(x, gensym("stereo"), 0); // initialize stereo attribute object_attr_setlong(x, gensym("w_interp"), 0); // initialize window interpolation attribute object_attr_setlong(x, gensym("s_interp"), 1); // initialize window interpolation attribute object_attr_setlong(x, gensym("zero"), 0); // initialize zero crossing attribute attr_args_process(x, argc, argv); // get attribute values if supplied as argument // CHECK IF USER SUPPLIED MAXIMUM GRAINS IS IN THE LEGAL RANGE (1 - MAXGRAINS) if (x->grains_limit < 1 || x->grains_limit > MAXGRAINS) { object_error((t_object *)x, "maximum grains allowed is %d", MAXGRAINS); return NULL; } // CREATE OUTLETS (OUTLETS ARE CREATED FROM RIGHT TO LEFT) x->grains_count_out = intout((t_object *)x); // create outlet for number of currently playing grains outlet_new((t_object *)x, "signal"); // right signal outlet outlet_new((t_object *)x, "signal"); // left signal outlet // GET SYSTEM SAMPLE RATE x->m_sr = sys_getsr() * 0.001; // get the current sample rate and write it into the object structure /************************************************************************************************************************/ // ALLOCATE MEMORY FOR THE BUSY ARRAY x->busy = (short *)sysmem_newptrclear((MAXGRAINS) * sizeof(short)); if (x->busy == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE GRAINPOS ARRAY x->grainpos = (long *)sysmem_newptrclear((MAXGRAINS) * sizeof(long)); if (x->grainpos == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE START ARRAY x->start = (long *)sysmem_newptrclear((MAXGRAINS) * sizeof(long)); if (x->start == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE smp_length ARRAY x->smp_length = (long *)sysmem_newptrclear((MAXGRAINS) * sizeof(long)); if (x->smp_length == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE pitch_length ARRAY x->pitch_length = (long *)sysmem_newptrclear((MAXGRAINS) * sizeof(long)); if (x->pitch_length == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE PAN_LEFT ARRAY x->pan_left = (double *)sysmem_newptrclear((MAXGRAINS) * sizeof(double)); if (x->pan_left == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE PAN_RIGHT ARRAY x->pan_right = (double *)sysmem_newptrclear((MAXGRAINS) * sizeof(double)); if (x->pan_right == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE GAIN ARRAY x->gain = (double *)sysmem_newptrclear((MAXGRAINS) * sizeof(double)); if (x->gain == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE OBJET FLOAT_INLETS ARRAY x->object_inlets = (double *)sysmem_newptrclear((FLOAT_INLETS) * sizeof(double)); if (x->object_inlets == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE GRAIN PARAMETERS ARRAY x->grain_params = (double *)sysmem_newptrclear((FLOAT_INLETS) * sizeof(double)); if (x->grain_params == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE GRAIN PARAMETERS ARRAY x->randomized = (double *)sysmem_newptrclear((FLOAT_INLETS / 2) * sizeof(double)); if (x->randomized == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } // ALLOCATE MEMORY FOR THE TEST VALUES ARRAY x->testvalues = (double *)sysmem_newptrclear((FLOAT_INLETS) * sizeof(double)); if (x->testvalues == NULL) { object_error((t_object *)x, "out of memory"); return NULL; } /************************************************************************************************************************/ // INITIALIZE VALUES x->object_inlets[0] = 0.0; // initialize float inlet value for current start min value x->object_inlets[1] = 0.0; // initialize float inlet value for current start max value x->object_inlets[2] = 150; // initialize float inlet value for min grain length x->object_inlets[3] = 150; // initialize float inlet value for max grain length x->object_inlets[4] = 1.0; // initialize inlet value for min pitch x->object_inlets[5] = 1.0; // initialize inlet value for min pitch x->object_inlets[6] = 0.0; // initialize value for min pan x->object_inlets[7] = 0.0; // initialize value for max pan x->object_inlets[8] = 1.0; // initialize value for min gain x->object_inlets[9] = 1.0; // initialize value for max gain x->tr_prev = 0.0; // initialize value for previous trigger sample x->grains_count = 0; // initialize the grains count value x->grains_limit_old = 0; // initialize value for the routine when grains limit was modified x->limit_modified = 0; // initialize channel change flag x->buffer_modified = 0; // initialized buffer modified flag // initialize the testvalues which are not dependent on sampleRate x->testvalues[0] = 0.0; // dummy MIN_START x->testvalues[1] = 0.0; // dummy MAX_START x->testvalues[4] = MIN_PITCH; x->testvalues[5] = MAX_PITCH; x->testvalues[6] = MIN_PAN; x->testvalues[7] = MAX_PAN; x->testvalues[8] = MIN_GAIN; x->testvalues[9] = MAX_GAIN; // calculate constants for panning function x->piovr2 = 4.0 * atan(1.0) * 0.5; x->root2ovr2 = sqrt(2.0) * 0.5; x->bang_trigger = 0; /************************************************************************************************************************/ // BUFFER REFERENCES x->buffer = buffer_ref_new((t_object *)x, x->buffer_name); // write the buffer reference into the object structure x->w_buffer = buffer_ref_new((t_object *)x, x->window_name); // write the window buffer reference into the object structure return x; }