void *irreference_new (t_symbol *s, short argc, t_atom *argv) { t_irreference *x = (t_irreference *)object_alloc (this_class); t_atom_long num_in_chans = 1; if (argc && atom_gettype(argv) == A_LONG) { num_in_chans = atom_getlong(argv++); num_in_chans = num_in_chans < 1 ? 1 : num_in_chans; num_in_chans = num_in_chans > HIRT_MAX_MEASURE_CHANS ? HIRT_MAX_MEASURE_CHANS : num_in_chans; argc--; } dsp_setup((t_pxobject *)x, (long) (num_in_chans + 1)); x->process_done = bangout(x); outlet_new(x, "signal"); init_HIRT_common_attributes(x); x->abs_progress = 0; x->T = 0; x->current_t = 0; x->fft_size = 0; x->start_rec = 0; x->stop_rec = 0; x->sample_rate = sys_getsr(); if (!x->sample_rate) x->sample_rate = 44100; alloc_mem_swap(&x->rec_mem, 0, 0); alloc_mem_swap(&x->out_mem, 0, 0); x->current_length = 0; x->current_out_length = 0; x->out_length = 0; x->num_in_chans = (long) num_in_chans; x->num_active_ins = (long) num_in_chans; x->current_num_active_ins = (long) num_in_chans; x->smooth_mode = 1; atom_setlong(&x->deconvolve_delay, 10); attr_args_process(x, argc, argv); return(x); }
void *irextract_new (t_symbol *s, short argc, t_atom *argv) { t_irextract *x = (t_irextract *)object_alloc (this_class); x->process_done = bangout(x); init_HIRT_common_attributes(x); x->bandlimit = 1; x->amp = -1; x->inv_amp = 0; x->fft_size = 0; x->sample_rate = 0; x->out_length_samps = 0; x->out_length = 0; x->gen_length = 0; alloc_mem_swap(&x->out_mem, 0, 0); x->measure_mode = SWEEP; attr_args_process(x, argc, argv); return(x); }
void *irmeasure_new(t_symbol *s, short argc, t_atom *argv) { t_irmeasure *x = (t_irmeasure *)object_alloc(this_class); t_atom_long num_out_chans = 1; t_atom_long num_in_chans = 1; long i; if (argc && atom_gettype(argv) == A_LONG) { num_in_chans = atom_getlong(argv++); num_in_chans = num_in_chans < 1 ? 1 : num_in_chans; num_in_chans = num_in_chans > HIRT_MAX_MEASURE_CHANS ? HIRT_MAX_MEASURE_CHANS : num_in_chans; argc--; } if (argc && atom_gettype(argv) == A_LONG) { num_out_chans = atom_getlong(argv++); num_out_chans = num_out_chans < 1 ? 1 : num_out_chans; num_out_chans = num_out_chans > HIRT_MAX_MEASURE_CHANS ? HIRT_MAX_MEASURE_CHANS : num_out_chans; argc--; } x->process_done = bangout(x); for (i = 0; i < num_out_chans + 1; i++) outlet_new(x, "signal"); dsp_setup((t_pxobject *)x, (long) num_in_chans); init_HIRT_common_attributes(x); x->bandlimit = 1; x->abs_progress = 0; x->amp = -1.0; x->inv_amp = 0; x->T2 = 0; x->current_t = 0; x->fft_size = 0; x->start_measurement = 0; x->stop_measurement = 0; x->test_tone = 0; x->no_dsp = 1; x->sample_rate = sys_getsr(); if (!x->sample_rate) x->sample_rate = 44100.0; alloc_mem_swap(&x->rec_mem, 0, 0); alloc_mem_swap(&x->out_mem, 0, 0); x->num_in_chans = (long) num_in_chans; x->num_out_chans = (long) num_out_chans; x->num_active_ins = (long) num_in_chans; x->num_active_outs = (long) num_out_chans; x->current_num_active_ins = (long) num_in_chans; x->current_num_active_outs = (long) num_out_chans; x->measure_mode = SWEEP; x->phase = 0.0; attr_args_process(x, argc, argv); return(x); }
void *dynamicdsp_new(t_symbol *s, long argc, t_atom *argv) { t_dynamicdsp *x = (t_dynamicdsp *)object_alloc(dynamicdsp_class); t_symbol *patch_name_entered = NULL; t_symbol *tempsym; long ac = 0; t_atom av[MAX_ARGS]; void *outs[MAX_IO]; long num_sig_ins = 2; long num_sig_outs = 2; long num_ins = 2; long num_outs = 2; long max_obj_threads = ThreadSet::getNumProcessors(); // Check if there is a patch name given to load if (argc && atom_gettype(argv) == A_SYM && atom_getsym(argv) != ps_declareio) { patch_name_entered = atom_getsym(argv); argc--; argv++; } // Check for the declareio symbol and ignore to maintain old style functionality if (argc && atom_gettype(argv) == A_SYM && atom_getsym(argv) == ps_declareio) { argc--; argv++; } // Check if there is a declaration of the number of inputs and outs (message and signal) if (argc && atom_gettype(argv) == A_LONG) { if (atom_getlong(argv) >= 0 && atom_getlong(argv) < MAX_IO) num_sig_ins = atom_getlong(argv); argc--; argv++; } if (argc && atom_gettype(argv) == A_LONG) { if (atom_getlong(argv) >= 0 && atom_getlong(argv) < MAX_IO) num_sig_outs = atom_getlong(argv); argc--; argv++; } if (argc && atom_gettype(argv) == A_LONG) { if (atom_getlong(argv) >= 0 && atom_getlong(argv) < MAX_IO) num_ins = atom_getlong(argv); argc--; argv++; } if (argc && atom_gettype(argv) == A_LONG) { if (atom_getlong(argv) >= 0 && atom_getlong(argv) < MAX_IO) num_outs = atom_getlong(argv); argc--; argv++; } if (argc && atom_gettype(argv) == A_LONG) { if (atom_getlong(argv) < max_obj_threads) max_obj_threads = atom_getlong(argv); if (max_obj_threads < 1) max_obj_threads = 1; argc--; argv++; } x->max_obj_threads = max_obj_threads; // Get arguments to patch that is being loaded if there are any if (argc && atom_gettype(argv) == A_SYM) { tempsym = atom_getsym(argv); argc--; argv++; if (tempsym == ps_args) { ac = argc; if (ac > MAX_ARGS) ac = MAX_ARGS; for (long i = 0; i < ac; i++, argv++) av[i] = *argv; } } // Multithreading Setup - defaults to multi-threading off for nested objects, on for non-nested if (Get_Dynamic_Object()) x->multithread_flag = 0; else x->multithread_flag = 1; // Multithreading variables x->manual_threading = 1; x->request_manual_threading = 1; x->request_num_active_threads = max_obj_threads; // Set other variables to defaults x->num_sig_ins = num_sig_ins; x->num_sig_outs = num_sig_outs; x->num_ins = num_ins; x->num_outs = num_outs; x->update_thread_map = 0; x->last_vec_size = 64; x->last_samp_rate = 44100; // Create signal in/out buffers and zero x->sig_ins = (void **) malloc(num_sig_ins * sizeof(void *)); x->sig_outs = (void **) malloc(num_sig_outs * sizeof(void *)); for (long i = 0; i < num_sig_ins; i++) x->sig_ins[i] = NULL; for (long i = 0; i < num_sig_outs; i++) x->sig_outs[i] = NULL; // Make non-signal outlets first for (long i = num_outs - 1; i >= 0; i--) outs[i] = outlet_new((t_object *)x, NULL); // Make signal ins x->num_proxies = (num_sig_ins > num_ins) ? num_sig_ins : num_ins; dsp_setup((t_pxobject *) x, x->num_proxies); x->x_obj.z_misc = Z_NO_INPLACE; // due to output zeroing!! // Make signal outs for (long i = 0; i < num_sig_outs; i++) outlet_new((t_object *)x, "signal"); // Get parent patcher x->parent_patch = (t_patcher *)gensym("#P")->s_thing; // store reference to parent patcher // Setup temporary memory / threads / slots alloc_mem_swap(&x->temp_mem, 0, 0); x->threads = new ThreadSet((t_object *) x, reinterpret_cast<ThreadSet::procFunc *>(&dynamicdsp_threadprocess), max_obj_threads, num_sig_outs); x->slots = new ThreadedPatchSet((t_object *)x, x->parent_patch, num_ins, num_outs, outs); // Load patch if (patch_name_entered) x->slots->load(0, patch_name_entered, ac, av, x->last_vec_size, x->last_samp_rate); return x; }