Max 5 API Reference
00001 /* 00002 * ext_parameter.h 00003 * 00004 * Copyright 2008 Cycling '74. All rights reserved. 00005 * 00006 */ 00007 00008 #ifndef _EXT_PARAMETER_H_ 00009 #define _EXT_PARAMETER_H_ 00010 00011 #include "ext_prefix.h" /* this header must always be first */ 00012 00013 BEGIN_USING_C_LINKAGE 00014 00015 #define PARAMETER_METHOD_FLAG_OVERRIDE (0L) // default is to override normal method with standard method 00016 #define PARAMETER_METHOD_FLAG_PRE (1L << 0L) // user-defined pre-processing function for standard method 00017 #define PARAMETER_METHOD_FLAG_POST (1L << 1L) // user-defined post-processing function for standard method 00018 #define PARAMETER_METHOD_FLAG_FULL (1L << 2L) // user-defined override method 00019 #define PARAMETER_METHOD_FLAG_DONOTHING (1L << 15L) // don't override at all 00020 00021 typedef enum { 00022 PARAM_TYPE_INVALID = -1, 00023 // these parameter types can be automated 00024 PARAM_TYPE_FLOAT = 0, 00025 PARAM_TYPE_INT, 00026 PARAM_TYPE_ENUM, 00027 00028 /////////////////////////////////////////////////////// 00029 // these parameter types cannot be automated, not are they known to anyone but Max 00030 PARAM_TYPE_BLOB, // generic atom type, can be stored, but doesn't use 00031 // any other parameter features at this time (order excepted) 00032 00033 PARAM_TYPE_FILE // not used yet 00034 } PARAM_TYPE; 00035 00036 typedef enum { 00037 PARAM_TYPE_ENABLE_OFF, // parameter type menu not available in the inspector 00038 PARAM_TYPE_ENABLE_ON, // enables basic parameter types Int, Float, Enum in the parameter type menu 00039 PARAM_TYPE_ENABLE_BLOB, // and additionally Blob 00040 } PARAM_TYPE_ENABLE; 00041 00042 typedef enum { 00043 PARAM_UNITSTYLE_INVALID = -1, 00044 PARAM_UNITSTYLE_INT, 00045 PARAM_UNITSTYLE_FLOAT, 00046 PARAM_UNITSTYLE_MS, 00047 PARAM_UNITSTYLE_HZ, 00048 PARAM_UNITSTYLE_DB, 00049 PARAM_UNITSTYLE_PERCENT, 00050 PARAM_UNITSTYLE_PAN, 00051 PARAM_UNITSTYLE_SEMITONE, 00052 PARAM_UNITSTYLE_MIDINOTE, 00053 PARAM_UNITSTYLE_CUSTOM, // what does this do? 00054 PARAM_UNITSTYLE_NATIVE, // use the type of the parameter to determine style 00055 } PARAM_UNITSTYLE; 00056 00057 typedef enum { 00058 PARAM_MOD_INVALID = -1, 00059 PARAM_MOD_NONE, 00060 PARAM_MOD_UNI, 00061 PARAM_MOD_BI, 00062 PARAM_MOD_ADD, 00063 PARAM_MOD_ABS 00064 } PARAM_MOD; 00065 00066 typedef enum { 00067 PARAM_DATA_TYPE_INVALID = -1, 00068 PARAM_DATA_TYPE_VALUE, 00069 PARAM_DATA_TYPE_TYPE, 00070 PARAM_DATA_TYPE_TYPE_ENABLE, 00071 PARAM_DATA_TYPE_ORDER, 00072 PARAM_DATA_TYPE_LONGNAME, 00073 PARAM_DATA_TYPE_SHORTNAME, 00074 PARAM_DATA_TYPE_MIN, 00075 PARAM_DATA_TYPE_MAX, 00076 PARAM_DATA_TYPE_ENUM, 00077 PARAM_DATA_TYPE_MODMODE, 00078 PARAM_DATA_TYPE_MODMIN, 00079 PARAM_DATA_TYPE_MODMAX, 00080 PARAM_DATA_TYPE_INITIAL_ENABLE, 00081 PARAM_DATA_TYPE_INITIAL, 00082 PARAM_DATA_TYPE_INITIAL_EDITABLE, 00083 PARAM_DATA_TYPE_UNITSTYLE, 00084 PARAM_DATA_TYPE_EXPONENT, 00085 PARAM_DATA_TYPE_STEPS, 00086 PARAM_DATA_TYPE_SPEEDLIM, 00087 PARAM_DATA_TYPE_SMOOTHING, 00088 PARAM_DATA_TYPE_UNITS, 00089 PARAM_DATA_TYPE_INFO, 00090 PARAM_DATA_TYPE_FOCUS, // read-only. use object_parameter_wants_focus() to set focus 00091 PARAM_DATA_TYPE_INVISIBLE, 00092 PARAM_DATA_TYPE_AUTOMATION_VALUE, 00093 PARAM_DATA_TYPE_AUTOMATION_STATE, 00094 PARAM_DATA_TYPE_MODULATION_VALUE, 00095 PARAM_DATA_TYPE_DIRTY, 00096 PARAM_DATA_TYPE_ASSIGNMENT_TEXT_MIDI, 00097 PARAM_DATA_TYPE_ASSIGNMENT_TEXT_KEY, 00098 PARAM_DATA_TYPE_ASSIGNMENT_TEXT_MACRO, 00099 PARAM_DATA_TYPE_LEARNING_MODE, 00100 PARAM_DATA_TYPE_FILEREF_PATH, 00101 PARAM_DATA_TYPE_FILEREF_DISPLAYPATH, 00102 PARAM_DATA_TYPE_FILEREF_DISPLAYNAME 00103 } PARAM_DATA_TYPE; 00104 00105 typedef enum { 00106 PARAM_VALUE_SET_DISTANCE = 0, 00107 PARAM_VALUE_SET_REAL, 00108 PARAM_VALUE_SET_GETONLY, 00109 PARAM_VALUE_SET_DISTANCE_NONOTIFY, 00110 PARAM_VALUE_SET_REAL_NONOTIFY 00111 } PARAM_VALUE_SET_TYPE; 00112 00113 typedef enum { 00114 PARAM_VALUE_GET_OUTPUT = 0, 00115 PARAM_VALUE_GET_AUTOMATION, 00116 PARAM_VALUE_GET_MODULATION 00117 } PARAM_VALUE_GET_TYPE; 00118 00119 typedef enum { 00120 PARAM_VALUE_DISTANCE = 0, 00121 PARAM_VALUE_LINEAR, 00122 PARAM_VALUE_REAL 00123 } PARAM_VALUE_FORMAT; 00124 00125 typedef enum { 00126 PARAM_AUTOMATION_STATE_NONE = 0x00, 00127 PARAM_AUTOMATION_STATE_AUTOMATED = 0x01, 00128 PARAM_AUTOMATION_STATE_AUTOENABLED = 0x02, 00129 PARAM_AUTOMATION_STATE_IRRELEVANT = 0x04, 00130 PARAM_AUTOMATION_STATE_DISABLED = 0x08, 00131 PARAM_AUTOMATION_STATE_MACRO = 0x10 00132 } PARAM_AUTOMATION_STATE; 00133 00134 typedef enum { 00135 PARAM_LEARNING_TYPE_NONE = 0, 00136 PARAM_LEARNING_TYPE_MIDI, 00137 PARAM_LEARNING_TYPE_KEY, 00138 PARAM_LEARNING_TYPE_MACRO 00139 } PARAM_LEARNING_TYPE; 00140 00141 typedef struct _parameter_notify_data { 00142 PARAM_DATA_TYPE type; 00143 long ac; 00144 t_atom *av; 00145 } t_parameter_notify_data; 00146 00147 typedef struct _param_class_defcolor_data { 00148 t_class *c; 00149 t_symbol *attrname; 00150 t_symbol *colorname; 00151 } t_param_class_defcolor_data; 00152 00153 // call in main function 00154 t_max_err class_parameter_init(t_class *c); 00155 // call in new function 00156 t_max_err object_parameter_init(t_object *x, PARAM_TYPE type); 00157 // call at end of new function, passing in object dictionary 00158 t_max_err object_parameter_dictionary_process(t_object *x, t_dictionary *d); 00159 // call in free function 00160 t_max_err object_parameter_free(t_object *x); 00161 // call in notify function, return value of TRUE means the notification was param data, in the pnd struct 00162 Boolean object_parameter_notify(t_object *x, t_symbol *s, t_symbol *msg, void *sender, void *data, t_parameter_notify_data *pnd); 00163 // get the value of a particular parameter datum 00164 t_max_err object_parameter_getinfo(t_object *x, PARAM_DATA_TYPE type, long *ac, t_atom **av); 00165 // set the value of a particular parameter datum 00166 t_max_err object_parameter_setinfo(t_object *x, PARAM_DATA_TYPE type, long ac, t_atom *av); 00167 // get the display string for a particular value 00168 t_max_err object_parameter_string_get(t_object *x, double val, char **outstr); 00169 // set object value, returns clipped/stepped value 00170 t_max_err object_parameter_value_set(t_object *x, PARAM_VALUE_SET_TYPE how, double *linear, double *real, char blobnotify); 00171 // get the specified value, in the specified format 00172 t_max_err object_parameter_value_get(t_object *x, PARAM_VALUE_GET_TYPE how, PARAM_VALUE_FORMAT what, double *value); 00173 // set the initial value from the current value 00174 t_max_err object_parameter_current_to_initial(t_object *x); 00175 // get RGB color (0.-1.) based on one of the color symbols, listed below 00176 t_max_err object_parameter_color_get(t_object *x, t_symbol *s, t_jrgba *jrgba); 00177 00178 // set object value using atoms, most useful for blob or file types 00179 t_max_err object_parameter_value_setvalueof(t_object *x, long ac, t_atom *av, char blobnotify); 00180 t_max_err object_parameter_value_setvalueof_nonotify(t_object *x, long ac, t_atom *av, char blobnotify); 00181 // get object value using atoms, most useful for blob or file types 00182 t_max_err object_parameter_value_getvalueof(t_object *x, long *ac, t_atom **av); 00183 // 00184 t_max_err object_parameter_value_changed(t_object *x, char blobnotify); 00185 t_max_err object_parameter_value_changed_nonotify(t_object *x, char blobnotify); 00186 00187 t_max_err class_parameter_addmethod(t_class *c, method m, char *name, long flags, ...); 00188 00189 t_max_err parameter_default_int(t_object *x, long n); 00190 t_max_err parameter_default_float(t_object *x, double d); 00191 t_max_err parameter_default_anything(t_object *x, t_symbol *s, long ac, t_atom *av); 00192 00193 t_max_err class_parameter_register_default_color(t_class *c, t_symbol *attrname, t_symbol *colorname); 00194 00195 Boolean object_parameter_is_initialized(t_object *x); 00196 Boolean object_parameter_is_plugged(t_object *x); 00197 Boolean object_parameter_is_automated(t_object *x); 00198 t_max_err object_parameter_wants_focus(t_object *x); 00199 00200 // available colors 00201 #define ps_surface_bg gensym("surface_bg") 00202 #define ps_control_bg gensym("control_bg") 00203 #define ps_control_text_bg gensym("control_text_bg") 00204 #define ps_control_fg gensym("control_fg") 00205 #define ps_control_fg_on gensym("control_fg_on") 00206 #define ps_control_fg_off gensym("control_fg_off") 00207 #define ps_control_selection gensym("control_selection") 00208 #define ps_control_zombie gensym("control_zombie") 00209 #define ps_value_arc gensym("value_arc") 00210 #define ps_value_bar gensym("value_bar") 00211 #define ps_active_automation gensym("active_automation") 00212 #define ps_inactive_automation gensym("inactive_automation") 00213 #define ps_macro_assigned gensym("macro_assigned") 00214 #define ps_contrast_frame gensym("contrast_frame") 00215 #define ps_key_assignment gensym("key_assignment") 00216 #define ps_midi_assignment gensym("midi_assignment") 00217 #define ps_macro_assignment gensym("macro_assignment") 00218 #define ps_assignment_text_bg gensym("assignment_text_bg") 00219 #define ps_control_fg_zombie gensym("control_fg_zombie") 00220 #define ps_value_arc_zombie gensym("value_arc_zombie") 00221 #define ps_numbox_triangle gensym("numbox_triangle") 00222 #define ps_macro_title gensym("macro_title") 00223 #define ps_selection gensym("selection") 00224 #define ps_led_bg gensym("led_bg") 00225 00226 00227 #define PARAM_COLOR_SURFACE_BG "0.666667 0.698039 0.717647 1." 00228 #define PARAM_COLOR_CONTROL_BG "0.572549 0.615686 0.658824 1." 00229 #define PARAM_COLOR_CONTROL_TEXT_BG "0.909804 0.909804 0.909804 1." 00230 #define PARAM_COLOR_CONTROL_FG "0. 0.019608 0.078431 1." 00231 #define PARAM_COLOR_CONTROL_FG_ON "0. 0. 0. 1." 00232 #define PARAM_COLOR_CONTROL_FG_OFF "0. 0. 0. 1." 00233 #define PARAM_COLOR_CONTROL_SELECTION "0.917647 0.94902 0.054902 1." 00234 #define PARAM_COLOR_CONTROL_ZOMBIE "0.815686 0.847059 0.886275 1." 00235 #define PARAM_COLOR_VALUE_ARC "0.94902 0.376471 0. 1." 00236 #define PARAM_COLOR_VALUE_BAR "0.94902 0.756863 0.309804 1." 00237 #define PARAM_COLOR_ACTIVE_AUTOMATION "1. 0. 0.380392 1." 00238 #define PARAM_COLOR_INACTIVE_AUTOMATION "0.752941 0.784314 0.839216 1." 00239 #define PARAM_COLOR_MACRO_ASSIGNED "0. 0.854902 0.282353 1." 00240 #define PARAM_COLOR_CONTRAST_FRAME "0.27451 0.32549 0.4 1." 00241 #define PARAM_COLOR_KEY_ASSIGNMENT "1. 0.392157 0. 1." 00242 #define PARAM_COLOR_MIDI_ASSIGNMENT "0.266667 0.215686 1. 1." 00243 #define PARAM_COLOR_MACRO_ASSIGNMENT "0. 0.854902 0.282353 1." 00244 #define PARAM_COLOR_ASSIGNMENT_TEXT_BG "0.85098 0.866667 0.886275 1." 00245 #define PARAM_COLOR_CONTROL_FG_ZOMBIE "0.403922 0.454902 0.54902 1." 00246 #define PARAM_COLOR_VALUE_ARC_ZOMBIE "0.752941 0.784314 0.839216 1." 00247 #define PARAM_COLOR_NUMBOX_TRIANGLE "1. 0.380392 0. 1." 00248 #define PARAM_COLOR_MACRO_TITLE "0.85098 0.866667 0.886275 1." 00249 #define PARAM_COLOR_SELECTION "0.976471 0.823529 0.054902 1." 00250 #define PARAM_COLOR_LED_BG "0.498039 0.52549 0.576471 1." 00251 00252 #define PARAM_COLOR_COUNT 24 00253 00254 END_USING_C_LINKAGE 00255 00256 #endif //_EXT_PARAMETER_H_
Copyright © 2008, Cycling '74