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 space_mouse_enddrag(t_space *x, t_object *patcherview, t_pt pt, long modifiers) { if(x->f_mode == 1) { for(int i = 0; i < x->f_number_of_microphones; i++) x->f_microphonesValues[i] = x->f_microphonesValuesRotate[i]; } object_notify(x, _sym_modified, NULL); }
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 scripto_ui_mousedown(t_scripto_ui *x, t_object *patcherview, t_pt pt, long modifiers) { long row, col, index; t_celldesc desc; scripto_ui_pt2rc(x, pt, &row, &col); index = (row * SCRIPTO_UI_COLS) + col; x->u_dragstate = !x->u_state[index]; x->u_state[index] = x->u_dragstate; desc.row = row; desc.col = col; desc.state = x->u_dragstate; object_notify((t_object *)x, gensym("cellclicked"), (void *)&desc); jbox_redraw((t_jbox *)x); }
t_max_err HoaConvolve_notify(t_HoaConvolve *x, t_symbol *s, t_symbol *msg, void *sender, void *data) { if(msg == gensym("globalsymbol_binding")) { x->f_buffer = (t_buffer*)x->f_name->s_thing; } else if (msg == gensym("globalsymbol_unbinding")) { x->f_buffer = NULL; } else if (msg == gensym("buffer_modified")) { buffer_setup(x); } return object_notify(x, s, data); }
t_max_err coefficients_set(t_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 < MAX_MICS; 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 < MAX_MICS; i++) { x->f_microphonesValues[i] = atom_getfloat(av + i); } } } else if (atom_gettype(av) == A_LONG && ac >= 2) { if(atom_gettype(av+1) == A_FLOAT && atom_getlong(av) < x->f_number_of_microphones) x->f_microphonesValues[atom_getlong(av)] = Tools::clip((double)atom_getfloat(av+1), 0., 1.); } object_notify(x, _sym_modified, NULL); } space_compute(x); return MAX_ERR_NONE; }
void sheep_baah(t_sheep *x) { // send the notification "sheep" to any object which is listening object_notify(x, gensym("sheep"), NULL); }
/** delete key (sym: dictionary) (sym: search key) delete value (sym: dictionary) (sym: search value) delete entry (sym: dictionary) (sym: search key) (sym: search value) delete dict_cont_entry (sym: dictionary) (sym: search key) (sym: search value) */ void dict_recurse_delete(t_dict_recurse *x, t_symbol *sym, long argc, t_atom *argv) { TRACE("dict_recurse_delete"); t_symbol *search_key_sym = gensym(""); t_symbol *search_val_sym = gensym(""); // Arg 1: Find a key, all entries with the key in, a value, or a dictionary t_symbol *cmd_arg = atom_getsym(argv); t_symbol *cmd_sym = gensym(""); if (cmd_arg == gensym("key")) { x->command = CMD_DELETE_KEY; cmd_sym = gensym("delete key"); } else if (cmd_arg == gensym("value")) { x->command = CMD_DELETE_VALUE_SYM; cmd_sym = gensym("delete value"); } else if (cmd_arg == gensym("entry")) { x->command = CMD_DELETE_ENTRY; cmd_sym = gensym("delete entry"); } else if (cmd_arg == gensym("dict_cont_entry")) { x->command = CMD_DELETE_DICT_CONT_ENTRY; cmd_sym = gensym("delete dict_cont_entry"); } else { MY_ASSERT(1, "delete: Arg 0: Invalid argument."); } switch (x->command) { // delete key (sym: dictionary) (sym: search key) case CMD_DELETE_KEY: search_key_sym = atom_getsym(argv + 2); MY_ASSERT(search_key_sym == gensym(""), "%s: Arg 2: Invalid argument.", cmd_sym->s_name); regexpr_set(x->search_key_expr, search_key_sym); break; // delete value (sym: dictionary) (sym: search value) case CMD_DELETE_VALUE_SYM: search_val_sym = atom_getsym(argv + 2); MY_ASSERT(search_val_sym == gensym(""), "%s: Arg 2: Invalid argument.", cmd_sym->s_name); regexpr_set(x->search_val_expr, search_val_sym); break; // delete entry (sym: dictionary) (sym: search key) (sym: search value) // delete dict_cont_entry (sym: dictionary) (sym: search key) (sym: search value) case CMD_DELETE_ENTRY: case CMD_DELETE_DICT_CONT_ENTRY: search_key_sym = atom_getsym(argv + 2); search_val_sym = atom_getsym(argv + 3); MY_ASSERT(search_key_sym == gensym(""), "%s: Arg 2: Invalid argument.", cmd_sym->s_name); MY_ASSERT(search_val_sym == gensym(""), "%s: Arg 3: Invalid argument.", cmd_sym->s_name); regexpr_set(x->search_key_expr, search_key_sym); regexpr_set(x->search_val_expr, search_val_sym); break; default: break; } // Initialize the object variables if (_dict_recurse_begin_cmd(x, argv + 1, cmd_sym) != ERR_NONE) { return; } // Start the recursion _dict_recurse_dict(x, x->dict, 0); // Notify that the dictionary has been modified if (x->count > 0) { object_notify(x->dict, gensym("modified"), NULL); } // Post a summary for the command POST("%s: %i deletion%s made in \"%s\".", cmd_sym->s_name, x->count, (x->count == 1) ? "" : "s", x->dict_sym->s_name); // End the command _dict_recurse_end_cmd(x); }
/** append in_dict_cont_entry (sym: dictionary) (sym: search key) (sym: search value) (sym: replace key) (sym: replace value) append in_dict_cont_entry_d (sym: dictionary) (sym: search key) (sym: search value) (sym: replace key) (sym: replace dict) append in_dict_from_key (sym: dictionary) (sym: search key) (sym: replace key) (sym: replace dict) */ void dict_recurse_append(t_dict_recurse *x, t_symbol *sym, long argc, t_atom *argv) { TRACE("dict_recurse_append"); t_symbol *search_key_sym = gensym(""); t_symbol *search_val_sym = gensym(""); // Arg 1: Find a key, all entries with the key in, a value, or a dictionary t_symbol *cmd_arg = atom_getsym(argv); t_symbol *cmd_sym = gensym(""); if (cmd_arg == gensym("in_dict_cont_entry")) { x->command = CMD_APPEND_IN_DICT_CONT_ENTRY; cmd_sym = gensym("append in_dict_cont_entry"); } else if (cmd_arg == gensym("in_dict_cont_entry_d")) { x->command = CMD_APPEND_IN_DICT_CONT_ENTRY_D; cmd_sym = gensym("append in_dict_cont_entry_d"); } else if (cmd_arg == gensym("in_dict_from_key")) { x->command = CMD_APPEND_IN_DICT_FROM_KEY; cmd_sym = gensym("append in_dict_from_key"); } else { MY_ASSERT(1, "replace: Arg 0: Invalid argument."); } switch (x->command) { // append in_dict_cont_entry (sym: dictionary) (sym: search key) (sym: search value) (sym: replace key) (sym: replace value) case CMD_APPEND_IN_DICT_CONT_ENTRY: search_key_sym = atom_getsym(argv + 2); search_val_sym = atom_getsym(argv + 3); x->replace_key_sym = atom_getsym(argv + 4); x->replace_val_sym = atom_getsym(argv + 5); MY_ASSERT(search_key_sym == gensym(""), "%s: Arg 2: Invalid argument.", cmd_sym->s_name); MY_ASSERT(search_val_sym == gensym(""), "%s: Arg 3: Invalid argument.", cmd_sym->s_name); MY_ASSERT(x->replace_key_sym == gensym(""), "%s: Arg 4: Invalid argument.", cmd_sym->s_name); MY_ASSERT(x->replace_val_sym == gensym(""), "%s: Arg 5: Invalid argument.", cmd_sym->s_name); regexpr_set(x->search_key_expr, search_key_sym); regexpr_set(x->search_val_expr, search_val_sym); break; // append in_dict_cont_entry_d (sym: dictionary) (sym: search key) (sym: search value) (sym: replace key) (sym: replace dict) case CMD_APPEND_IN_DICT_CONT_ENTRY_D: search_key_sym = atom_getsym(argv + 2); search_val_sym = atom_getsym(argv + 3); x->replace_key_sym = atom_getsym(argv + 4); x->replace_dict_sym = atom_getsym(argv + 5); MY_ASSERT(search_key_sym == gensym(""), "%s: Arg 2: Invalid argument.", cmd_sym->s_name); MY_ASSERT(search_val_sym == gensym(""), "%s: Arg 3: Invalid argument.", cmd_sym->s_name); MY_ASSERT(x->replace_key_sym == gensym(""), "%s: Arg 4: Invalid argument.", cmd_sym->s_name); MY_ASSERT(x->replace_dict_sym == gensym(""), "%s: Arg 5: Invalid argument.", cmd_sym->s_name); regexpr_set(x->search_key_expr, search_key_sym); regexpr_set(x->search_val_expr, search_val_sym); x->replace_dict = dictobj_findregistered_retain(x->replace_dict_sym); MY_ASSERT(!x->replace_dict, "%s: Arg 5: Unable to reference the dictionary named \"%s\".", cmd_sym->s_name, x->replace_dict_sym->s_name); break; // append in_dict_from_key (sym: dictionary) (sym: search key) (sym: replace key) (sym: replace dict) case CMD_APPEND_IN_DICT_FROM_KEY: search_key_sym = atom_getsym(argv + 2); x->replace_key_sym = atom_getsym(argv + 3); x->replace_dict_sym = atom_getsym(argv + 4); MY_ASSERT(search_key_sym == gensym(""), "%s: Arg 2: Invalid argument.", cmd_sym->s_name); MY_ASSERT(x->replace_key_sym == gensym(""), "%s: Arg 3: Invalid argument.", cmd_sym->s_name); MY_ASSERT(x->replace_dict_sym == gensym(""), "%s: Arg 4: Invalid argument.", cmd_sym->s_name); regexpr_set(x->search_key_expr, search_key_sym); x->replace_dict = dictobj_findregistered_retain(x->replace_dict_sym); MY_ASSERT(!x->replace_dict, "%s: Arg 4: Unable to reference the dictionary named \"%s\".", cmd_sym->s_name, x->replace_dict_sym->s_name); break; default: break; } // Initialize the object variables if (_dict_recurse_begin_cmd(x, argv + 1, cmd_sym) != ERR_NONE) { return; } // Start the recursion _dict_recurse_dict(x, x->dict, 0); // Notify that the dictionary has been modified if (x->count > 0) { object_notify(x->dict, gensym("modified"), NULL); } // Post a summary for the command POST("%s: %i entr%s appended in \"%s\".", cmd_sym->s_name, x->count, (x->count == 1) ? "y" : "ies", x->dict_sym->s_name); // End the command _dict_recurse_end_cmd(x); }