From 1d296c40615533f41472fbc5d552f0f9ebd5c2b1 Mon Sep 17 00:00:00 2001 From: Thomas Grill Date: Wed, 18 Jun 2003 02:41:05 +0000 Subject: "" svn path=/trunk/; revision=704 --- externals/grill/flext/tutorial/simple1/main.cpp | 59 ++++++++++++------------- 1 file changed, 28 insertions(+), 31 deletions(-) (limited to 'externals/grill/flext/tutorial/simple1/main.cpp') diff --git a/externals/grill/flext/tutorial/simple1/main.cpp b/externals/grill/flext/tutorial/simple1/main.cpp index 9f0f43e8..ed3c3ea3 100755 --- a/externals/grill/flext/tutorial/simple1/main.cpp +++ b/externals/grill/flext/tutorial/simple1/main.cpp @@ -32,10 +32,36 @@ class simple1: public: // constructor - simple1(); + simple1() + { + // define inlets: + // first inlet must always be of type anything (or signal for dsp objects) + AddInAnything(); // add one inlet for any message + + // define outlets: + AddOutFloat(); // add one float outlet (has index 0) + + // register methods + FLEXT_ADDMETHOD(0,m_float); // register method (for float messages) "m_float" for inlet 0 + } protected: - void m_float(float f); // method for float values + void m_float(float input) // method for float values + { + float result; + + if(input == 0) { + // special case 0 + post("%s - zero can't be inverted!",thisName()); + result = 0; + } + else + // normal case + result = 1/input; + + // output value to outlet + ToOutFloat(0,result); // (0 stands for the outlet index 0 - the leftmost outlet) + } private: FLEXT_CALLBACK_1(m_float,float) // callback for method "m_float" (with one float argument) @@ -45,32 +71,3 @@ private: FLEXT_NEW("simple1",simple1) -simple1::simple1() -{ - // define inlets: - // first inlet must always be of type anything (or signal for dsp objects) - AddInAnything(); // add one inlet for any message - - // define outlets: - AddOutFloat(); // add one float outlet (has index 0) - - // register methods - FLEXT_ADDMETHOD(0,m_float); // register method (for float messages) "m_float" for inlet 0 -} - -void simple1::m_float(float f) -{ - float res; - if(f == 0) { - // special case 0 - post("%s - zero can't be inverted!",thisName()); - res = 0; - } - else - // normal case - res = 1/f; - - // output value to outlet - ToOutFloat(0,res); // (0 stands for the outlet index 0 - the leftmost outlet) -} - -- cgit v1.2.1