// // Modified By: Craig Stuart Sapp // Creation Date: Fri Feb 7 13:09:01 PST 2003 // Last Modified: Fri Feb 7 13:09:04 PST 2003 // Filename: thru.c // Source: Ichiro Fujinaga: Max/MSP Externals Tutorial, 2002, v2.41, p.31 // Web Address: http://peabody.sapp.org/class/dmp2/lab/thru/thru.c // Syntax: C; Max4/MSP2 External Object; CodeWarrior 6.0 // OS: Mac OS 9; PPC // // Description: Demonstration of how to receive and send signal data // without modifying the data. // #include "ext.h" #include "z_dsp.h" typedef struct { t_pxobject msp_data; // must always be the first field; used by MSP } MyObject; void* object_data; // pointer to data for object (created in setup()); // function declarations: void main (void); void* create_object (void); void MessageDSP (MyObject* mo, t_signal** signal, short* count); t_int* Perform (t_int *parameters); ////////////////////////////////////////////////////////////////////////// // // Initialization functions: // void main(void) { setup((t_messlist**)&object_data, // the pointer for object data (method)create_object, // your function that initializes object (method)dsp_free, // 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 addmess((method)MessageDSP, "dsp", A_CANT, A_NOTHING); dsp_initclass(); } ////////////////////////////// // // 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 = (MyObject*)newobject(object_data); // create data storage dsp_setup((t_pxobject*)mo, 1); // inlet 1 outlet_new((t_pxobject*)mo, "signal"); // outlet 1 return mo; // return pointer to data storage } ////////////////////////////////////////////////////////////////////////// // // Behavior functions: // ////////////////////////////// // // MessageDSP -- What to do when a "dsp" message arrives into the object. // void MessageDSP(MyObject* mo, t_signal** signal, short* count) { #pragma unused(mo) #pragma unused(count) dsp_add(Perform, 4, 4, signal[0]->s_vec, signal[1]->s_vec, signal[0]->s_n); } ////////////////////////////// // // Perform -- do the action for one sample group (number of samples // specified by the value w[3], which is to copy the input data into // the output data. // t_int* Perform(t_int *parameters) { long pcount = (long) (parameters[1]); t_float *input = (t_float*)(parameters[2]); t_float *output = (t_float*)(parameters[3]); long count = (long) (parameters[4]); long i; for (i=0; i