Max 5 API Reference
00001 /** 00002 @defgroup misc Miscellaneous 00003 00004 00005 00006 00007 @defgroup console Console 00008 @ingroup misc 00009 00010 00011 00012 00013 @defgroup byteorder Byte Ordering 00014 @ingroup misc 00015 00016 Utilities for swapping the order of bytes to match the Endianness of the required platform. 00017 An introduction to the issue of endianness can be found at http://en.wikipedia.org/wiki/Endianness. 00018 00019 Of particular relevance is that a Macintosh with a PPC processor uses a Big-endian byte ordering, 00020 whereas an Intel processor in a Mac or Windows machine will use a Little-endian byte ordering. 00021 00022 These utilities are defined to assist with cases where byte ordering needs to be manipulated for floats or ints. 00023 Note that floats are subject to the same byte ordering rules as integers. 00024 While the IEEE defines the bits, the machine still defines how the bits are arranged with regard to bytes. 00025 00026 00027 00028 @defgroup expr Extending expr 00029 @ingroup misc 00030 00031 If you want to use C-like variable expressions that are entered by a user 00032 of your object, you can use the "guts" of Max’s expr object in your 00033 object. For example, the if object uses expr routines for evaluating a 00034 conditional expression, so it can decide whether to send the message 00035 after the words then or else. The following functions provide an 00036 interface to expr. 00037 00038 00039 00040 @defgroup tables Table Access 00041 @ingroup misc 00042 00043 You can use these functions to access named table objects. Tables have 00044 names when the user creates a table with an argument. 00045 00046 The scenario for knowing the name of a table but not the object itself is 00047 if you were passed a #t_symbol, either as an argument to your creation 00048 function or in some message, with the implication being "do your 00049 thing with the data in the table named norris." 00050 00051 00052 00053 @defgroup texteditors Text Editor Windows 00054 @ingroup misc 00055 00056 Max has a simple built-in text editor object that can display and 00057 edit text in conjunction with your object. The routines described here 00058 let you create a text editor. 00059 00060 When the editor window is about to be closed, your object could 00061 receive as many as three messages. The first one, okclose, will be sent if 00062 the user has changed the text in the window. This is the standard 00063 okclose message that is sent to all "dirty" windows when they are about 00064 to be closed, but the text editor window object passes it on to you 00065 instead of doing anything itself. Refer to the section on Window 00066 Messages for a description of how to write a method for the okclose 00067 message. It’s not required that you write one—if you don’t, the 00068 behavior of the window will be determined by the setting of the 00069 window’s w_scratch bit. If it’s set, no 00070 confirmation will be asked when a dirty window is closed (and no 00071 okclose message will be sent to the text editor either). The second 00072 message, edclose, requires a method that should be added to your 00073 object at initialization time. The third message, edSave, allows you to 00074 gain access to the text before it is saved, or save it yourself. 00075 00076 @see @ref chapter_enhancements_ed 00077 00078 00079 @defgroup presets Presets 00080 @ingroup misc 00081 00082 Max contains a preset object that has the ability to send preset messages 00083 to some or all of the objects (clients) in a Patcher window. The preset 00084 message, sent when the user is storing a preset, is just a request for your 00085 object to tell the preset object how to restore your internal state to what 00086 it is now. Later, when the user executes a preset, the preset object will 00087 send you back the message you had previously said you wanted. 00088 00089 The dialog goes something like this: 00090 00091 - During a store…preset object to Client object(s): hello, this is the preset message—tell me how to restore your stateClient object to preset object: send me int 34 (for example) 00092 - During an execute…preset object to Client object: int 34 00093 00094 The client object won’t know the difference between receiving int 34 00095 from a preset object and receiving a 34 in its leftmost inlet. 00096 00097 It’s not mandatory for your object to respond to the preset message, 00098 but it is something that will make users happy. All Max user interface 00099 objects currently respond to preset messages. Note that if your object is 00100 not a user interface object and implements a preset method, the user 00101 will need to connect the outlet of the preset object to its leftmost inlet 00102 in order for it to be sent a preset message when the user stores a preset. 00103 00104 Here’s an example of using preset_store() that specifies that the 00105 object would like to receive a set message. We assume it has one field, 00106 myvalue, which it would like to save and restore. 00107 00108 @code 00109 void myobject_preset(myobject *x) 00110 { 00111 preset_store("ossl",x,ob_sym(x),gensym("set"),x->myvalue); 00112 } 00113 @endcode 00114 00115 When this preset is executed, the object will receive a set message 00116 whose argument will be the value of myvalue. Note that the same 00117 thing can be accomplished more easily with preset_set() and 00118 preset_int(). 00119 00120 Don’t pass more than 12 items to preset_store(). If you want to store 00121 a huge amount of data in a preset, use binbuf_insert(). 00122 00123 The following example locates the Binbuf into which the preset data is 00124 being collected, then calls binbuf_insert() on a previously prepared 00125 array of Atoms. It assumes that the state of your object can be restored 00126 with a set message. 00127 00128 @code 00129 void myobject_preset(myObject *x) 00130 { 00131 void *preset_buf;// Binbuf that stores the preset 00132 short atomCount; // number of atoms you’re storing 00133 t_atom atomArray[SOMESIZE];// array of atoms to be stored 00134 00135 // 1. prepare the preset "header" information 00136 atom_setobj(atomArray,x); 00137 atom_setsym(atomArray+1,ob_sym(x)); 00138 atom_setsym(atomArray+2,gensym("set")); 00139 // fill atomArray+3 with object's state here and set atomCount 00140 00141 // 2. find the Binbuf 00142 preset_buf = gensym("_preset")->s_thing; 00143 00144 // 3. store the data 00145 if (preset_buf) { 00146 binbuf_insert(preset_buf,NIL,atomCount,atomArray); 00147 } 00148 } 00149 @endcode 00150 00151 00152 00153 00154 @defgroup evnum Event and File Serial Numbers 00155 @ingroup misc 00156 00157 If you call outlet_int(), outlet_float(), outlet_list(), or 00158 outlet_anything() inside a Qelem or during some idle or interrupt 00159 time, you should increment Max’s Event Serial Number beforehand. 00160 This number can be read by objects that want to know if two messages 00161 they have received occurred at the same logical "time" (in response to 00162 the same event). Max increments the serial number for each tick of the 00163 clock, each key press, mouse click, and MIDI event. Note that this is 00164 different from the file serial number returned by the serialno() 00165 function. The file serial number is only incremented when patchers are 00166 saved in files. If more than one patcher is saved in a file, the file serial 00167 number will change but the event serial number will not. 00168 00169 @section using_event_serial_numbers Using Event Serial Numbers 00170 00171 Here is a Max patch that includes an object called simul that would use 00172 the information returned by evnum_get to return a 1 if the right and 00173 left inlets receive messages at the same time, 0 if not. The number 00174 boxes below show the results of clicking on the button objects or typing 00175 a key. 00176 00177 <img src="figures/event_serialno.png"> 00178 00179 00180 00181 @defgroup loading_max_files Loading Max Files 00182 @ingroup misc 00183 00184 Several high-level functions permit you to load patcher files. These can 00185 be used in sophisticated objects that use Patcher objects to perform 00186 specific tasks. 00187 00188 00189 00190 @defgroup jmonitor Monitors and Displays 00191 @ingroup misc 00192 00193 Functions for finding our information about the environment. 00194 00195 00196 00197 @defgroup jwind Windows 00198 @ingroup misc 00199 00200 00201 00202 @defgroup jmouse Mouse and Keyboard 00203 @ingroup misc 00204 00205 00206 00207 @defgroup examples Example Projects 00208 */
Copyright © 2008, Cycling '74