aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2002-12-31 04:31:58 +0000
committerThomas Grill <xovo@users.sourceforge.net>2002-12-31 04:31:58 +0000
commit0e1fe750cfd8467a80530cbc70326c81f41a8fe5 (patch)
treee83b934dd51b097c35ee3e39e2408202c7c73227
parent8f434561d045ce500b8e07dea39b664a0e4c3a0d (diff)
""
svn path=/trunk/; revision=314
-rw-r--r--externals/grill/flext/flext.dsp12
-rw-r--r--externals/grill/flext/make-files.txt2
-rw-r--r--externals/grill/flext/readme.txt1
-rw-r--r--externals/grill/flext/source/flsndobj.cpp8
-rw-r--r--externals/grill/flext/source/flstk.cpp122
-rw-r--r--externals/grill/flext/source/flstk.h84
6 files changed, 229 insertions, 0 deletions
diff --git a/externals/grill/flext/flext.dsp b/externals/grill/flext/flext.dsp
index 8ebb264f..da59dfb9 100644
--- a/externals/grill/flext/flext.dsp
+++ b/externals/grill/flext/flext.dsp
@@ -298,5 +298,17 @@ SOURCE=.\source\flsndobj.cpp
SOURCE=.\source\flsndobj.h
# End Source File
# End Group
+# Begin Group "STK"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=.\flstk.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\flstk.h
+# End Source File
+# End Group
# End Target
# End Project
diff --git a/externals/grill/flext/make-files.txt b/externals/grill/flext/make-files.txt
index c6228eeb..d477106d 100644
--- a/externals/grill/flext/make-files.txt
+++ b/externals/grill/flext/make-files.txt
@@ -5,3 +5,5 @@ flproxy.cpp flqueue.cpp
HDRS=flprefix.h flstdc.h flbase.h flclass.h fldefs.h flext.h flsupport.h fldsp.h flinternal.h
SRCS_SNDOBJ=flsndobj.cpp
HDRS_SNDOBJ=flsndobj.h
+SRCS_STK=flstk.cpp
+HDRS_STK=flstk.h
diff --git a/externals/grill/flext/readme.txt b/externals/grill/flext/readme.txt
index a3828937..37e600a8 100644
--- a/externals/grill/flext/readme.txt
+++ b/externals/grill/flext/readme.txt
@@ -118,6 +118,7 @@ Version history:
- also FLEXT_DEBUG for debug build
- SndObjs: virtual FreeObject routine is now called at destruction (by parent class), derived class doesn't need to call it!
- SndObjs: fixed typo (numbers of output slots was wrong) and init bug
+- STK: added support for STK object classes (flstk.{h,cpp})
- introduced a helper thread for launching flext threads in the background
- threads are now handled on class (as opposed to object) level
- threads can now be terminated separately
diff --git a/externals/grill/flext/source/flsndobj.cpp b/externals/grill/flext/source/flsndobj.cpp
index c3b54014..090b5034 100644
--- a/externals/grill/flext/source/flsndobj.cpp
+++ b/externals/grill/flext/source/flsndobj.cpp
@@ -1,3 +1,11 @@
+/*
+
+Copyright (c) 2002 Thomas Grill (xovo@gmx.net)
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "license.txt," in this distribution.
+
+*/
+
#include "flext.h"
#include "flsndobj.h"
diff --git a/externals/grill/flext/source/flstk.cpp b/externals/grill/flext/source/flstk.cpp
new file mode 100644
index 00000000..85d52751
--- /dev/null
+++ b/externals/grill/flext/source/flstk.cpp
@@ -0,0 +1,122 @@
+/*
+
+Copyright (c) 2002 Thomas Grill (xovo@gmx.net)
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "license.txt," in this distribution.
+
+*/
+
+#include "flext.h"
+#include "flstk.h"
+
+flext_stk::flext_stk():
+ inobjs(0),outobjs(0),
+ inobj(NULL),outobj(NULL),
+ smprt(0),blsz(0)
+{}
+
+bool flext_stk::Init()
+{
+ bool ret = flext_dsp::Init();
+ inobjs = CntInSig();
+ outobjs = CntOutSig();
+ return ret;
+}
+
+void flext_stk::Exit()
+{
+ ClearObjs();
+ flext_dsp::Exit();
+}
+
+void flext_stk::ClearObjs()
+{
+ FreeObjs();
+
+ if(inobj) {
+ for(int i = 0; i < inobjs; ++i) delete inobj[i];
+ delete[] inobj; inobj = NULL; inobjs = 0;
+ }
+ if(outobj) {
+ for(int i = 0; i < outobjs; ++i) delete outobj[i];
+ delete[] outobj; outobj = NULL; outobjs = 0;
+ }
+}
+
+void flext_stk::m_dsp(int n,t_sample *const *in,t_sample *const *out)
+{
+ // called on every rebuild of the dsp chain
+
+ int i;
+
+ if(Blocksize() != blsz || Samplerate() != smprt) {
+ // block size or sample rate has changed... rebuild all objects
+
+ ClearObjs();
+
+ smprt = Samplerate();
+ blsz = Blocksize();
+ Stk::setSampleRate(smprt);
+
+ // set up sndobjs for inlets and outlets
+ inobj = new Inlet *[inobjs];
+ for(i = 0; i < inobjs; ++i) {
+ inobj[i] = new Inlet(in[i],blsz);
+ }
+ outobj = new Outlet *[outobjs];
+ for(i = 0; i < outobjs; ++i) outobj[i] = new Outlet(out[i],blsz);
+
+ NewObjs();
+ }
+ else {
+ // assign changed input/output vectors
+
+ for(i = 0; i < inobjs; ++i) inobj[i]->SetBuf(in[i]);
+ for(i = 0; i < outobjs; ++i) outobj[i]->SetBuf(out[i]);
+ }
+}
+
+void flext_stk::m_signal(int n,t_sample *const *in,t_sample *const *out)
+{
+ ProcessObjs();
+}
+
+
+// inlet class
+
+flext_stk::Inlet::Inlet(const t_sample *b,int v):
+ buf(b),vecsz(v),
+ index(0)
+{}
+
+t_sample flext_stk::Inlet::tick()
+{
+ if(++index >= vecsz) index = 0;
+ return lastOut();
+}
+
+t_sample *flext_stk::Inlet::tick(t_sample *vector,unsigned int vectorSize)
+{
+ for(unsigned int i = 0; i < vectorSize; i++) vector[i] = tick();
+ return vector;
+}
+
+
+// outlet class
+
+flext_stk::Outlet::Outlet(t_sample *b,int v):
+ buf(b),vecsz(v),
+ index(0)
+{}
+
+void flext_stk::Outlet::tick(t_sample s)
+{
+ buf[index] = s;
+ if(++index >= vecsz) index = 0;
+}
+
+void flext_stk::Outlet::tick(const t_sample *vector,unsigned int vectorSize)
+{
+ for(unsigned int i = 0; i < vectorSize; i++) tick(vector[i]);
+}
+
diff --git a/externals/grill/flext/source/flstk.h b/externals/grill/flext/source/flstk.h
new file mode 100644
index 00000000..e9f12650
--- /dev/null
+++ b/externals/grill/flext/source/flstk.h
@@ -0,0 +1,84 @@
+/*
+
+Copyright (c) 2002 Thomas Grill (xovo@gmx.net)
+For information on usage and redistribution, and for a DISCLAIMER OF ALL
+WARRANTIES, see the file, "license.txt," in this distribution.
+
+*/
+
+#ifndef __FLSTK_H
+#define __FLSTK_H
+
+#include "flext.h"
+
+#include <stk.h>
+
+class FLEXT_SHARE flext_stk:
+ public flext_dsp
+{
+ FLEXT_HEADER(flext_stk,flext_dsp)
+
+public:
+ flext_stk();
+
+ // these have to be overridden in child classes
+ virtual void NewObjs() {}
+ virtual void FreeObjs() {}
+ virtual void ProcessObjs() {}
+
+protected:
+ virtual bool Init();
+ virtual void Exit();
+
+ virtual void m_dsp(int n,t_sample *const *in,t_sample *const *out);
+ virtual void m_signal(int n,t_sample *const *in,t_sample *const *out);
+
+private:
+ //! STK object for reading from inlet buffer
+ class Inlet:
+ public Stk
+ {
+ public:
+ Inlet(const t_sample *b,int vecsz);
+
+ const t_sample *lastFrame() const { return buf+index; }
+ t_sample lastOut() const { return buf[index]; }
+
+ t_sample tick();
+ t_sample *tick(t_sample *vector,unsigned int vectorSize);
+
+ void SetBuf(const t_sample *b) { buf = b; }
+
+ private:
+ const t_sample *buf;
+ int vecsz,index;
+ };
+
+ //! STK object for writing to outlet buffer
+ class Outlet:
+ public Stk
+ {
+ public:
+ Outlet(t_sample *b,int vecsz);
+
+ void tick(t_sample sample);
+ void tick(const t_sample *vector,unsigned int vectorSize);
+
+ void SetBuf(t_sample *b) { buf = b; }
+
+ private:
+ t_sample *buf;
+ int vecsz,index;
+ };
+
+ void ClearObjs();
+
+ int inobjs,outobjs;
+ Inlet **inobj;
+ Outlet **outobj;
+
+ float smprt;
+ int blsz;
+};
+
+#endif