Max 5 API Reference
00001 /* 00002 * ext_time.h 00003 * 00004 * Copyright 2008 Cycling '74. All rights reserved. 00005 * 00006 */ 00007 00008 #ifndef __EXT_TIME_H__ 00009 #define __EXT_TIME_H__ 00010 00011 #include "ext_itm.h" 00012 00013 BEGIN_USING_C_LINKAGE 00014 00015 00016 00017 /** 00018 A high-level time object for tempo-based scheduling. 00019 00020 @ingroup time 00021 @see #t_itm 00022 @see @ref chapter_itm 00023 */ 00024 typedef t_object t_timeobject; 00025 00026 00027 /*******************************************************************************/ 00028 00029 00030 /** 00031 Stop a currently scheduled time object. 00032 00033 @ingroup time 00034 @param x The time object. 00035 00036 */ 00037 void time_stop(t_timeobject *x); 00038 00039 00040 /** 00041 Execute a time object's task, then if it was already set to execute, reschedule for the current interval value of the object. 00042 00043 @ingroup time 00044 @param x The time object. 00045 00046 */ 00047 void time_tick(t_timeobject *x); 00048 00049 00050 /** 00051 Convert the value of a time object to milliseconds. 00052 00053 @ingroup time 00054 @param x The time object. 00055 @return The time object's value, converted to milliseconds. 00056 */ 00057 double time_getms(t_timeobject *x); 00058 00059 00060 /** 00061 Convert the value of a time object to ticks. 00062 00063 @ingroup time 00064 @param x The time object. 00065 @return The time object's value, converted to ticks. 00066 */ 00067 double time_getticks(t_timeobject *x); 00068 00069 00070 /** 00071 Return the phase of the ITM object (transport) associated with a time object. 00072 00073 @ingroup time 00074 @param tx The time object. 00075 @param phase Pointer to a double to receive the progress within the specified time value of the associated ITM object. 00076 @param slope Pointer to a double to receive the slope (phase difference) within the specified time value of the associated ITM object. 00077 @param ticks 00078 */ 00079 void time_getphase(t_timeobject *tx, double *phase, double *slope, double *ticks); 00080 00081 00082 /** 00083 Specify that a millisecond-based attribute to be updated automatically when the converted milliseconds of the time object's value changes. 00084 00085 @ingroup time 00086 @param x The time object. 00087 @param attr Name of the millisecond based attribute in the owning object that will be updated 00088 @param flags If TIME_FLAGS_LISTENTICKS is passed here, updating will not happen if the time value is fixed (ms) based 00089 */ 00090 void time_listen(t_timeobject *x, t_symbol *attr, long flags); 00091 00092 00093 /** 00094 Set the current value of a time object (either an interval or a position) using a Max message. 00095 00096 @ingroup time 00097 @param tx The time object. 00098 @param s Message selector. 00099 @param argc Count of arguments. 00100 @param argv Message arguments. 00101 */ 00102 void time_setvalue(t_timeobject *tx, t_symbol *s, long argc, t_atom *argv); 00103 00104 /** 00105 Create an attribute permitting a time object to be changed in a user-friendly way. 00106 00107 @ingroup time 00108 @param c Class being initialized. 00109 @param attrname Name of the attribute associated with the time object. 00110 @param attrlabel Descriptive label for the attribute (appears in the inspector) 00111 @param flags Options, see "Flags that determine time object behavior" above 00112 */ 00113 void class_time_addattr(t_class *c, char *attrname, char *attrlabel, long flags); 00114 00115 /** 00116 Create a new time object. 00117 00118 @ingroup time 00119 @param owner Object that will own this time object (task routine, if any, will pass owner as argument). 00120 @param attrname Name of the attribute associated with the time object. 00121 @param tick Task routine that will be executed (can be NULL) 00122 @param flags Options, see "Flags that determine time object behavior" above 00123 @return The newly created #t_timeobject. 00124 */ 00125 void *time_new(t_object *owner, t_symbol *attrname, method tick, long flags); 00126 00127 /** 00128 Return a time object associated with an attribute of an owning object. 00129 00130 @ingroup time 00131 @param owner Object that owns this time object (task routine, if any, will pass owner as argument). 00132 @param attrname Name of the attribute associated with the time object. 00133 @return The #t_timeobject associated with the named attribute. 00134 */ 00135 t_object *time_getnamed(t_object *owner, t_symbol *attrname); 00136 00137 00138 void time_enable_attributes(t_object *x); 00139 00140 /** 00141 Return whether this time object currently holds a fixed (millisecond-based) value. 00142 00143 @ingroup time 00144 @param x Time object. 00145 @return True if time object's current value is fixed, false if it is tempo-relative. 00146 */ 00147 long time_isfixedunit(t_timeobject *x); 00148 00149 00150 /** 00151 Schedule a task, with optional quantization. 00152 00153 @ingroup time 00154 @param x The time object that schedules temporary events (must have been created with TIME_FLAGS_USECLOCK but not TIME_FLAGS_PERMANENT) 00155 @param quantize A time object that holds a quantization interval, can be NULL for no quantization. 00156 */ 00157 void time_schedule(t_timeobject *x, t_timeobject *quantize); 00158 00159 00160 /** 00161 Schedule a task, with optional minimum interval, 00162 00163 @ingroup time 00164 @param x The time object that schedules temporary events (must have been created with TIME_FLAGS_USECLOCK but not TIME_FLAGS_PERMANENT) 00165 @param quantize The minimum interval into the future when the event can occur, can be NULL if there is no minimum interval. 00166 */ 00167 void time_schedule_limit(t_timeobject *x, t_timeobject *quantize); 00168 00169 /** 00170 Schedule a task for right now, with optional quantization. 00171 00172 @ingroup time 00173 @param x The time object that schedules temporary events. The time interval is ignored and 0 ticks is used instead. 00174 @param quantize A time object that holds a quantization interval, can be NULL for no quantization. 00175 */ 00176 void time_now(t_timeobject *x, t_timeobject *quantize); 00177 00178 00179 /** 00180 Return the ITM object associated with this time object. 00181 00182 @ingroup time 00183 @param ox Time object. 00184 @return The associated #t_itm object. 00185 */ 00186 void *time_getitm(t_timeobject *ox); 00187 00188 00189 /** 00190 Calculate the quantized interval (in ticks) if this time object were to be scheduled at the current time. 00191 00192 @ingroup time 00193 @param ox Time object. 00194 @param vitm The associated ITM object (use time_getitm() to determine it). 00195 @param oq A time object that holds a quantization interval, can be NULL. 00196 @return Interval (in ticks) for scheduling this object. 00197 */ 00198 double time_calcquantize(t_timeobject *ox, t_itm *vitm, t_timeobject *oq); 00199 00200 00201 /** 00202 Associate a named setclock object with a time object (unsupported). 00203 00204 @ingroup time 00205 @param tx Time object. 00206 @param sc Name of an associated setclock object. 00207 */ 00208 void time_setclock(t_timeobject *tx, t_symbol *sc); 00209 00210 END_USING_C_LINKAGE 00211 00212 #endif // __EXT_TIME_H__ 00213
Copyright © 2008, Cycling '74