// // Copyright: Copyright 2003 Craig Stuart Sapp // Programmer: Craig Stuart Sapp // Creation Date: Wed Feb 5 08:46:00 PST 2003 // Last Modified: Wed Feb 5 08:47:57 PST 2003 // Filename: gettime.c // Web Address: http://peabody.sapp.org/class/dmp2/lab/gettime/gettime.c // Syntax: C; Max4/MSP2 External Object; CodeWarrior 6.0 // OS: Mac OS 9; PPC // // Description: Demonstration of how to keep track of time. // #include "ext.h" typedef struct { t_object max_data; // Max/MSP data, MUST come first in struct void* output; // output bang function pointer } MyObject; void* object_data = NULL; // function declarations: void* create_object (void); void InputBang (MyObject* mo); ///////////////////////////////////////////////////////////////////////// // // Initialization functions // ////////////////////////////// // // main -- called once when the object is created in a patcher window. // void main(void) { setup((t_messlist**)&object_data, (method)create_object, NULL, sizeof(MyObject), NULL, A_NOTHING); addbang((method)InputBang); } ////////////////////////////// // // create_object -- create the data storage for the mydiff object and // and setup input 1. // void* create_object(void) { MyObject* mo = (MyObject*)newobject(object_data); mo->output = intout(mo); return mo; } ///////////////////////////////////////////////////////////////////////// // // Behavior functions // ////////////////////////////// // // InputBang -- behavior of the object when a "bang" message is received. // void InputBang(MyObject* mo) { outlet_int(mo->output, gettime()); }