Commit 715f1d73 authored by Thomas Grill's avatar Thomas Grill
Browse files

Corrections for Max 64-bit DSP, especially buffer elements remain 32 bits

parent 611f7225
/* /*
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.
*/ */
...@@ -32,7 +32,7 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::Setup(t_classid id) ...@@ -32,7 +32,7 @@ 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 #if MSP64
,inVec(NULL),outVec(NULL) , inVec(NULL), outVec(NULL)
#else #else
, vecs(NULL) , vecs(NULL)
#endif #endif
...@@ -55,19 +55,31 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::dspmeth64(flext_hdr *x, t_object ...@@ -55,19 +55,31 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::dspmeth64(flext_hdr *x, t_object
{ {
flext_dsp *obj = (flext_dsp *)userparam; flext_dsp *obj = (flext_dsp *)userparam;
obj->blksz = sampleframes;
obj->inVec = ins; obj->inVec = ins;
obj->outVec = outs; obj->outVec = outs;
if(!obj->thisHdr()->z_disabled) 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)
flext_base::indsp = true; {
obj->CbSignal64(); // store current dsp parameters
flext_base::indsp = false; 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 #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)
...@@ -86,29 +98,6 @@ FLEXT_TEMPIMPL(t_int *FLEXT_CLASSDEF(flext_dsp))::dspmeth(t_int *w) ...@@ -86,29 +98,6 @@ FLEXT_TEMPIMPL(t_int *FLEXT_CLASSDEF(flext_dsp))::dspmeth(t_int *w)
} }
return w+2; return w+2;
} }
#endif
#if MSP64
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 = sys_getsr(); // \TODO need not be stored in each object....
// overlap = sp[0]->s_sr/srate; // currently not used/exposed
blksz = sys_getblksize() ;
// with the following call derived classes can do their eventual DSP setup
if(CbDsp64()) {
// set the DSP function
// object_method(dsp64, gensym("dsp_add64"), x, dspmeth64, 0, NULL);
dsp_add64(dsp64,(t_object *)&x->obj,(t_dspmethod)dspmeth64,flags, this);
}
}
#else
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::SetupDsp(t_signal **sp) FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::SetupDsp(t_signal **sp)
{ {
...@@ -121,7 +110,7 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::SetupDsp(t_signal **sp) ...@@ -121,7 +110,7 @@ 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() ?
...@@ -139,8 +128,7 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::SetupDsp(t_signal **sp) ...@@ -139,8 +128,7 @@ 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 #endif
...@@ -156,14 +144,6 @@ FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_dsp))::CbDsp() ...@@ -156,14 +144,6 @@ FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_dsp))::CbDsp()
} }
FLEXT_TEMPIMPL(bool FLEXT_CLASSDEF(flext_dsp))::CbDsp64()
{
// invoke legacy method
m_dsp(Blocksize(),InSig(),OutSig());
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)
{ {
...@@ -175,11 +155,6 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::CbSignal() ...@@ -175,11 +155,6 @@ FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::CbSignal()
// invoke legacy method // invoke legacy method
m_signal(Blocksize(),InSig(),OutSig()); m_signal(Blocksize(),InSig(),OutSig());
} }
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_dsp))::CbSignal64()
{
// invoke legacy method
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 - 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.
*/ */
...@@ -106,13 +106,11 @@ public: ...@@ -106,13 +106,11 @@ public:
\return true (default)... use DSP, false, don't use DSP \return true (default)... use DSP, false, don't use DSP
*/ */
virtual bool CbDsp(); virtual bool CbDsp();
virtual bool CbDsp64();
/*! \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();
virtual void CbSignal64();
/*! \brief Deprecated method for CbSignal /*! \brief Deprecated method for CbSignal
...@@ -179,8 +177,8 @@ private: ...@@ -179,8 +177,8 @@ private:
#if MSP64 #if MSP64
t_signalvec * inVec; t_signalvec *inVec;
t_signalvec * outVec; t_signalvec *outVec;
#else #else
t_signalvec *vecs; t_signalvec *vecs;
#endif #endif
...@@ -195,15 +193,11 @@ private: ...@@ -195,15 +193,11 @@ 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); }
// dsp stuff // dsp stuff
#if MSP64 #if MSP64
static void dspmeth64(flext_hdr *x, t_object *dsp64, double **ins, long numins, double **outs, long numouts, long sampleframes, long flags, void *userparam);
void SetupDsp64(flext_hdr *x, t_object *dsp64, short *count, double samplerate, long maxvectorsize, long flags); void SetupDsp64(flext_hdr *x, t_object *dsp64, short *count, double samplerate, long maxvectorsize, long flags);
#else 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); void SetupDsp(t_signal **sp);
static t_int *dspmeth(t_int *w); static t_int *dspmeth(t_int *w);
#endif #endif
......
/* /*
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.
*/ */
...@@ -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)
......
/* /*
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