void irreference_dsp_common(t_irreference *x, double samplerate) { double old_sr; AH_UIntPtr mem_size; // Store sample rate old_sr = x->sample_rate; x->sample_rate = samplerate; if (x->start_rec) { // Resize memory if we are just about to record mem_size = irreference_calc_mem_size(x, x->current_num_active_ins); if (!schedule_grow_mem_swap(&x->rec_mem, mem_size, mem_size)) object_error((t_object *) x, "not able to allocate adequate memory for recording"); } else { if (x->sample_rate != old_sr) { // Clear memory if the sample rate has changed and we have not just started measuring irreference_clear(x); } } }
void *dynamicdsp_client_temp_mem_resize(t_dynamicdsp *x, t_ptr_int index, t_ptr_uint size) { // FIX - better system for this... schedule_grow_mem_swap(&x->temp_mem, size * x->threads->getNumThreads(), size); x->slots->setTempMemSize(index, size); return (void *) 1; }
void irreference_rec (t_irreference *x, t_symbol *sym, short argc, t_atom *argv) { double length = 30000; double out_length = 5000; long num_active_ins = x->num_active_ins; AH_SIntPtr mem_size; // Load arguments if (argc > 0) length = atom_getfloat(argv++); if (argc > 1) out_length = atom_getfloat(argv++); // Check parameters length = irreference_param_check(x, "length", length, 0., HUGE_VAL); out_length = irreference_param_check(x, "ir length", out_length, 0., length); // Store parameters x->length = length / 1000.; x->out_length = out_length / 1000.; // Check length of recording and memory allocation if (length) { mem_size = irreference_calc_mem_size(x, num_active_ins); if (!schedule_grow_mem_swap(&x->rec_mem, mem_size, mem_size)) object_error((t_object *) x, "not able to allocate adequate memory for recording"); // Start measurement x->current_num_active_ins = num_active_ins; x->fft_size = 0; x->stop_rec = 0; x->start_rec = 1; } else { object_error((t_object *) x, "zero length recording"); x->stop_rec = 1; } }
void irmeasure_mls(t_irmeasure *x, t_symbol *sym, long argc, t_atom *argv) { double out_length = 5000.0; long num_active_ins = x->num_active_ins; long num_active_outs = x->num_active_outs; t_atom_long order = 18; AH_SIntPtr mem_size; // Load parameters if (argc > 0) order = atom_getlong(argv++); if (argc > 1) out_length = atom_getfloat(argv++); // Check parameters order = (t_atom_long) irmeasure_param_check(x, "order", (double) order, 1, 24); out_length = irmeasure_param_check(x, "ir length", out_length, 0.0, HUGE_VAL); // Store parameters x->order = (long) order; x->out_length = out_length / 1000.0; // Allocate memory mem_size = num_active_ins * irmeasure_calc_mls_mem_size(x->order, num_active_outs, x->out_length, x->sample_rate); if (!schedule_grow_mem_swap(&x->rec_mem, mem_size, mem_size)) object_error((t_object *) x, "not able to allocate adequate memory for recording"); // Start measurement x->current_num_active_ins = num_active_ins; x->current_num_active_outs = num_active_outs; x->measure_mode = MLS; x->fft_size = 0; x->test_tone = 0; x->stop_measurement = 0; x->start_measurement = 1; }
void irmeasure_noise(t_irmeasure *x, t_symbol *sym, long argc, t_atom *argv) { double length = 10000.0; double fade_in = 10.0; double fade_out = 10.0; double out_length = 5000.0; long num_active_ins = x->num_active_ins; long num_active_outs = x->num_active_outs; AH_SIntPtr mem_size; t_noise_mode noise_mode = NOISE_MODE_WHITE; if (sym == gensym("brown")) noise_mode = NOISE_MODE_BROWN; if (sym == gensym("pink")) noise_mode = NOISE_MODE_PINK; // Load parameters if (argc > 0) length = atom_getfloat(argv++); if (argc > 1) fade_in = atom_getfloat(argv++); if (argc > 2) fade_out = atom_getfloat(argv++); if (argc > 3) out_length = atom_getfloat(argv++); // Check parameters length = irmeasure_param_check(x, "length", length, 0.0, HUGE_VAL); fade_in = irmeasure_param_check(x, "fade in time", fade_in, 0.0, length / 2.0); fade_out = irmeasure_param_check(x, "fade out time", fade_out, 0.0, length / 2.0); out_length = irmeasure_param_check(x, "ir length", out_length, 0.0, HUGE_VAL); // Store parameters x->noise_mode = noise_mode; x->length = length / 1000.0; x->fade_in = fade_in / 1000.0; x->fade_out = fade_out / 1000.0; x->out_length = out_length / 1000.0; // Allocate memory mem_size = num_active_ins * irmeasure_calc_noise_mem_size(x->length, num_active_outs, x->out_length, x->sample_rate); if (!schedule_grow_mem_swap(&x->rec_mem, mem_size, mem_size)) object_error((t_object *) x, "not able to allocate adequate memory for recording"); // Start measurement x->current_num_active_ins = num_active_ins; x->current_num_active_outs = num_active_outs; x->measure_mode = NOISE; x->fft_size = 0; x->test_tone = 0; x->stop_measurement = 0; x->start_measurement = 1; }
void irmeasure_sweep(t_irmeasure *x, t_symbol *sym, long argc, t_atom *argv) { t_ess sweep_params; double f1 = 20.0; double f2 = sys_getsr() / 2.0; double length = 30000.0; double fade_in = 50.0; double fade_out = 10.0; double out_length = 5000.0; long num_active_ins = x->num_active_ins; long num_active_outs = x->num_active_outs; AH_SIntPtr mem_size; // Load parameters if (argc > 0) f1 = atom_getfloat(argv++); if (argc > 1) f2 = atom_getfloat(argv++); if (argc > 2) length = atom_getfloat(argv++); if (argc > 3) fade_in = atom_getfloat(argv++); if (argc > 4) fade_out = atom_getfloat(argv++); if (argc > 5) out_length = atom_getfloat(argv++); // Check parameters f1 = irmeasure_param_check(x, "low frequency", f1, 0.0001, x->sample_rate / 2.0); f2 = irmeasure_param_check(x, "high frequency", f2, f2, x->sample_rate / 2.0); length = irmeasure_param_check(x, "length", length, 0.0, HUGE_VAL); fade_in = irmeasure_param_check(x, "fade in time", fade_in, 0.0, length / 2.0); fade_out = irmeasure_param_check(x, "fade out time", fade_out, 0.0, length / 2.0); out_length = irmeasure_param_check(x, "ir length", out_length, 0.0, HUGE_VAL); // Store parameters x->lo_f = f1; x->hi_f = f2; x->fade_in = fade_in / 1000.0; x->fade_out = fade_out / 1000.0; x->length = length / 1000.0; x->out_length = out_length / 1000.0; // Check length of sweep and memory allocation if (ess_params(&sweep_params, x->lo_f, x->hi_f, x->fade_in, x->fade_out, x->length, x->sample_rate, db_to_a(x->amp), 0)) { mem_size = num_active_ins * irmeasure_calc_sweep_mem_size(&sweep_params, num_active_outs, x->out_length, x->sample_rate); if (!schedule_grow_mem_swap(&x->rec_mem, mem_size, mem_size)) object_error((t_object *) x, "not able to allocate adequate memory for recording"); // Get amplitude curve fill_amp_curve_specifier(x->amp_curve, x->amp_curve_specifier, x->amp_curve_num_specifiers); // Start measurement x->current_num_active_ins = num_active_ins; x->current_num_active_outs = num_active_outs; x->measure_mode = SWEEP; x->fft_size = 0; x->test_tone = 0; x->stop_measurement = 0; x->start_measurement = 1; } else { object_error((t_object *) x, "zero length sweep - requested length value is too small"); x->stop_measurement = 1; } }