t_max_err space_notify(t_space *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { t_symbol *name; if (msg == gensym("attr_modified")) { name = (t_symbol *)object_method((t_object *)data, gensym("getname")); if(name == gensym("bgcolor") || name == gensym("borderboxcolor") || name == gensym("cicolor") || name == gensym("cicolorin") ) { jbox_invalidate_layer((t_object *)x, NULL, gensym("background_layer")); } else if(name == gensym("harmocolor")) { jbox_invalidate_layer((t_object *)x, NULL, gensym("harmonics_layer")); } else if(name == gensym("miccolor")) { jbox_invalidate_layer((t_object *)x, NULL, gensym("microphones_points_layer")); } else if(name == gensym("shadow")) { jbox_invalidate_layer((t_object *)x, NULL, gensym("background_layer")); if (x->f_shadow) object_attr_setdisabled((t_object *)x, gensym("cishadcolor"), 0); else object_attr_setdisabled((t_object *)x, gensym("cishadcolor"), 1); } jbox_redraw((t_jbox *)x); } return jbox_notify((t_jbox *)x, s, msg, sender, data); }
t_max_err hoa_space_coefficients_set(t_hoa_space *x, t_object *attr, long ac, t_atom *av) { if (ac && av) { if(atom_gettype(av) == A_FLOAT) { if(x->f_mode == 0 || x->f_mode == 2) { for (int i = 0; i < ac && i < x->f_number_of_microphones; i++) { if(atom_gettype(av+i) == A_FLOAT) x->f_microphonesValues[i] = Tools::clip((double)atom_getfloat(av + i), 0., 1.); } } else { for (int i = 0; i < ac && i < x->f_number_of_microphones; i++) { x->f_microphonesValues[i] = atom_getfloat(av + i); } } } } x->f_recomposer->processFixe(x->f_microphonesValues, x->f_harmonicsValues); x->f_viewer->processContribAndRep(x->f_harmonicsValues); jbox_invalidate_layer((t_object *)x, NULL, gensym("microphones_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("harmonics_layer")); jbox_redraw((t_jbox *)x); return 0; }
void meter_tick(t_meter *x) { meter_output(x); if(x->f_ramp == x->f_vector->getNumberOfChannels()) x->f_ramp = 0; x->f_vector->process(x->f_signals, x->f_vector_coords + x->f_vector->getNumberOfChannels() * x->f_ramp); for(int i = 0; i < x->f_meter->getNumberOfChannels(); i++) { if(x->f_meter->getChannelEnergy(i) >= 0.) x->f_overled[i] = OVERLED_DRAWTIME; else x->f_overled[i] -= x->f_interval; if(x->f_overled[i] < 0) x->f_overled[i] = 0; } jbox_invalidate_layer((t_object *)x, NULL, s_leds_layer); jbox_invalidate_layer((t_object *)x, NULL, s_energy_layer); jbox_invalidate_layer((t_object *)x, NULL, s_velocity_layer); jbox_redraw((t_jbox *)x); if (sys_getdspstate()) clock_fdelay(x->f_clock, x->f_interval); }
void hoa_gain_set_input_mode_value(t_hoa_gain *x, double value, bool notify) { double dBValue = x->j_valdB; switch (x->f_inputMode) { case DECIBELS : dBValue = value; break; case AMPLITUDE : dBValue = atodb(value); break; case MIDI : dBValue = scale(value, 0, 128, -70, 0); break; default: break; } x->j_val = hoa_gain_constrain_real_value(x, dBValue) - x->j_min; x->j_valdB = x->j_val + x->j_min; hoa_gain_set_gain(x); if (notify) { object_notify(x, hoa_sym_modified, NULL); } jbox_invalidate_layer((t_object *)x, NULL, gensym("cursor_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("valuerect_layer")); jbox_redraw((t_jbox *)x); }
t_max_err angles_set(t_meter *x, t_object *attr, long ac, t_atom *av) { if(ac && av) { object_method(hoa_sym_dsp->s_thing, hoa_sym_stop); for(long i = 0; i < ac && i < x->f_meter->getNumberOfPlanewaves(); i++) { if(atom_isNumber(av+i)) { x->f_meter->setPlanewaveAzimuth(i, atom_getfloat(av+i) / 360.f * HOA_2PI); x->f_vector->setPlanewaveAzimuth(i, atom_getfloat(av+i) / 360.f * HOA_2PI); } } x->f_meter->computeRendering(); x->f_vector->computeRendering(); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_skeleton_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_separator_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_leds_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_vectors_layer); jbox_redraw((t_jbox *)x); } return MAX_ERR_NONE; }
void tralala_paint(t_tll *x, t_object *pv) { if (TLL_FLAG_TRUE(TLL_DIRTY_RUN)) { jbox_invalidate_layer((t_object *)x, NULL, TLL_SYM_RUN); TLL_FLAG_UNSET(TLL_DIRTY_RUN); } if (TLL_FLAG_TRUE(TLL_DIRTY_ZONE)) { jbox_invalidate_layer((t_object *)x, NULL, TLL_SYM_ZONE); TLL_FLAG_UNSET(TLL_DIRTY_ZONE); } if (TLL_FLAG_TRUE(TLL_DIRTY_NOTE)) { jbox_invalidate_layer((t_object *)x, NULL, TLL_SYM_NOTE); TLL_FLAG_UNSET(TLL_DIRTY_NOTE); } if (TLL_FLAG_TRUE(TLL_DIRTY_LASSO)) { jbox_invalidate_layer((t_object *)x, NULL, TLL_SYM_LASSO); TLL_FLAG_UNSET(TLL_DIRTY_LASSO); } if (TLL_FLAG_TRUE(TLL_DIRTY_BACKGROUND)) { jbox_invalidate_layer((t_object *)x, NULL, TLL_SYM_BACKGROUND); TLL_FLAG_UNSET(TLL_DIRTY_BACKGROUND); } tralala_paintBackground(x, pv); tralala_paintCurrent(x, pv); tralala_paintRun(x, pv); tralala_paintLasso(x, pv); }
void scope_tick(t_scope *x) { x->f_viewer->processContribAndRep(x->f_harmonicsValues); jbox_invalidate_layer((t_object *)x, NULL, gensym("contrib_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("harmonics_layer")); jbox_redraw((t_jbox *)x); if (sys_getdspstate()) clock_delay(x->f_clock, x->f_interval); }
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 hoa_space_compute(t_hoa_space *x) { x->f_recomposer->processFixe(x->f_microphonesValues, x->f_harmonicsValues); x->f_viewer->processContribAndRep(x->f_harmonicsValues); 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); hoa_space_output(x); }
void hoa_gain_set_dB(t_hoa_gain *x, double dBValue) { x->j_val = hoa_gain_constrain_real_value(x, dBValue) - x->j_min; x->j_valdB = x->j_val + x->j_min; hoa_gain_set_gain(x); object_notify(x, hoa_sym_modified, NULL); jbox_invalidate_layer((t_object *)x, NULL, gensym("cursor_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("valuerect_layer")); jbox_redraw((t_jbox *)x); }
t_max_err scope_notify(t_scope *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { if (msg == gensym("attr_modified")) { if( s == gensym("bgcolor") || s == gensym("drawcircle") ) { jbox_invalidate_layer((t_object *)x, NULL, gensym("background_layer")); } else if(s == gensym("drawangles")) { jbox_invalidate_layer((t_object *)x, NULL, gensym("angle_layer")); } else if(s == gensym("txcolor")) { jbox_invalidate_layer((t_object *)x, NULL, gensym("angle_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("contrib_layer")); } else if(s == gensym("phcolor") || s == gensym("nhcolor")) { jbox_invalidate_layer((t_object *)x, NULL, gensym("harmonics_layer")); } else if(s == gensym("order")) { jbox_invalidate_layer((t_object *)x, NULL, gensym("background_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("angle_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("contrib_layer")); } jbox_redraw((t_jbox *)x); } return jbox_notify((t_jbox *)x, s, msg, sender, data); }
void space_compute(t_space *x) { x->f_recomposer->process(x->f_microphonesValues, x->f_harmonicsValues); x->f_viewer->process(x->f_harmonicsValues); jbox_invalidate_layer((t_object *)x, NULL, gensym("rotation_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("harmonics_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("microphones_points_layer")); jbox_redraw((t_jbox *)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); }
t_max_err view_set(t_hoa_3d_scope *x, t_object *attr, long ac, t_atom *av) { if(ac && av && atom_isNumber(av)) { //object_method(hoa_sym_dsp->s_thing, hoa_sym_stop); if(atom_gettype(av) == A_FLOAT) x->f_view[0] = atom_getfloat(av); else x->f_view[0] = x->f_scope->getViewRotationX() * 360. / HOA_2PI; if(ac > 1 && atom_gettype(av+1) == A_FLOAT) x->f_view[1] = atom_getfloat(av+1); else x->f_view[1] = x->f_scope->getViewRotationY() * 360. / HOA_2PI; if(ac > 2 && atom_isNumber(av+2)) x->f_view[2] = atom_getfloat(av+2); else x->f_view[2] = x->f_scope->getViewRotationZ() * 360. / HOA_2PI; x->f_scope->setViewRotation(x->f_view[0] / 360. * HOA_2PI, x->f_view[1] / 360. * HOA_2PI, x->f_view[2] / 360. * HOA_2PI); x->f_scope->computeRendering(); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_harmonics_layer); jbox_redraw((t_jbox *)x); } return MAX_ERR_NONE; }
t_max_err set_order(t_hoa_3d_scope *x, t_object *attr, long ac, t_atom *av) { long order; t_object *b = NULL; if (ac && av && atom_gettype(av) == A_LONG) { order = atom_getlong(av); if(order != x->f_scope->getDecompositionOrder() && order > 0) { object_method(hoa_sym_dsp->s_thing, hoa_sym_stop); delete x->f_scope; delete [] x->f_signals; x->f_scope = new Scope<Hoa3d, t_sample>(order, (ulong)(HOA_DISPLAY_NPOINTS * 0.25), (ulong)(HOA_DISPLAY_NPOINTS * 0.5)); x->f_order = x->f_scope->getDecompositionOrder(); x->f_signals = new double[x->f_scope->getNumberOfHarmonics() * SYS_MAXBLKSIZE]; object_obex_lookup(x, hoa_sym_pound_B, (t_object **)&b); object_method(b, hoa_sym_dynlet_begin); dsp_resize((t_pxobject*)x, x->f_scope->getNumberOfHarmonics()); object_method(b, hoa_sym_dynlet_end); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_background_layer); jbox_redraw((t_jbox *)x); } } return MAX_ERR_NONE; }
t_max_err number_of_microphones_set(t_space *x, t_object *attr, long argc, t_atom *argv) { if(atom_gettype(argv) == A_LONG) { if(atom_getlong(argv) != x->f_number_of_microphones || x->f_number_of_microphones_initialized == false) { delete x->f_viewer; delete x->f_recomposer; x->f_number_of_microphones = atom_getlong(argv); x->f_number_of_microphones = Tools::clip_min(x->f_number_of_microphones, (long)3); if(x->f_number_of_microphones % 2 == 0) x->f_order = (x->f_number_of_microphones - 2) / 2; else x->f_order = (x->f_number_of_microphones - 1) / 2; x->f_number_of_harmonics = x->f_order * 2 + 1; x->f_viewer = new AmbisonicViewer(x->f_order); x->f_recomposer = new ambisonicRecomposer(x->f_order, x->f_number_of_microphones); if(x->f_number_of_microphones_initialized == false) x->f_number_of_microphones_initialized = true; jbox_invalidate_layer((t_object*)x, NULL, gensym("background_layer")); object_method(x, gensym("coeffs"), 0, NULL); } } return 0; }
t_max_err number_of_microphones_set(t_space *x, t_object *attr, long argc, t_atom *argv) { if(atom_gettype(argv) == A_LONG) { if(atom_getlong(argv) != x->f_number_of_microphones) { delete x->f_viewer; delete x->f_recomposer; x->f_number_of_microphones = Tools::clip(atom_getlong(argv), (long)3, (long)MAX_MICS); if(x->f_number_of_microphones % 2 == 0) x->f_order = (x->f_number_of_microphones - 2) / 2; else x->f_order = (x->f_number_of_microphones - 1) / 2; x->f_number_of_harmonics = x->f_order * 2 + 1; x->f_viewer = new AmbisonicViewer(x->f_order); x->f_recomposer = new ambisonicRecomposer(x->f_order, x->f_number_of_microphones); jbox_invalidate_layer((t_object*)x, NULL, gensym("background_layer")); space_compute(x); } } return 0; }
void hoa_scope_tick(t_hoa_scope *x) { x->f_scope->process(x->f_signals + x->f_index * x->f_scope->getNumberOfHarmonics()); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_harmonics_layer); jbox_redraw((t_jbox *)x); if (sys_getdspstate()) clock_fdelay(x->f_clock, x->f_interval); }
t_max_err hoa_scope_notify(t_hoa_scope *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { t_symbol *name; if (msg == hoa_sym_attr_modified) { name = (t_symbol *)object_method((t_object *)data, hoa_sym_getname); if( name == hoa_sym_bgcolor || name == gensym("order")) { jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_background_layer); } else if(name == gensym("phcolor") || name == gensym("nhcolor")) { jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_harmonics_layer); } jbox_redraw((t_jbox *)x); } return jbox_notify((t_jbox *)x, s, msg, sender, data); }
t_max_err offset_set(t_meter *x, t_object *attr, long argc, t_atom *argv) { if(argc && argv && atom_isNumber(argv)) { const double offset = atom_getfloat(argv) / 360. * HOA_2PI; x->f_vector->setPlanewavesRotation(offset, 0., 0.); x->f_meter->setPlanewavesRotation(offset, 0., 0.); x->f_vector->computeRendering(); x->f_meter->computeRendering(); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_skeleton_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_separator_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_leds_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_vectors_layer); jbox_redraw((t_jbox *)x); } return MAX_ERR_NONE; }
void hoa_gain_setminmax(t_hoa_gain *x, t_symbol *s, long argc, t_atom *argv) { if (argc > 1) { double old_min = x->j_min; double old_size = x->j_size; double a = 0., b = 0.; if (atom_isNumber(argv)) a = (double)atom_getfloat(argv); if (atom_isNumber(argv+1)) b = (double)atom_getfloat(argv+1); if (a == b) { x->j_min = 0.; x->j_size = 1.; } else if (a < b) { x->j_min = a; x->j_size = b - a; } else { x->j_min = b; x->j_size = a - b; } x->f_range[0] = x->j_min; x->f_range[1] = x->j_size + x->j_min; if (old_min != x->j_min || old_size != x->j_size) { jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_background_layer); jbox_invalidate_layer((t_object *)x, NULL, gensym("cursor_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("valuerect_layer")); jbox_redraw((t_jbox *)x); } } }
t_max_err hoa_gain_notify(t_hoa_gain *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { if (msg == hoa_sym_attr_modified) { t_symbol *name = (t_symbol *)object_method((t_object *)data, hoa_sym_getname); if (name == gensym("knobcolor")) { jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_background_layer); jbox_invalidate_layer((t_object *)x, NULL, gensym("cursor_layer")); } else if(name == hoa_sym_bgcolor) { jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_background_layer); } else if (name == gensym("barcolor")) { jbox_invalidate_layer((t_object *)x, NULL, gensym("valuerect_layer")); } jbox_redraw((t_jbox *)x); } return jbox_notify((t_jbox *)x, s, msg, sender, data); }
void meter_tick(t_meter *x) { if(x->f_drawvector == VECTOR_BOTH) { x->f_vector->process(x->f_signals, x->f_vector_coords); } else if(x->f_drawvector == VECTOR_VELOCITY) { x->f_vector->processVelocity(x->f_signals, x->f_vector_coords); } else if(x->f_drawvector == VECTOR_ENERGY) { x->f_vector->processEnergy(x->f_signals, x->f_vector_coords + 2); } x->f_meter->tick(1000 / x->f_interval); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_leds_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_vectors_layer); jbox_redraw((t_jbox *)x); if (sys_getdspstate()) clock_delay(x->f_clock, x->f_interval); }
t_max_err hoa_space_notify(t_hoa_space *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { if (msg == gensym("attr_modified")) { if(s == gensym("miccolor")) { jbox_invalidate_layer((t_object *)x, NULL, gensym("microphones_layer")); } else if(s == gensym("harmocolor")) { jbox_invalidate_layer((t_object *)x, NULL, gensym("microphones_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("harmonics_layer")); } else if(s == gensym("circolor")) { jbox_invalidate_layer((t_object *)x, NULL, gensym("microphones_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("harmonics_layer")); jbox_invalidate_layer((t_object *)x, NULL, gensym("background_layer")); } jbox_redraw((t_jbox *)x); } return ebox_notify((t_jbox *)x, s, msg, sender, data); }
t_max_err meter_notify(t_meter *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { t_symbol *name; if (msg == hoa_sym_attr_modified) { name = (t_symbol *)object_method((t_object *)data, hoa_sym_getname); if(name == gensym("bgcolor") || name == gensym("mbgcolor") || name == gensym("ledsbg") || name == gensym("mborder") || name == gensym("ledbgcolor")) { jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_skeleton_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_separator_layer); } else if(name == gensym("cicolor") || name == gensym("coldcolor") || name == gensym("tepidcolor") || name == gensym("warmcolor") || name == gensym("hotcolor") || name == gensym("overloadcolor") || name == gensym("numleds")) { jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_skeleton_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_separator_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_leds_layer); } else if(name == gensym("vectors") || name == gensym("energycolor") || name == gensym("velocitycolor")) { jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_vectors_layer); } else if(name == gensym("offset") || name == gensym("metersize") || name == gensym("direction") || name == gensym("orientation") || gensym("rotation")) { jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_skeleton_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_separator_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_leds_layer); jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_vectors_layer); } else if(name == gensym("dbperled") || name == gensym("nhotleds") || name == gensym("ntepidleds") || name == gensym("nwarmleds")) { jbox_invalidate_layer((t_object *)x, NULL, hoa_sym_leds_layer); } jbox_redraw((t_jbox *)x); } return jbox_notify((t_jbox *)x, s, msg, sender, data); }