Commit a09c81af authored by thomas's avatar thomas
Browse files

no message


git-svn-id: https://svn.grrrr.org/ext/trunk@114 4d9ac71a-51e6-0310-8455-cad1006bcd31
parent 4f516a2f
No preview for this file type
......@@ -15,10 +15,10 @@ Name = flext
ObjDir = :MPW:
MaxSDK = HD Daten:Prog Stuff:Max/MSP SDK:SDK Examples
Includes = -i :,"{MaxSDK}:Max Includes","{MaxSDK}:MSP Includes"
Defines = -d MAXMSP
Defines = -d MAXMSP
Sym-PPC = -sym off
Flags = -bool on -includes unix -opt speed,unroll,unswitch
Flags = -bool on -enum int -includes unix -opt speed,unroll,unswitch
WarnOff = -w 35 # arg not used
PPCCPlusOptions = {Includes} {Sym-PPC} {Defines} {Flags} {WarnOff}
......
......@@ -75,8 +75,9 @@ Version history:
- no support for default arguments (A_DEFFLOAT and A_DEFSYMBOL).. use GIMME instead!
- better graphics update behavior for PD
- improved behavior for invalid/undefined buffers/arrays
- changed "enable" message for DSP objects to "dspon" ("enable" is reserved in Max/MSP)
- 128-bit aligned memory allocation with new[]
- use MaxMSP internal z_disabled flag with for pausing/resuming dsp processing in flext_dsp
- included CHECK_TILDE, a test whether a tilde object (defined as FLEXT_TILDE_*) has a trailing ~. (debug mode only)
0.1.1:
- documentation for flext.h
......@@ -108,7 +109,9 @@ Platform specific:
Restrictions in compatibility mode:
- Max allows only 9 float/int inlets
Porting to new platforms:
- enums must be int-sized
- compiler must support RTTI and bool type
----------------------------------------------------------------------------
......
......@@ -11,11 +11,49 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// This is all derived from GEM by Mark Danks
#include "flbase.h"
#include <string.h>
/////////////////////////////////////////////////////////
//
// flext_obj
//
/////////////////////////////////////////////////////////
flext_hdr *flext_obj::m_holder;
const char *flext_obj::m_holdname;
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
flext_obj :: flext_obj()
: x_obj(m_holder)
, m_name(m_holdname)
{
#ifdef PD
m_canvas = canvas_getcurrent();
#elif defined(MAXMSP)
m_canvas = (t_patcher *)gensym("#P")->s_thing;
x_obj->curinlet = 0;
#endif
}
/////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
flext_obj :: ~flext_obj()
{ }
// --- global overloaded new/delete memory allocation methods ----
/////////////////////////////////////////////////////////
// overloaded new/delete memory allocation methods
//
/////////////////////////////////////////////////////////
void *flext_obj::operator new(size_t bytes)
{
bytes += sizeof(size_t);
......@@ -59,36 +97,25 @@ void flext_obj::operator delete[](void *blk)
/////////////////////////////////////////////////////////
//
// flext_obj
// check if tilde object's name ends with a tilde
//
/////////////////////////////////////////////////////////
flext_hdr *flext_obj::m_holder;
const char *flext_obj::m_holdname;
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
flext_obj :: flext_obj()
: x_obj(m_holder)
, m_name(m_holdname)
#ifdef _DEBUG
bool flext_obj::check_tilde(const char *objname,const char *setupfun)
{
#ifdef PD
m_canvas = canvas_getcurrent();
#elif defined(MAXMSP)
m_canvas = (t_patcher *)gensym("#P")->s_thing;
x_obj->curinlet = 0;
#endif
int stplen = strlen(setupfun);
bool tilde = !strncmp(setupfun,"_tilde",6);
if((objname[strlen(objname)-1] == '~'?1:0)^(tilde?1:0)) {
if(tilde)
error("flext_obj::check_tilde: %s (no trailing ~) is defined as a tilde object",objname);
else
error("flext_obj::check_tilde: %s is no tilde object",objname);
return true;
}
else
return false;
}
/////////////////////////////////////////////////////////
// Destructor
//
/////////////////////////////////////////////////////////
flext_obj :: ~flext_obj()
{ }
#endif
......@@ -138,6 +138,9 @@ class FLEXT_EXT flext_obj
// The object's name in the patcher
const char *m_name;
#ifdef _DEBUG
static bool check_tilde(const char *objname,const char *setupfun);
#endif
};
// This has a dummy arg so that NT won't complain
......@@ -215,12 +218,6 @@ static void cb_setup(t_class *classPtr);
//
// ONE ARGUMENT
/////////////////////////////////////////////////
#define FLEXT_NEW_1ARG(NAME,NEW_CLASS, TYPE, PD_TYPE) \
REAL_NEW_WITH_ARG(NAME,NEW_CLASS, _setup, _class, TYPE, PD_TYPE)
#define FLEXT_TILDE_NEW_1ARG(NAME,NEW_CLASS, TYPE, PD_TYPE) \
REAL_NEW_WITH_ARG(NAME,NEW_CLASS, _tilde_setup, _class, TYPE, PD_TYPE)
#define FLEXT_1ARG(NAME,NEW_CLASS, TYPE) \
REAL_NEW_WITH_ARG(NAME,NEW_CLASS, _setup, _class, TYPE, FLEXTTP(TYPE))
......@@ -230,12 +227,6 @@ static void cb_setup(t_class *classPtr);
//
// GIMME ARGUMENT
/////////////////////////////////////////////////
#define FLEXT_NEW_GIMME(NAME,NEW_CLASS) \
REAL_NEW_WITH_GIMME(NAME,NEW_CLASS, _setup, _class)
#define FLEXT_TILDE_NEW_GIMME(NAME,NEW_CLASS) \
REAL_NEW_WITH_GIMME(NAME,NEW_CLASS, _tilde_setup, _class)
#define FLEXT_GIMME(NAME,NEW_CLASS) \
REAL_NEW_WITH_GIMME(NAME,NEW_CLASS, _setup, _class)
......@@ -245,12 +236,6 @@ static void cb_setup(t_class *classPtr);
//
// TWO ARGUMENTS
/////////////////////////////////////////////////
#define FLEXT_NEW_2ARGS(NAME,NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO) \
REAL_NEW_WITH_ARG_ARG(NAME,NEW_CLASS, _setup, _class, TYPE, PD_TYPE, TTWO, PD_TWO)
#define FLEXT_TILDE_NEW_2ARGS(NAME,NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO) \
REAL_NEW_WITH_ARG_ARG(NAME,NEW_CLASS, _tilde_setup, _class, TYPE, PD_TYPE, TTWO, PD_TWO)
#define FLEXT_2ARGS(NAME,NEW_CLASS, TYPE, TTWO) \
REAL_NEW_WITH_ARG_ARG(NAME,NEW_CLASS, _setup, _class, TYPE, FLEXTTP(TYPE), TTWO, FLEXTTP(TTWO))
......@@ -260,12 +245,6 @@ static void cb_setup(t_class *classPtr);
//
// THREE ARGUMENTS
/////////////////////////////////////////////////
#define FLEXT_NEW_3ARGS(NAME,NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE) \
REAL_NEW_WITH_ARG_ARG_ARG(NAME,NEW_CLASS, _setup, _class, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE)
#define FLEXT_TILDE_NEW_3ARGS(NAME,NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE) \
REAL_NEW_WITH_ARG_ARG_ARG(NAME,NEW_CLASS, _tilde_setup, _class, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE)
#define FLEXT_3ARGS(NAME,NEW_CLASS, TYPE, TTWO, TTHREE) \
REAL_NEW_WITH_ARG_ARG_ARG(NAME,NEW_CLASS, _setup, _class, TYPE, FLEXTTP(TYPE), TTWO, FLEXTTP(TTWO), TTHREE, FLEXTTP(TTHREE))
......@@ -275,12 +254,6 @@ static void cb_setup(t_class *classPtr);
//
// FOUR ARGUMENTS
/////////////////////////////////////////////////
#define FLEXT_NEW_4ARGS(NAME,NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE, TFOUR, PD_FOUR) \
REAL_NEW_WITH_ARG_ARG_ARG_ARG(NAME,NEW_CLASS, _setup, _class, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE, TFOUR, PD_FOUR)
#define FLEXT_TILDE_NEW_4ARGS(NAME,NEW_CLASS, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE, TFOUR, PD_FOUR) \
REAL_NEW_WITH_ARG_ARG_ARG_ARG(NAME,NEW_CLASS, _tilde_setup, _class, TYPE, PD_TYPE, TTWO, PD_TWO, TTHREE, PD_THREE, TFOUR, PD_FOUR)
#define FLEXT_4ARGS(NAME,NEW_CLASS, TYPE, TTWO, TTHREE, TFOUR) \
REAL_NEW_WITH_ARG_ARG_ARG_ARG(NAME,NEW_CLASS, _setup, _class, TYPE, FLEXTTP(TYPE), TTWO, FLEXTTP(TTWO), TTHREE, FLEXTTP(TTHREE), TFOUR, FLEXTTP(TFOUR))
......@@ -306,6 +279,11 @@ static void cb_setup(t_class *classPtr);
#define CLNEW_OPTIONS 0 // flags for class creation
#endif
#ifdef _DEBUG
#define CHECK_TILDE(OBJNAME,SETUPFUN) flext_obj::check_tilde(OBJNAME,SETUPFUN)
#else
#define CHECK_TILDE(OBJNAME,SETUPFUN) ((void)0)
#endif
///////////////////////////////////////////////////////////////////////////////
......@@ -331,7 +309,8 @@ void * EXTERN_NAME ## NEW_CLASS () \
} \
extern "C" { \
FLEXT_EXT void FLEXT_MAIN(NEW_CLASS ## SETUP_FUNCTION)() \
{ \
{ \
CHECK_TILDE(NAME,#SETUP_FUNCTION); \
NEW_CLASS ## EXTERN_NAME = FLEXT_NEWFN( \
FLEXT_CLREF(NAME,NEW_CLASS ## EXTERN_NAME), \
(t_newmethod)EXTERN_NAME ## NEW_CLASS, \
......@@ -359,6 +338,7 @@ void * EXTERN_NAME ## NEW_CLASS (VAR_TYPE arg) \
extern "C" { \
FLEXT_EXT void FLEXT_MAIN(NEW_CLASS ## SETUP_FUNCTION)() \
{ \
CHECK_TILDE(NAME,#SETUP_FUNCTION); \
NEW_CLASS ## EXTERN_NAME = FLEXT_NEWFN( \
FLEXT_CLREF(NAME,NEW_CLASS ## EXTERN_NAME), \
(t_newmethod)EXTERN_NAME ## NEW_CLASS, \
......@@ -387,6 +367,7 @@ void * EXTERN_NAME ## NEW_CLASS (t_symbol *, int argc, t_atom *argv) \
extern "C" { \
FLEXT_EXT void FLEXT_MAIN(NEW_CLASS ## SETUP_FUNCTION)() \
{ \
CHECK_TILDE(NAME,#SETUP_FUNCTION); \
NEW_CLASS ## EXTERN_NAME = FLEXT_NEWFN( \
FLEXT_CLREF(NAME,NEW_CLASS ## EXTERN_NAME), \
(t_newmethod)EXTERN_NAME ## NEW_CLASS, \
......@@ -415,6 +396,7 @@ void * EXTERN_NAME ## NEW_CLASS (ONE_VAR_TYPE arg, TWO_VAR_TYPE argtwo) \
extern "C" { \
FLEXT_EXT void FLEXT_MAIN(NEW_CLASS ## SETUP_FUNCTION)() \
{ \
CHECK_TILDE(NAME,#SETUP_FUNCTION); \
NEW_CLASS ## EXTERN_NAME = FLEXT_NEWFN( \
FLEXT_CLREF(NAME,NEW_CLASS ## EXTERN_NAME), \
(t_newmethod)EXTERN_NAME ## NEW_CLASS, \
......@@ -443,6 +425,7 @@ void * EXTERN_NAME ## NEW_CLASS (ONE_VAR_TYPE arg, TWO_VAR_TYPE argtwo, THREE_VA
extern "C" { \
FLEXT_EXT void FLEXT_MAIN(NEW_CLASS ## SETUP_FUNCTION)() \
{ \
CHECK_TILDE(NAME,#SETUP_FUNCTION); \
NEW_CLASS ## EXTERN_NAME = FLEXT_NEWFN( \
FLEXT_CLREF(NAME,NEW_CLASS ## EXTERN_NAME), \
(t_newmethod)EXTERN_NAME ## NEW_CLASS, \
......@@ -471,6 +454,7 @@ void * EXTERN_NAME ## NEW_CLASS (ONE_VAR_TYPE arg, TWO_VAR_TYPE argtwo, THREE_VA
extern "C" { \
FLEXT_EXT void FLEXT_MAIN(NEW_CLASS ## SETUP_FUNCTION)() \
{ \
CHECK_TILDE(NAME,#SETUP_FUNCTION); \
NEW_CLASS ## EXTERN_NAME = FLEXT_NEWFN( \
FLEXT_CLREF(NAME,NEW_CLASS ## EXTERN_NAME), \
(t_newmethod)EXTERN_NAME ## NEW_CLASS, \
......
......@@ -23,11 +23,15 @@ V flext_dsp::cb_setup(t_class *c)
#endif
add_dsp(c,cb_dsp);
add_method1(c,cb_dspon,"dspon",A_FLINT);
#ifndef MAXMSP
add_method1(c,cb_enable,"enable",A_FLINT);
#endif
}
flext_dsp::flext_dsp():
#ifndef MAXMSP
dspon(true),
#endif
srate(sys_getsr()),
invecs(NULL),outvecs(NULL)
{}
......@@ -43,7 +47,11 @@ flext_dsp::~flext_dsp()
t_int *flext_dsp::dspmeth(t_int *w)
{
flext_dsp *obj = (flext_dsp *)w[1];
#ifdef MAXMSP
if(!obj->thisHdr()->z_disabled)
#else
if(obj->dspon)
#endif
obj->m_signal((I)w[2],obj->invecs,obj->outvecs);
return w+3;
}
......@@ -74,9 +82,9 @@ V flext_dsp::cb_dsp(t_class *c,t_signal **sp)
dsp_add((t_dspmethod)dspmeth,2,obj,sp[0]->s_n);
}
V flext_dsp::cb_dspon(t_class *c,FI on) { thisObject(c)->m_dspon(on != 0); }
V flext_dsp::m_dspon(BL en) { dspon = en; }
#ifndef MAXMSP
V flext_dsp::cb_enable(t_class *c,FI on) { thisObject(c)->m_enable(on != 0); }
V flext_dsp::m_enable(BL en) { dspon = en; }
#endif
......@@ -470,7 +470,6 @@ typedef V (*methfun_0)(flext_base *c);
#define MAXARGS 5
// the reference is needed for PPC processors
typedef V (*methfun_1)(flext_base *c,t_any &);
typedef V (*methfun_2)(flext_base *c,t_any &,t_any &);
typedef V (*methfun_3)(flext_base *c,t_any &,t_any &,t_any &);
......@@ -483,6 +482,8 @@ BL flext_base::m_methodmain(I inlet,const t_symbol *s,I argc,t_atom *argv)
LOG3("methodmain inlet:%i args:%i symbol:%s",inlet,argc,s?s->s_name:"");
// LOG3("offset int=%i, float=%i, symbol=%i",(I)&((t_any *)0)->it,(I)&((t_any *)0)->ft,(I)&((t_any *)0)->st);
for(const methitem *m = mlst; m && !ret; m = m->nxt) {
if(m->tag == sym_anything && m->argc == 1 && m->args[0] == a_gimme) {
// any
......@@ -510,17 +511,23 @@ BL flext_base::m_methodmain(I inlet,const t_symbol *s,I argc,t_atom *argv)
if(is_float(argv[ix])) aargs[ix].ft = get_float(argv[ix]);
else if(is_int(argv[ix])) aargs[ix].ft = (F)get_int(argv[ix]);
else ok = false;
// if(ok) LOG2("int arg %i = %f",ix,aargs[ix].ft);
break;
}
case a_int: {
if(is_float(argv[ix])) aargs[ix].it = (I)get_float(argv[ix]);
else if(is_int(argv[ix])) aargs[ix].it = get_int(argv[ix]);
else ok = false;
// if(ok) LOG2("float arg %i = %i",ix,aargs[ix].it);
break;
}
case a_symbol: {
if(is_symbol(argv[ix])) aargs[ix].st = get_symbol(argv[ix]);
else ok = false;
// if(ok) LOG2("symbol arg %i = %s",ix,get_string(aargs[ix].st));
break;
}
#ifdef PD
......
......@@ -404,9 +404,10 @@ public:
// outsigs: array of output vectors (get number with function cnt_outsig())
virtual V m_signal(I n,F *const *insigs,F *const *outsigs) = 0;
// called with "enable" message: pauses/resumes dsp
virtual V m_dspon(BL on);
// called with "enable" message: pauses/resumes dsp - already defined in MaxMSP
#ifndef MAXMSP
virtual V m_enable(BL on);
#endif
// --- inlet/outlet stuff -----------------------------------------
......@@ -425,13 +426,15 @@ protected:
private:
F srate;
BL dspon;
// callback functions
static V cb_dsp(t_class *c,t_signal **s);
static V cb_dspon(t_class *c,FI on);
#ifndef MAXMSP
static V cb_enable(t_class *c,FI on);
BL dspon;
#endif
// dsp stuff
......
......@@ -29,12 +29,6 @@ once drifted apart in Max and PD. It is not elegant but helps.
#endif
#if 0
// host namespace
namespace flhost {
#endif
// PD stuff
#ifdef PD
......@@ -102,12 +96,6 @@ typedef int t_atomtype;
typedef t_symbol *t_symtype;
#if 0
// end of host namespace
}
#endif
#ifdef _LOG
#define LOG(s) post(s)
#define LOG1(s,v1) post(s,v1)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment