aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext/tutorial/stk1
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-01-02 04:37:31 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-01-02 04:37:31 +0000
commit10e0265429983876e2fd69950df4d51c8faf5635 (patch)
tree3e1c45e40bedd1b92225696ce955b902c4daf8e0 /externals/grill/flext/tutorial/stk1
parent59e66762250fe61d570c5baf6c9ce6896a09e027 (diff)
""
svn path=/trunk/; revision=316
Diffstat (limited to 'externals/grill/flext/tutorial/stk1')
-rw-r--r--externals/grill/flext/tutorial/stk1/main.cpp87
-rw-r--r--externals/grill/flext/tutorial/stk1/stk1.dsp8
2 files changed, 45 insertions, 50 deletions
diff --git a/externals/grill/flext/tutorial/stk1/main.cpp b/externals/grill/flext/tutorial/stk1/main.cpp
index 31e10e70..4f7c7e6a 100644
--- a/externals/grill/flext/tutorial/stk1/main.cpp
+++ b/externals/grill/flext/tutorial/stk1/main.cpp
@@ -1,25 +1,32 @@
/*
flext tutorial - stk 1
-Copyright (c) 2002 Thomas Grill (xovo@gmx.net)
+Copyright (c) 2002,2003 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.
-------------------------------------------------------------------------
This is an example of an external using the STK ("synthesis toolkit") library.
-See http://ccrma-www.stanford.edu/software/stk
+For STK see http://ccrma-www.stanford.edu/software/stk
-*/
+STK needs C++ exceptions switched on.
+
+The STK tutorial examples assume that a static stk library exists which contains all the
+source files (except rt*.cpp) of the stk/src directory.
+The library should be compiled multithreaded and with the appropriate compiler flags for
+the respective platform (e.g. __OS_WINDOWS__ and __LITTLE_ENDIAN__ for Windows)
-#define FLEXT_ATTRIBUTES 1
+*/
#include <flstk.h>
-
+
#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401)
#error You need at least flext version 0.4.1
#endif
+#include "Noise.h"
+
class stk1:
public flext_stk
@@ -30,66 +37,54 @@ public:
stk1();
protected:
-
// these are obligatory!
- virtual void NewObjs();
- virtual void FreeObjs();
- virtual void ProcessObjs();
-
- // space for a few sndobjs
-// Pitch *obj1,*obj2;
-
- float sh1,sh2;
+ virtual bool NewObjs(); // create STK instruments
+ virtual void FreeObjs(); // destroy STK instruments
+ virtual void ProcessObjs(int n); // do DSP processing
- FLEXT_ATTRVAR_F(sh1)
- FLEXT_ATTRVAR_F(sh2)
+private:
+ Noise *inst;
+ static void Setup(t_class *c);
};
FLEXT_NEW_DSP("stk1~",stk1)
-
+
stk1::stk1():
- sh1(1),sh2(1)
+ inst(NULL)
{
- AddInSignal(2); // audio ins
- AddOutSignal(2); // audio outs
-
-// obj1 = obj2 = NULL;
-
- FLEXT_ADDATTR_VAR1("shL",sh1);
- FLEXT_ADDATTR_VAR1("shR",sh2);
+ AddInAnything();
+ AddOutSignal();
}
-// construct needed SndObjs
-void stk1::NewObjs()
+
+// create STK instruments
+bool stk1::NewObjs()
{
+ bool ok = true;
+
// set up objects
-// obj1 = new Pitch(.1f,&InObj(0),sh1,Blocksize(),Samplerate());
-// obj2 = new Pitch(.1f,&InObj(1),sh2,Blocksize(),Samplerate());
+ try {
+ inst = new Noise;
+ }
+ catch (StkError &) {
+ post("%s - Noise() setup failed!",thisName());
+ ok = false;
+ }
+ return ok;
}
-// destroy the SndObjs
+
+// destroy the STK instruments
void stk1::FreeObjs()
{
-// if(obj1) delete obj1;
-// if(obj2) delete obj2;
+ if(inst) delete inst;
}
// this is called on every DSP block
-void stk1::ProcessObjs()
+void stk1::ProcessObjs(int n)
{
-/*
- // set current pitch shift
- obj1->SetPitch(sh1);
- obj2->SetPitch(sh2);
-
- // do processing here!!
- obj1->DoProcess();
- obj2->DoProcess();
-
- // output
- *obj1 >> OutObj(0);
- *obj2 >> OutObj(1);
-*/
+ while(n--) Outlet(0).tick(inst->tick());
}
+
diff --git a/externals/grill/flext/tutorial/stk1/stk1.dsp b/externals/grill/flext/tutorial/stk1/stk1.dsp
index 7ee60fdb..2be3c776 100644
--- a/externals/grill/flext/tutorial/stk1/stk1.dsp
+++ b/externals/grill/flext/tutorial/stk1/stk1.dsp
@@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
-# ADD CPP /nologo /W3 /O2 /I "..\..\source" /I "f:\prog\packs\sndobj\include" /I "f:\prog\packs\stk\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\..\source" /I "f:\prog\packs\sndobj\include" /I "f:\prog\packs\stk\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /D "FLEXT_THREADS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0xc07 /d "NDEBUG"
@@ -53,7 +53,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib /nologo /dll /machine:I386
-# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib stk.lib /nologo /dll /machine:I386 /out:"../pd-msvc/stk1~.dll" /libpath:"..\..\pd-msvc" /libpath:"f:\prog\packs\stk\lib"
+# ADD LINK32 kernel32.lib user32.lib pd.lib pthreadVC.lib flext_t-pdwin.lib stk.lib /nologo /dll /machine:I386 /out:"../pd-msvc/stk1~.dll" /libpath:"..\..\pd-msvc" /libpath:"f:\prog\packs\stk\lib"
!ELSEIF "$(CFG)" == "stk1 - Win32 Debug"
@@ -69,7 +69,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /ZI /Od /I "..\..\source" /I "f:\prog\packs\sndobj\include" /I "f:\prog\packs\stk\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /Fr /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "..\..\source" /I "f:\prog\packs\sndobj\include" /I "f:\prog\packs\stk\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /D "FLEXT_THREADS" /Fr /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0xc07 /d "_DEBUG"
@@ -79,7 +79,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 kernel32.lib user32.lib pd.lib flext_d-pdwin.lib stk.lib /nologo /dll /debug /machine:I386 /out:"msvc-debug/stk1~.dll" /pdbtype:sept /libpath:"..\..\pd-msvc" /libpath:"f:\prog\packs\stk\lib"
+# ADD LINK32 kernel32.lib user32.lib pd.lib pthreadVC.lib flext_td-pdwin.lib stk_d.lib /nologo /dll /debug /machine:I386 /out:"msvc-debug/stk1~.dll" /pdbtype:sept /libpath:"..\..\pd-msvc" /libpath:"f:\prog\packs\stk\lib"
!ENDIF