t_max_err paramui_notify(t_paramui *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { if(msg == _sym_modified) jbox_redraw(&x->box); else if((msg == _sym_attr_modified) && (sender == x)){ t_object *textfield; t_symbol *attrname; attrname = (t_symbol *)object_method((t_object *)data, gensym("getname")); if(attrname == _sym_name){ if(!x->attr_label || x->attr_label == _sym_nothing){ textfield = jbox_get_textfield((t_object*) x); object_method(textfield, gensym("settext"), x->attr_name->s_name); } } else if(attrname == gensym("label")){ if(x->attr_label && x->attr_label != _sym_nothing){ textfield = jbox_get_textfield((t_object*) x); object_method(textfield, gensym("settext"), x->attr_label->s_name); } } else paramui_menu_build(x); // we don't really want this everytime -- make this conditional... jbox_redraw(&x->box); } return MAX_ERR_NONE; }
void uisimp_mousewheel(t_uisimp *x, t_object *patcherview, t_pt pt, long modifiers, double delta_x, double delta_y) { if (delta_y > 0.1) { // some threshold x->j_mouse_counter++; jbox_redraw((t_jbox *)x); } else if (delta_y < -0.1) { x->j_mouse_counter--; jbox_redraw((t_jbox *)x); } }
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; }
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 rd_mousedrag(t_rd *x, t_object *patcherview, t_pt pt, long modifiers){ t_rect rect; jbox_get_rect_for_view((t_object *)x, patcherview, &rect); double f; if(x->mode){ f = rd_scale(pt.y, rect.height, 0, x->freqmin, x->freqmax); }else{ f = rd_scale(pt.x, 0, rect.width, x->freqmin, x->freqmax); } if((f > x->selection.min)&&(f >= x->selection.max)){ x->selection.max = f; }else if ((f <= x->selection.min)&&(f < x->selection.max)){ x->selection.min = f; }else{ //if its in between both, move the closest one. if (abs(f - x->selection.min) < abs(f - x->selection.max)){ x->selection.min = f; } else { x->selection.max = f; } } rd_output_sel(x); jbox_redraw(&(x->ob)); }
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; }
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 odisplay_refresh(t_odisplay *x) { #ifdef OMAX_PD_VERSION x->draw_new_data_indicator = 0; #endif jbox_redraw((t_jbox *)x); }
void odisplay_anything(t_odisplay *x, t_symbol *msg, short argc, t_atom *argv) { t_atom av[argc + 1]; int ac = argc; if (msg) { ac = argc + 1; atom_setsym(av, msg); if (argc > 0) { memcpy(av + 1, argv, argc * sizeof(t_atom)); } } else { memcpy(av, argv, argc * sizeof(t_atom)); } t_osc_msg_u *m = NULL; t_osc_err e = omax_util_maxAtomsToOSCMsg_u(&m, msg, argc, argv); if(e){ return; } t_osc_bndl_u *b = osc_bundle_u_alloc(); osc_bundle_u_addMsg(b, m); t_osc_bndl_s *bs = osc_bundle_u_serialize(b); odisplay_newBundle(x, b, bs); #ifdef OMAX_PD_VERSION x->draw_new_data_indicator = 1; x->have_new_data = 1; jbox_redraw((t_jbox *)x); #else x->draw_new_data_indicator = 1; x->have_new_data = 1; qelem_set(x->qelem); #endif }
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); }
void uisimp_mousedown(t_uisimp *x, t_object *patcherview, t_pt pt, long modifiers) { x->j_mouse_is_down = true; if (x->j_reset) x->j_mouse_counter = 0; jbox_redraw((t_jbox *)x); }
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 hoa_space_mouse_drag(t_hoa_space *x, t_object *patcherview, t_pt pt, long modifiers) { 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 radius = Tools::radius(mapped_x, mapped_y); double angle = Tools::angle(mapped_x, mapped_y) - CICM_PI2; x->f_mousepos.x = radius; x->f_mousepos.y = angle; if(x->f_mode == 0) { hoa_space_draw_points(x, patcherview, pt, modifiers); } else if(x->f_mode == 1) { hoa_space_rotate_points(x, patcherview, pt, modifiers); } else if(x->f_mode == 2) { hoa_space_retract_points(x, patcherview, pt, modifiers); } jbox_redraw((t_jbox *)x); }
void tralala_focusLost(t_tll *x, t_object *pv) { TLL_FLAG_UNSET(TLL_FLAG_FOCUS); tralala_mouseUnselectAll(x); TLL_FLAG_SET(TLL_DIRTY_ZONE | TLL_DIRTY_NOTE); jbox_redraw((t_jbox *)x); }
void uisimp_mouseup(t_uisimp *x, t_object *patcherview, t_pt pt, long modifiers) { t_rect rect; jbox_get_rect_for_view((t_object *)x, patcherview, &rect); jmouse_setposition_view(patcherview, rect.x + x->j_absolute_position.x, rect.y + x->j_absolute_position.y); x->j_mouse_is_down = false; jbox_redraw((t_jbox *)x); }
void uisimp_mouseup(t_uisimp *x, t_object *patcherview, t_pt pt, long modifiers) { if (x->u_mousedowninside) { x->u_state = !x->u_state; uisimp_bang(x); x->u_mousedowninside = false; jbox_redraw((t_jbox *)x); } }
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); }
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_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 rd_displayrange(t_rd *x, double min, double max){ if(min > max){ x->freqmin = max; x->freqmax = min; }else{ x->freqmin = min; x->freqmax = max; } jbox_redraw(&(x->ob)); }
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); }
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 tralala_mouseUp(t_tll *x, t_object *pv, t_pt pt, long m) { TLL_FLAG_UNSET(TLL_FLAG_GRAB | TLL_FLAG_COPY | TLL_FLAG_SHIFT); if (TLL_FLAG_TRUE(TLL_FLAG_LASSO)) { tralala_mouseReleaseLasso(x); TLL_FLAG_SET(TLL_DIRTY_LASSO); jbox_redraw((t_jbox *)x); } }
void uisimp_mousedrag(t_uisimp *x, t_object *patcherview, t_pt pt, long modifiers) { t_rect rect; // test to see if mouse is still inside the object jbox_get_rect_for_view((t_object *)x, patcherview, &rect); // redraw if changed if (pt.x >= 0 && pt.x <= rect.width && pt.y >= 0 && pt.y <= rect.height) { if (!x->u_mousedowninside) { x->u_mousedowninside = true; jbox_redraw((t_jbox *)x); } } else { if (x->u_mousedowninside) { x->u_mousedowninside = false; jbox_redraw((t_jbox *)x); } } }
void scripto_ui_mousedrag(t_scripto_ui *x, t_object *patcherview, t_pt pt, long modifiers) { long row, col, index; char state; scripto_ui_pt2rc(x, pt, &row, &col); index = (row * SCRIPTO_UI_COLS) + col; state = x->u_state[index]; if (state != x->u_dragstate) { // optimization: only redraw if state is changing x->u_state[index] = x->u_dragstate; jbox_redraw((t_jbox *)x); } }
void rd_mousedown(t_rd *x, t_object *patcherview, t_pt pt, long modifiers){ t_rect rect; jbox_get_rect_for_view((t_object *)x, patcherview, &rect); double f; if(x->mode){ f = rd_scale(pt.y, rect.height, 0, x->freqmin, x->freqmax); }else{ f = rd_scale(pt.x, 0, rect.width, x->freqmin, x->freqmax); } x->selection.min = x->selection.max = f; jbox_redraw(&(x->ob)); }
void odisplay_doFullPacket(t_odisplay *x, long len, char *ptr) { osc_bundle_s_wrap_naked_message(len, ptr); long copylen = len; char *copyptr = osc_mem_alloc(len); memcpy(copyptr, ptr, len); t_osc_bndl_s *b = osc_bundle_s_alloc(copylen, copyptr); odisplay_newBundle(x, NULL, b); #ifdef OMAX_PD_VERSION jbox_redraw((t_jbox *)x); #else qelem_set(x->qelem); #endif }
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); }