// // Modified By: Craig Stuart Sapp // Creation Date: Mon Feb 3 09:32:00 PST 2003 // Last Modified: Fri Feb 7 08:00:59 PST 2003 // Filename: bang.c // Source: Ichiro Fujinaga: Max/MSP Externals Tutorial, 2002, v2.41, p.3 // Web Address: http://peabody.sapp.org/class/dmp2/lab/bang/bang.c // Syntax: C; Max4/MSP2 External Object; CodeWarrior 6.0 // OS: Mac OS 9; PPC // // Description: Demonstration of how to receive a bang input message. // This object contains one input and one output. The // input accepts bang messages, and will send the bang // to the output immediately when it receives it. // #include "ext.h" typedef stuct { t_object max_data; // must always be the first field; used by Max void* output; // pointer to outlet, need one for each outlet } MyObject; void* object_data; // pointer to data for object (created in setup()); // function declarations: void main (void); void* create_object (void); void InputBang (MyObject* mo); ////////////////////////////////////////////////////////////////////////// // // Initialization functions: // void main(void) { setup((t_messlist**)&object_data, // the pointer for object data (method)create_object, // your function that initializes object NULL, // your function that deinitializes object (short)sizeof(MyObject), // size of your object data struct NULL, // your menu function A_NOTHING); // A list of default parameters types // ending with A_NOTHING addbang((method)InputBang); // associate InputBang with incoming bangs } ////////////////////////////// // // create_object -- object initializing function. This function is // called by the setup() function inside of main(). Place code // here which will be used to initialized your data structure, // as well as the actual creation of the data storage itself. // The setup function will cause the pointer object_data to point // to the created data storage. // void* create_object(void) { MyObject *mo; // temporary pointer mo = (MyObject*)newobject(object_data); // create data storage for object mo->output = bangout(mo); // set 1 output which sends bangs return mo; // return pointer to data storage } ////////////////////////////////////////////////////////////////////////// // // Behavior functions: // ////////////////////////////// // // InputBang -- What to do when a bang message arrives into the object: // if a bang is received from the object input, then send out a bang. // void InputBang(MyObject* mo) { outlet_bang(mo->output); }