Commit d21f56b1 authored by Thomas Grill's avatar Thomas Grill
Browse files

Corrected merge conflict

parents f76472d3 715f1d73
/* /*
flext - C++ layer for Max and Pure Data externals flext - C++ layer for Max and Pure Data externals
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org) Copyright (c) 2001-2017 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution. WARRANTIES, see the file, "license.txt," in this distribution.
*/ */
...@@ -1117,8 +1117,12 @@ private: ...@@ -1117,8 +1117,12 @@ private:
static void cb_assist(flext_hdr *c,void *b,long msg,long arg,char *s); static void cb_assist(flext_hdr *c,void *b,long msg,long arg,char *s);
static void cb_click (flext_hdr *c, Point pt, short mods); static void cb_click (flext_hdr *c, Point pt, short mods);
#if MSP64
static void cb_dsp64(flext_hdr *x, t_object *dsp64, short *count, double samplerate, long maxvectorsize, long flags);
#else
static void cb_dsp(flext_hdr *c,t_signal **s,short *count); static void cb_dsp(flext_hdr *c,t_signal **s,short *count);
#endif
#elif FLEXT_SYS == FLEXT_SYS_PD #elif FLEXT_SYS == FLEXT_SYS_PD
static void cb_click(flext_hdr *z,t_floatarg xpos,t_floatarg ypos,t_floatarg shift,t_floatarg ctrl,t_floatarg alt); static void cb_click(flext_hdr *z,t_floatarg xpos,t_floatarg ypos,t_floatarg shift,t_floatarg ctrl,t_floatarg alt);
......
/* /*
flext - C++ layer for Max and Pure Data externals flext - C++ layer for Max and Pure Data externals
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org) Copyright (c) 2001-2017 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution. WARRANTIES, see the file, "license.txt," in this distribution.
*/ */
...@@ -31,7 +31,11 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::Setup(t_classid id) ...@@ -31,7 +31,11 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::Setup(t_classid id)
FLEXT_TEMPIMPL(FLEXT_CLASSDEF(flext_dsp))::FLEXT_CLASSDEF(flext_dsp)() FLEXT_TEMPIMPL(FLEXT_CLASSDEF(flext_dsp))::FLEXT_CLASSDEF(flext_dsp)()
: srate(sys_getsr()),blksz(sys_getblksize()) : srate(sys_getsr()),blksz(sys_getblksize())
#if MSP64
, inVec(NULL), outVec(NULL)
#else
, vecs(NULL) , vecs(NULL)
#endif
#if FLEXT_SYS != FLEXT_SYS_MAX #if FLEXT_SYS != FLEXT_SYS_MAX
, dspon(true) , dspon(true)
#endif #endif
...@@ -40,11 +44,44 @@ FLEXT_TEMPIMPL(FLEXT_CLASSDEF(flext_dsp))::FLEXT_CLASSDEF(flext_dsp)() ...@@ -40,11 +44,44 @@ FLEXT_TEMPIMPL(FLEXT_CLASSDEF(flext_dsp))::FLEXT_CLASSDEF(flext_dsp)()
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::Exit() FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::Exit()
{ {
flext_base::Exit(); flext_base::Exit();
#if !MSP64
if(vecs) delete[] vecs; if(vecs) delete[] vecs;
#endif
} }
#if MSP64
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::dspmeth64(flext_hdr *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam)
{
flext_dsp *obj = (flext_dsp *)userparam;
obj->blksz = sampleframes;
obj->inVec = ins;
obj->outVec = outs;
if(!obj->thisHdr()->z_disabled) {
flext_base::indsp = true;
obj->CbSignal();
flext_base::indsp = false;
}
}
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::SetupDsp64(flext_hdr *x, t_object *dsp64, short *count, double samplerate, long maxvectorsize, long flags)
{
// store current dsp parameters
srate = samplerate;
// overlap = sp[0]->s_sr/srate; // currently not used/exposed
blksz = maxvectorsize; // will be overwritten in dspmeth64 anyway...
// with the following call derived classes can do their eventual DSP setup
if(CbDsp()) {
// set the DSP function
dsp_add64(dsp64, (t_object *)&x->obj, (t_dspmethod)dspmeth64, 0, this);
}
}
#else
FLEXT_TEMPIMPL(t_int *FLEXT_CLASSDEF(flext_dsp))::dspmeth(t_int *w) FLEXT_TEMPIMPL(t_int *FLEXT_CLASSDEF(flext_dsp))::dspmeth(t_int *w)
{ {
flext_dsp *obj = (flext_dsp *)(size_t)w[1]; flext_dsp *obj = (flext_dsp *)(size_t)w[1];
...@@ -73,8 +110,9 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::SetupDsp(t_signal **sp) ...@@ -73,8 +110,9 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::SetupDsp(t_signal **sp)
#endif #endif
// store current dsp parameters // store current dsp parameters
srate = sys_getsr(); // \TODO need not be stored in each object.... srate = sys_getsr();
// overlap = sp[0]->s_sr/srate; // currently not used/exposed // overlap = sp[0]->s_sr/srate; // currently not used/exposed
blksz = sp[0]->s_n; // is this guaranteed to be the same as sys_getblksize() ? blksz = sp[0]->s_n; // is this guaranteed to be the same as sys_getblksize() ?
// store in and out signal vectors // store in and out signal vectors
...@@ -90,9 +128,11 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::SetupDsp(t_signal **sp) ...@@ -90,9 +128,11 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::SetupDsp(t_signal **sp)
// with the following call derived classes can do their eventual DSP setup // with the following call derived classes can do their eventual DSP setup
if(CbDsp()) { if(CbDsp()) {
// set the DSP function // set the DSP function
dsp_add((t_dspmethod)dspmeth,1,this); dsp_add((t_dspmethod)dspmeth, 1, this);
} }
} }
#endif
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::m_dsp(int /*n*/,t_signalvec const * /*insigs*/,t_signalvec const * /*outsigs*/) {} FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::m_dsp(int /*n*/,t_signalvec const * /*insigs*/,t_signalvec const * /*outsigs*/) {}
...@@ -103,6 +143,7 @@ FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_dsp))::CbDsp() ...@@ -103,6 +143,7 @@ FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_dsp))::CbDsp()
return true; return true;
} }
// this function will be overridden anyway - the probably useless default is clearing all outputs // this function will be overridden anyway - the probably useless default is clearing all outputs
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::m_signal(int n,t_sample *const * /*insigs*/,t_sample *const *outs) FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::m_signal(int n,t_sample *const * /*insigs*/,t_sample *const *outs)
{ {
...@@ -115,7 +156,6 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::CbSignal() ...@@ -115,7 +156,6 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::CbSignal()
m_signal(Blocksize(),InSig(),OutSig()); m_signal(Blocksize(),InSig(),OutSig());
} }
#if FLEXT_SYS == FLEXT_SYS_PD #if FLEXT_SYS == FLEXT_SYS_PD
//void flext_dsp::cb_enable(flext_hdr *c,t_float on) { thisObject(c)->dspon = on != 0; } //void flext_dsp::cb_enable(flext_hdr *c,t_float on) { thisObject(c)->dspon = on != 0; }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_dsp))::cb_enable(flext_base *b,float &on) FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_dsp))::cb_enable(flext_base *b,float &on)
......
/* /*
flext - C++ layer for Max and Pure Data externals flext - C++ layer for Max and Pure Data externals
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org) Copyright (c) 2001-2017 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution. WARRANTIES, see the file, "license.txt," in this distribution.
*/ */
...@@ -54,7 +54,14 @@ public: ...@@ -54,7 +54,14 @@ public:
int Blocksize() const { return blksz; } int Blocksize() const { return blksz; }
//! returns array of input vectors (CntInSig() vectors) //! returns array of input vectors (CntInSig() vectors)
t_sample *const *InSig() const { return vecs; } t_sample *const *InSig() const {
#if MSP64
return inVec;
#else
return vecs;
#endif
}
//! returns input vector //! returns input vector
t_sample *InSig(int i) const { return InSig()[i]; } t_sample *InSig(int i) const { return InSig()[i]; }
...@@ -63,7 +70,10 @@ public: ...@@ -63,7 +70,10 @@ public:
// \todo cache that returned pointer // \todo cache that returned pointer
t_sample *const *OutSig() const t_sample *const *OutSig() const
{ {
int i = CntInSig(); int i = CntInSig();
#if MSP64
return outVec;
#else
// in PD we have at least one actual dsp in vector // in PD we have at least one actual dsp in vector
#if FLEXT_SYS == FLEXT_SYS_PD #if FLEXT_SYS == FLEXT_SYS_PD
return vecs+(i?i:1); return vecs+(i?i:1);
...@@ -71,6 +81,7 @@ public: ...@@ -71,6 +81,7 @@ public:
return vecs+i; return vecs+i;
#else #else
#error #error
#endif
#endif #endif
} }
...@@ -99,7 +110,7 @@ public: ...@@ -99,7 +110,7 @@ public:
/*! \brief Called with every signal vector - here you do the dsp calculation /*! \brief Called with every signal vector - here you do the dsp calculation
flext_dsp::CbSignal fills all output vectors with silence flext_dsp::CbSignal fills all output vectors with silence
*/ */
virtual void CbSignal(); virtual void CbSignal();
/*! \brief Deprecated method for CbSignal /*! \brief Deprecated method for CbSignal
...@@ -163,7 +174,14 @@ private: ...@@ -163,7 +174,14 @@ private:
// not static, could be different in different patchers.. // not static, could be different in different patchers..
float srate; float srate;
int blksz; int blksz;
t_signalvec *vecs;
#if MSP64
t_signalvec *inVec;
t_signalvec *outVec;
#else
t_signalvec *vecs;
#endif
// setup function // setup function
static void Setup(t_classid c); static void Setup(t_classid c);
...@@ -175,10 +193,14 @@ private: ...@@ -175,10 +193,14 @@ private:
static inline flext_dsp *thisObject(flext_hdr *c) { return FLEXT_CAST<flext_dsp *>(c->data); } static inline flext_dsp *thisObject(flext_hdr *c) { return FLEXT_CAST<flext_dsp *>(c->data); }
void SetupDsp(t_signal **sp);
// dsp stuff // dsp stuff
static t_int *dspmeth(t_int *w); #if MSP64
void SetupDsp64(flext_hdr *x, t_object *dsp64, short *count, double samplerate, long maxvectorsize, long flags);
static void dspmeth64(flext_hdr *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam);
#else // Max 32-bits or Pd
void SetupDsp(t_signal **sp);
static t_int *dspmeth(t_int *w);
#endif
}; };
#include "flpopns.h" #include "flpopns.h"
......
/* /*
flext - C++ layer for Max and Pure Data externals flext - C++ layer for Max and Pure Data externals
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org) Copyright (c) 2001-2017 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution. WARRANTIES, see the file, "license.txt," in this distribution.
*/ */
...@@ -159,7 +159,11 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_base))::AddMessageMethods(t_class *c,bo ...@@ -159,7 +159,11 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_base))::AddMessageMethods(t_class *c,bo
if(dsp) { if(dsp) {
#if FLEXT_SYS == FLEXT_SYS_MAX #if FLEXT_SYS == FLEXT_SYS_MAX
#if MSP64
add_dsp64(c,cb_dsp64);
#else
add_dsp(c,cb_dsp); add_dsp(c,cb_dsp);
#endif
dsp_initclass(); dsp_initclass();
#elif FLEXT_SYS == FLEXT_SYS_PD #elif FLEXT_SYS == FLEXT_SYS_PD
if(dspin) if(dspin)
...@@ -246,6 +250,33 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_base))::cb_assist(flext_hdr *c,void * / ...@@ -246,6 +250,33 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_base))::cb_assist(flext_hdr *c,void * /
} }
#endif #endif
#if MSP64
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_base))::cb_dsp64(flext_hdr *c, t_object *dsp64, short *count, double samplerate, long maxvectorsize, long flags)
{
Locker lock(c);
flext_base *bobj = thisObject(c);
#if FLEXT_SYS == FLEXT_SYS_MAX
// we must extra-check here if it is really a DSP object
// obviously, for objects that are part of a library, one dsp_initclass enables DSP for all
if(!bobj->IsDSP()) return;
#endif
flext_dsp *obj;
#ifdef FLEXT_DEBUG
obj = dynamic_cast<flext_dsp *>(bobj);
#else
obj = static_cast<flext_dsp *>(bobj);
#endif
FLEXT_ASSERT(obj);
obj->SetupDsp64(c,dsp64,count,samplerate,maxvectorsize,flags);
}
#else
#if FLEXT_SYS == FLEXT_SYS_MAX #if FLEXT_SYS == FLEXT_SYS_MAX
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_base))::cb_dsp(flext_hdr *c,t_signal **sp,short *count) FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_base))::cb_dsp(flext_hdr *c,t_signal **sp,short *count)
#else #else
...@@ -271,6 +302,11 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_base))::cb_dsp(flext_hdr *c,t_signal ** ...@@ -271,6 +302,11 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_base))::cb_dsp(flext_hdr *c,t_signal **
FLEXT_ASSERT(obj); FLEXT_ASSERT(obj);
obj->SetupDsp(sp); obj->SetupDsp(sp);
} }
#endif
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_base))::CbIdle() { return 0; } FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_base))::CbIdle() { return 0; }
......
/* /*
flext - C++ layer for Max and Pure Data externals flext - C++ layer for Max and Pure Data externals
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org) Copyright (c) 2001-2017 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution. WARRANTIES, see the file, "license.txt," in this distribution.
*/ */
...@@ -24,8 +24,6 @@ WARRANTIES, see the file, "license.txt," in this distribution. ...@@ -24,8 +24,6 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define object_new(clss) pd_new(clss) #define object_new(clss) pd_new(clss)
#define object_free(obj) pd_free(&(obj)->ob_pd) #define object_free(obj) pd_free(&(obj)->ob_pd)
#define add_dsp(clss,meth) class_addmethod(clss, (t_method)meth,gensym(const_cast<char *>("dsp")),A_NULL) #define add_dsp(clss,meth) class_addmethod(clss, (t_method)meth,gensym(const_cast<char *>("dsp")),A_NULL)
#define add_bang(clss,meth) class_addbang(clss, (t_method)meth) #define add_bang(clss,meth) class_addbang(clss, (t_method)meth)
...@@ -73,6 +71,7 @@ typedef void t_outlet; ...@@ -73,6 +71,7 @@ typedef void t_outlet;
//#define object_new(clss) newobject(clss) //#define object_new(clss) newobject(clss)
#define object_free(obj) freeobject((object *)(obj)) #define object_free(obj) freeobject((object *)(obj))
#define add_dsp64(clss,meth) addmess((method)meth,const_cast<char *>("dsp64"),A_CANT,A_NOTHING)
#define add_dsp(clss,meth) addmess((method)meth,const_cast<char *>("dsp"),A_CANT,A_NOTHING) #define add_dsp(clss,meth) addmess((method)meth,const_cast<char *>("dsp"),A_CANT,A_NOTHING)
#define add_bang(clss,meth) addbang((method)meth) #define add_bang(clss,meth) addbang((method)meth)
#define add_float(clss,meth) addfloat((method)meth) #define add_float(clss,meth) addfloat((method)meth)
...@@ -102,8 +101,12 @@ typedef void t_outlet; ...@@ -102,8 +101,12 @@ typedef void t_outlet;
#define outlet_flint(o,v) outlet_int(o,(int)(v)) #define outlet_flint(o,v) outlet_int(o,(int)(v))
#define outlet_symbol(o,s) outlet_anything(o,s,0,NULL) #define outlet_symbol(o,s) outlet_anything(o,s,0,NULL)
typedef t_perfroutine t_dspmethod;
#if MSP64
typedef t_perfroutine64 t_dspmethod;
#else
typedef t_perfroutine t_dspmethod;
#endif
#define CRITON() short state = lockout_set(1) #define CRITON() short state = lockout_set(1)
#define CRITOFF() lockout_set(state) #define CRITOFF() lockout_set(state)
......
/* /*
flext - C++ layer for Max and Pure Data externals flext - C++ layer for Max and Pure Data externals
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org) Copyright (c) 2001-2017 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution. WARRANTIES, see the file, "license.txt," in this distribution.
*/ */
......
/* /*
flext - C++ layer for Max and Pure Data externals flext - C++ layer for Max and Pure Data externals
Copyright (c) 2001-2015 Thomas Grill (gr@grrrr.org) Copyright (c) 2001-2017 Thomas Grill (gr@grrrr.org)
For information on usage and redistribution, and for a DISCLAIMER OF ALL For information on usage and redistribution, and for a DISCLAIMER OF ALL
WARRANTIES, see the file, "license.txt," in this distribution. WARRANTIES, see the file, "license.txt," in this distribution.
*/ */
...@@ -226,16 +226,16 @@ public: ...@@ -226,16 +226,16 @@ public:
# endif # endif
#elif FLEXT_SYS == FLEXT_SYS_MAX #elif FLEXT_SYS == FLEXT_SYS_MAX
# define FLEXT_ARRAYTYPE t_sample # define FLEXT_ARRAYTYPE float
# define FLEXT_GETSAMPLE(x) (x) # define FLEXT_GETSAMPLE(x) (x)
#endif #endif
class Element { class Element {
public: public:
Element() {} Element() {}
Element(t_sample s) { FLEXT_GETSAMPLE(el) = s; } Element(FLEXT_ARRAYTYPE s) { FLEXT_GETSAMPLE(el) = s; }
operator t_sample &() { return FLEXT_GETSAMPLE(el); } operator FLEXT_ARRAYTYPE &() { return FLEXT_GETSAMPLE(el); }
operator t_sample () const { return FLEXT_GETSAMPLE(el); } operator FLEXT_ARRAYTYPE () const { return FLEXT_GETSAMPLE(el); }
protected: protected:
FLEXT_ARRAYTYPE el; FLEXT_ARRAYTYPE el;
}; };
...@@ -335,10 +335,10 @@ public: ...@@ -335,10 +335,10 @@ public:
void Frames(int fr,bool keep = false,bool zero = true); void Frames(int fr,bool keep = false,bool zero = true);
//! Get data value in a platform-independent way //! Get data value in a platform-independent way
inline t_sample operator [](int index) const { return data[index]; } inline FLEXT_ARRAYTYPE operator [](int index) const { return data[index]; }
//! Reference data value in a platform-independent way //! Reference data value in a platform-independent way
inline t_sample &operator [](int index) { return data[index]; } inline FLEXT_ARRAYTYPE &operator [](int index) { return data[index]; }
//! Graphic auto refresh interval //! Graphic auto refresh interval
void SetRefrIntv(float intv); void SetRefrIntv(float intv);
......
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