aboutsummaryrefslogtreecommitdiff
path: root/externals
diff options
context:
space:
mode:
authorThomas Grill <xovo@users.sourceforge.net>2003-02-11 04:37:35 +0000
committerThomas Grill <xovo@users.sourceforge.net>2003-02-11 04:37:35 +0000
commit97926eb08cf74f277e522ffb8c7f985457822de3 (patch)
tree680b0e4c564057340a0b528ea6468d4e381a907d /externals
parent06f62d1168209ca6b9e2c3c5264c96a0a4c7cc98 (diff)
""
svn path=/trunk/; revision=388
Diffstat (limited to 'externals')
-rw-r--r--externals/grill/flext/config-pd-darwin.txt3
-rw-r--r--externals/grill/flext/flext.cwbin440355 -> 440331 bytes
-rw-r--r--externals/grill/flext/readme.txt3
-rw-r--r--externals/grill/flext/source/flbuf.cpp22
-rwxr-xr-xexternals/grill/flext/source/fllib.cpp2
-rwxr-xr-xexternals/grill/flext/source/flprefix.h19
-rw-r--r--externals/grill/flext/source/flstdc.h2
-rw-r--r--externals/grill/flext/source/flsupport.cpp11
-rw-r--r--externals/grill/flext/source/flsupport.h16
-rw-r--r--externals/grill/flext/source/flutil.cpp36
-rw-r--r--externals/grill/flext/tutorial/sndobj1/sndobj1.dsp8
-rw-r--r--externals/grill/pool/data.cpp77
-rw-r--r--externals/grill/pool/main.cpp225
-rw-r--r--externals/grill/pool/pool.cpp280
-rwxr-xr-xexternals/grill/pool/pool.cwbin202236 -> 202236 bytes
-rw-r--r--externals/grill/pool/pool.dsp4
-rw-r--r--externals/grill/pool/pool.dtd5
-rw-r--r--externals/grill/pool/pool.h44
-rwxr-xr-xexternals/grill/pool/pool.helpbin5952 -> 6174 bytes
-rw-r--r--externals/grill/pool/pool.pd146
-rw-r--r--externals/grill/pool/readme.txt8
-rwxr-xr-xexternals/grill/xsample/config-pd-darwin.txt5
-rwxr-xr-xexternals/grill/xsample/config-pd-linux.txt6
-rwxr-xr-xexternals/grill/xsample/make-files.txt2
-rwxr-xr-xexternals/grill/xsample/makefile.pd-darwin2
-rw-r--r--externals/grill/xsample/makefile.pd-linux3
-rw-r--r--externals/grill/xsample/maxmsp/xgroove~.helpbin7207 -> 7301 bytes
-rw-r--r--externals/grill/xsample/maxmsp/xplay~.helpbin4649 -> 4788 bytes
-rw-r--r--externals/grill/xsample/pd/xgroove~.pd348
-rw-r--r--externals/grill/xsample/readme.txt28
-rw-r--r--externals/grill/xsample/source/groove.cpp39
-rw-r--r--externals/grill/xsample/source/inter.cpp9
-rwxr-xr-x[-rw-r--r--]externals/grill/xsample/source/inter.h (renamed from externals/grill/xsample/source/inter.ci)54
-rw-r--r--externals/grill/xsample/source/main.cpp61
-rw-r--r--externals/grill/xsample/source/main.h28
-rw-r--r--externals/grill/xsample/source/play.cpp25
-rw-r--r--externals/grill/xsample/source/record.cpp3
-rwxr-xr-xexternals/grill/xsample/xsample.cwbin154591 -> 155147 bytes
-rw-r--r--externals/grill/xsample/xsample.dsp4
39 files changed, 1017 insertions, 511 deletions
diff --git a/externals/grill/flext/config-pd-darwin.txt b/externals/grill/flext/config-pd-darwin.txt
index a07cf62f..e017030e 100644
--- a/externals/grill/flext/config-pd-darwin.txt
+++ b/externals/grill/flext/config-pd-darwin.txt
@@ -22,4 +22,5 @@ INSTDIR=/usr/local/pd/flext
# additional compiler flags
# (check if they fit for your system!)
-# UFLAGS=-maltivec \ No newline at end of file
+UFLAGS=-malign-power -maltivec
+
diff --git a/externals/grill/flext/flext.cw b/externals/grill/flext/flext.cw
index 2d1ea660..79e2896c 100644
--- a/externals/grill/flext/flext.cw
+++ b/externals/grill/flext/flext.cw
Binary files differ
diff --git a/externals/grill/flext/readme.txt b/externals/grill/flext/readme.txt
index 8cbf4049..2196fb72 100644
--- a/externals/grill/flext/readme.txt
+++ b/externals/grill/flext/readme.txt
@@ -111,7 +111,7 @@ see flext.h, fldefs.h and flclass.h for the documented base definitions and clas
Version history:
0.4.2:
-- port for jMax
+- started port for jMax
- moved CLASS_MAINSIGNALIN to class scope (fixed "float method overwritten" warning)
- unix makefiles: CXX should be commented out if standard (to enable environmental settings)
- introduced default returns for the different flext::GetA* functions
@@ -120,6 +120,7 @@ Version history:
- added new POSIX for ThrCond::TimedWait (but still have to find out when to enable it....)
- added CopySamples and ZeroSamples
- fixed bug for DSP object with zero signal inlets in PD
+- added validity check for sample buffers
0.4.1:
- full port for Max@OSX
diff --git a/externals/grill/flext/source/flbuf.cpp b/externals/grill/flext/source/flbuf.cpp
index ebfe2abf..633f0d45 100644
--- a/externals/grill/flext/source/flbuf.cpp
+++ b/externals/grill/flext/source/flbuf.cpp
@@ -119,6 +119,24 @@ int flext::buffer::Set(const t_symbol *s,bool nameonly)
return ret;
}
+bool flext::buffer::Valid() const
+{
+ if(sym) {
+#if FLEXT_SYS == FLEXT_SYS_PD
+ int frames1;
+ t_sample *data1;
+ return garray_getfloatarray(arr, &frames1, &data1) != 0;
+#elif FLEXT_SYS == FLEXT_SYS_MAX
+ const _buffer *p = (const _buffer *)sym->s_thing;
+ return p && p->b_valid;
+#else
+#error
+#endif
+ }
+ else return false;
+}
+
+
bool flext::buffer::Update()
{
if(!Ok()) return false;
@@ -172,7 +190,7 @@ void flext::buffer::Frames(int fr,bool keep)
// copy buffer data to tmp storage
tmp = new t_sample[sz];
if(tmp)
- BlockMoveData(data,tmp,sizeof(t_sample)*sz);
+ CopySamples(data,tmp,sz);
else
error("flext::buffer - not enough memory for keeping buffer~ contents");
}
@@ -190,7 +208,7 @@ void flext::buffer::Frames(int fr,bool keep)
if(tmp) {
// copy data back
- BlockMoveData(tmp,data,sizeof(t_sample)*sz);
+ CopySamples(tmp,data,sz);
delete[] tmp;
}
#else
diff --git a/externals/grill/flext/source/fllib.cpp b/externals/grill/flext/source/fllib.cpp
index 998cbae3..f061c2cb 100755
--- a/externals/grill/flext/source/fllib.cpp
+++ b/externals/grill/flext/source/fllib.cpp
@@ -19,7 +19,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#define ALIASDEL ','
#define ALIASSLASHES ":/\\"
-#if FLEXT_OS == FLEXT_OS_MACOS
+#if FLEXT_OS == FLEXT_OS_MAC
#define ALIASSLASH ':'
#elif FLEXT_OS == FLEXT_OS_WIN
#if FLEXT_SYS == FLEXT_SYS_PD
diff --git a/externals/grill/flext/source/flprefix.h b/externals/grill/flext/source/flprefix.h
index ad1d1edb..dce223e7 100755
--- a/externals/grill/flext/source/flprefix.h
+++ b/externals/grill/flext/source/flprefix.h
@@ -48,14 +48,15 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// --- definitions for FLEXT_OS ----------------------
#define FLEXT_OS_UNKNOWN 0
#define FLEXT_OS_WIN 1
-#define FLEXT_OS_MACOS 2
+#define FLEXT_OS_MAC 2
#define FLEXT_OS_LINUX 3
#define FLEXT_OS_IRIX 4
// --- definitions for FLEXT_OS_API ---------------------
#define FLEXT_OSAPI_UNKNOWN 0
-#define FLEXT_OSAPI_MAC_CARBON 1
-#define FLEXT_OSAPI_MAC_OSX 2
+#define FLEXT_OSAPI_MAC_CLASSIC 1
+#define FLEXT_OSAPI_MAC_CARBON 2
+#define FLEXT_OSAPI_MAC_OSX 3
// --- definitions for FLEXT_CPU ---------------------
#define FLEXT_CPU_UNKNOWN 0
@@ -160,7 +161,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#ifndef FLEXT_OS
#if TARGET_OS_MAC
- #define FLEXT_OS FLEXT_OS_MACOS
+ #define FLEXT_OS FLEXT_OS_MAC
#elif TARGET_OS_WIN32
// assume Windows
#define FLEXT_OS FLEXT_OS_WIN
@@ -205,14 +206,14 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#elif defined(__CYGWIN__) || defined(__CYGWIN32__)
#define FLEXT_OS FLEXT_OS_WIN
#elif defined(__APPLE__) && defined(__MACH__)
- #define FLEXT_OS FLEXT_OS_MACOS
+ #define FLEXT_OS FLEXT_OS_MAC
// how about IRIX??
#else
#define FLEXT_OS FLEXT_OS_UNKNOWN
#endif
#endif
- #if FLEXT_OS == FLEXT_OS_MACOS
+ #if FLEXT_OS == FLEXT_OS_MAC
#define FLEXT_OSAPI FLEXT_OSAPI_MAC_OSX
#else
#define FLEXT_OSAPI FLEXT_OSAPI_UNKNOWN
@@ -234,7 +235,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#ifndef FLEXT_OS
#if defined(macintosh)
- #define FLEXT_OS FLEXT_OS_MACOS
+ #define FLEXT_OS FLEXT_OS_MAC
#else
#define FLEXT_OS FLEXT_OS_UNKNOWN
#endif
@@ -269,7 +270,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#else
#error "Flext SYS/OS combination unknown"
#endif
-#elif FLEXT_OS == FLEXT_OS_MACOS
+#elif FLEXT_OS == FLEXT_OS_MAC
// #pragma message("Compiling for MacOS")
#if FLEXT_SYS == FLEXT_SYS_PD
@@ -288,7 +289,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
// set threading model
#ifdef FLEXT_THREADS
#undef FLEXT_THREADS
- #if FLEXT_OS == FLEXT_OS_MACOS && FLEXT_SYS == FLEXT_SYS_MAX
+ #if FLEXT_OS == FLEXT_OS_MAC && FLEXT_SYS == FLEXT_SYS_MAX
// Max crashes with posix threads (but don't know why...)
#define FLEXT_THREADS FLEXT_THR_MP
#else
diff --git a/externals/grill/flext/source/flstdc.h b/externals/grill/flext/source/flstdc.h
index e36ec4e4..873f4243 100644
--- a/externals/grill/flext/source/flstdc.h
+++ b/externals/grill/flext/source/flstdc.h
@@ -71,7 +71,7 @@ typedef t_clock t_qelem;
// Include the relevant Max/MSP header files
-#if FLEXT_OS == FLEXT_OS_MACOS
+#if FLEXT_OS == FLEXT_OS_MAC
#ifndef __MRC__
#define powerc
#endif
diff --git a/externals/grill/flext/source/flsupport.cpp b/externals/grill/flext/source/flsupport.cpp
index 3c6ab8f3..f3309ab0 100644
--- a/externals/grill/flext/source/flsupport.cpp
+++ b/externals/grill/flext/source/flsupport.cpp
@@ -128,13 +128,22 @@ void flext::GetAString(const t_atom &a,char *buf,int szbuf)
#endif
}
+unsigned long flext::AtomHash(const t_atom &a)
+{
+#if FLEXT_SYS == FLEXT_SYS_MAX || FLEXT_SYS == FLEXT_SYS_PD
+ return ((unsigned long)a.a_type<<28)^*(unsigned long *)&a.a_w;
+#else
+#error Not implemented
+#endif
+}
+
unsigned int flext::FoldBits(unsigned long h,int bits)
{
if(!bits) return 0;
const int hmax = (1<<bits)-1;
unsigned int ret = 0;
for(unsigned int i = 0; i < sizeof(h)*8; i += bits)
- ret = ret^((h>>i)&hmax);
+ ret ^= (h>>i)&hmax;
return ret;
}
diff --git a/externals/grill/flext/source/flsupport.h b/externals/grill/flext/source/flsupport.h
index 66f16dac..497351d2 100644
--- a/externals/grill/flext/source/flsupport.h
+++ b/externals/grill/flext/source/flsupport.h
@@ -95,6 +95,10 @@ public:
*/
bool Ok() const { return sym != NULL && data != NULL; }
+ /*! \brief Check if buffer is valid
+ */
+ bool Valid() const;
+
/*! \brief Check and update if the buffer has been changed (e.g. resized)
*/
bool Update();
@@ -167,17 +171,21 @@ public:
static t_atom *CopyList(int argc,const t_atom *argv);
//! Copy a memory region
static void CopyMem(void *dst,const void *src,int bytes);
- static void CopySamples(t_sample *dst,const t_sample *src,int cnt) { CopyMem(dst,src,cnt*sizeof(t_sample)); }
- //! Zero a memory region
+ static void CopySamples(t_sample *dst,const t_sample *src,int cnt);
+ //! Set a memory region
static void ZeroMem(void *dst,int bytes);
- static void ZeroSamples(t_sample *dst,int cnt) { ZeroMem(dst,cnt*sizeof(t_sample)); }
+ static void SetSamples(t_sample *dst,int cnt,t_sample s);
+ static void ZeroSamples(t_sample *dst,int cnt) { SetSamples(dst,cnt,0); }
//! Sleep for an amount of time
static void Sleep(double s);
+ //! Get a 32 bit hash value frm an atom
+ static unsigned long AtomHash(const t_atom &a);
+
/*! \brief Fold value to a number of bits
- \remark Good for hash generation
+ \remark Good for hash tables
*/
static unsigned int FoldBits(unsigned long h,int bits);
diff --git a/externals/grill/flext/source/flutil.cpp b/externals/grill/flext/source/flutil.cpp
index 1b1d929a..9be38cf1 100644
--- a/externals/grill/flext/source/flutil.cpp
+++ b/externals/grill/flext/source/flutil.cpp
@@ -17,9 +17,9 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#if FLEXT_OS == FLEXT_OS_WIN
#include <windows.h>
-#elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX || defined(__GNUC__)
+#elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX || FLEXT_OSAPI == FLEXT_OSAPI_MAC_OSX
#include <unistd.h>
-#elif FLEXT_OS == FLEXT_OS_MACOS
+#elif FLEXT_OS == FLEXT_OS_MAC
#include <Timer.h>
#include <Threads.h>
#endif
@@ -34,13 +34,41 @@ void flext::ZeroMem(void *dst,int bytes)
memset(dst,0,bytes);
}
+void flext::CopySamples(t_sample *dst,const t_sample *src,int cnt)
+{
+ int n = cnt>>3;
+ cnt -= n<<3;
+ while(n--) {
+ dst[0] = src[0]; dst[1] = src[1];
+ dst[2] = src[2]; dst[3] = src[3];
+ dst[4] = src[4]; dst[5] = src[5];
+ dst[6] = src[6]; dst[7] = src[7];
+ src += 8,dst += 8;
+ }
+
+ while(cnt--) *(dst++) = *(src++);
+}
+
+void flext::SetSamples(t_sample *dst,int cnt,t_sample s)
+{
+ int n = cnt>>3;
+ cnt -= n<<3;
+ while(n--) {
+ dst[0] = dst[1] = dst[2] = dst[3] = dst[4] = dst[5] = dst[6] = dst[7] = s;
+ dst += 8;
+ }
+
+ while(cnt--) *(dst++) = s;
+}
+
+
void flext::Sleep(double s)
{
#if FLEXT_OS == FLEXT_OS_WIN
::Sleep((long)(s*1000.));
-#elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX || defined(__GNUC__)
+#elif FLEXT_OS == FLEXT_OS_LINUX || FLEXT_OS == FLEXT_OS_IRIX || FLEXT_OSAPI == FLEXT_OSAPI_MAC_OSX
usleep((long)(s*1000000.));
-#elif FLEXT_OS == FLEXT_OS_MACOS
+#elif FLEXT_OS == FLEXT_OS_MAC
// that's just for OS9!
UnsignedWide tick;
Microseconds(&tick);
diff --git a/externals/grill/flext/tutorial/sndobj1/sndobj1.dsp b/externals/grill/flext/tutorial/sndobj1/sndobj1.dsp
index 0be35837..36ce74e6 100644
--- a/externals/grill/flext/tutorial/sndobj1/sndobj1.dsp
+++ b/externals/grill/flext/tutorial/sndobj1/sndobj1.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" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /YX /FD /c
+# ADD CPP /nologo /W3 /O2 /I "..\..\source" /I "f:\prog\audio\sndobj\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /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 sndobj.lib /nologo /dll /machine:I386 /out:"../pd-msvc/sndobj1~.dll" /libpath:"..\..\pd-msvc" /libpath:"f:\prog\packs\sndobj\lib"
+# ADD LINK32 kernel32.lib user32.lib pd.lib flext-pdwin.lib sndobj.lib /nologo /dll /machine:I386 /out:"../pd-msvc/sndobj1~.dll" /libpath:"..\..\pd-msvc" /libpath:"f:\prog\audio\sndobj\lib"
!ELSEIF "$(CFG)" == "sndobj1 - 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" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /Fr /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /ZI /Od /I "..\..\source" /I "f:\prog\audio\sndobj\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PD" /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 sndobj.lib /nologo /dll /debug /machine:I386 /out:"msvc-debug/sndobj1~.dll" /pdbtype:sept /libpath:"..\..\pd-msvc" /libpath:"f:\prog\packs\sndobj\lib"
+# ADD LINK32 kernel32.lib user32.lib pd.lib flext_d-pdwin.lib sndobj.lib /nologo /dll /debug /machine:I386 /out:"msvc-debug/sndobj1~.dll" /pdbtype:sept /libpath:"..\..\pd-msvc" /libpath:"f:\prog\audio\sndobj\lib"
!ENDIF
diff --git a/externals/grill/pool/data.cpp b/externals/grill/pool/data.cpp
index 4984129b..8d5d41c4 100644
--- a/externals/grill/pool/data.cpp
+++ b/externals/grill/pool/data.cpp
@@ -16,9 +16,9 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include <stdlib.h>
-pooldata::pooldata(const S *s):
+pooldata::pooldata(const S *s,I vcnt,I dcnt):
sym(s),nxt(NULL),refs(0),
- root(nullatom,NULL)
+ root(nullatom,NULL,vcnt,dcnt)
{
LOG1("new pool %s",sym?flext_base::GetString(sym):"<private>");
}
@@ -28,17 +28,18 @@ pooldata::~pooldata()
LOG1("free pool %s",sym?flext_base::GetString(sym):"<private>");
}
+
const A pooldata::nullatom = { A_NULL };
V pooldata::Reset()
{
- root.Clear(true);
+ root.Reset();
}
-BL pooldata::MkDir(const AtomList &d)
+BL pooldata::MkDir(const AtomList &d,I vcnt,I dcnt)
{
- root.AddDir(d);
+ root.AddDir(d,vcnt,dcnt);
return true;
}
@@ -117,6 +118,12 @@ I pooldata::GetAll(const AtomList &d,A *&keys,AtomList *&lst)
}
}
+I pooldata::CntSub(const AtomList &d)
+{
+ pooldir *pd = root.GetDir(d);
+ return pd?pd->CntSub():0;
+}
+
I pooldata::GetSub(const AtomList &d,const t_atom **&dirs)
{
pooldir *pd = root.GetDir(d);
@@ -144,7 +151,7 @@ pooldir *pooldata::Copy(const AtomList &d,const A &key,BL cut)
if(pd) {
AtomList *val = pd->GetVal(key,cut);
if(val) {
- pooldir *ret = new pooldir(nullatom,NULL);
+ pooldir *ret = new pooldir(nullatom,NULL,pd->VSize(),pd->DSize());
ret->SetVal(key,val);
return ret;
}
@@ -159,7 +166,8 @@ pooldir *pooldata::CopyAll(const AtomList &d,I depth,BL cut)
{
pooldir *pd = root.GetDir(d);
if(pd) {
- pooldir *ret = new pooldir(nullatom,NULL);
+ // What sizes should we choose here?
+ pooldir *ret = new pooldir(nullatom,NULL,pd->VSize(),pd->DSize());
if(pd->Copy(ret,depth,cut))
return ret;
else {
@@ -220,4 +228,59 @@ BL pooldata::SvDir(const AtomList &d,const C *flnm,I depth,BL absdir)
return false;
}
+BL pooldata::LdDirXML(const AtomList &d,const C *flnm,I depth,BL mkdir)
+{
+ pooldir *pd = root.GetDir(d);
+ if(pd) {
+ C tmp[1024];
+ const C *t = CnvFlnm(tmp,flnm,sizeof tmp);
+ if(t) {
+ ifstream fl(t);
+ BL ret = fl.good() != 0;
+ if(ret) {
+ fl.getline(tmp,sizeof tmp);
+ ret = !strncmp(tmp,"<?xml",5);
+ }
+ if(ret) {
+ fl.getline(tmp,sizeof tmp);
+ // DOCTYPE need not be present / only external DOCTYPE is allowed!
+ if(!strncmp(tmp,"<!DOCTYPE",9))
+ fl.getline(tmp,sizeof tmp);
+ ret = !strncmp(tmp,"<pool>",6);
+ }
+ if(ret)
+ ret = pd->LdDirXML(fl,depth,mkdir);
+ return ret;
+ }
+ else return false;
+ }
+ else
+ return false;
+}
+
+BL pooldata::SvDirXML(const AtomList &d,const C *flnm,I depth,BL absdir)
+{
+ pooldir *pd = root.GetDir(d);
+ if(pd) {
+ C tmp[1024];
+ const C *t = CnvFlnm(tmp,flnm,sizeof tmp);
+ if(t) {
+ ofstream fl(t);
+ AtomList tmp;
+ if(absdir) tmp = d;
+ if(fl.good()) {
+ fl << "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" << endl;
+ fl << "<!DOCTYPE pool SYSTEM \"pool.dtd\">" << endl;
+ fl << "<pool>" << endl;
+ BL ret = pd->SvDirXML(fl,depth,tmp);
+ fl << "</pool>" << endl;
+ return ret;
+ }
+ }
+ else return false;
+ }
+ else
+ return false;
+}
+
diff --git a/externals/grill/pool/main.cpp b/externals/grill/pool/main.cpp
index cf513d87..4397a55b 100644
--- a/externals/grill/pool/main.cpp
+++ b/externals/grill/pool/main.cpp
@@ -10,7 +10,10 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include "pool.h"
-#define POOL_VERSION "0.1.1pre"
+#define POOL_VERSION "0.2.0pre"
+
+#define VCNT 64
+#define DCNT 16
class pool:
public flext_base
@@ -22,6 +25,8 @@ public:
~pool();
static V setup(t_classid);
+
+ virtual BL Init();
pooldata *Pool() { return pl; }
@@ -58,6 +63,9 @@ protected:
V m_getall(); // only values
V m_getrec(I argc,const A *argv); // also subdirectories
V m_getsub(I argc,const A *argv); // only subdirectories
+ V m_ogetall(); // only values (ordered)
+ V m_ogetrec(I argc,const A *argv); // also subdirectories (ordered)
+ V m_ogetsub(I argc,const A *argv); // only subdirectories (ordered)
V m_cntall(); // only values
V m_cntrec(I argc,const A *argv); // also subdirectories
V m_cntsub(I argc,const A *argv); // only subdirectories
@@ -74,16 +82,22 @@ protected:
V m_copyrec(I argc,const A *argv) { copyrec(MakeSymbol("copyrec"),argc,argv,false); } // cut directory (and subdirs) into clipboard
// load/save from/to file
- V m_load(I argc,const A *argv);
- V m_save(I argc,const A *argv);
+ V m_load(I argc,const A *argv) { load(argc,argv,false); }
+ V m_save(I argc,const A *argv) { save(argc,argv,false); }
+ V m_loadx(I argc,const A *argv) { load(argc,argv,true); } // XML
+ V m_savex(I argc,const A *argv) { save(argc,argv,true); } // XML
// load directories
- V m_lddir(I argc,const A *argv); // load values into current dir
- V m_ldrec(I argc,const A *argv); // load values recursively
+ V m_lddir(I argc,const A *argv) { lddir(argc,argv,false); } // load values into current dir
+ V m_ldrec(I argc,const A *argv) { ldrec(argc,argv,false); } // load values recursively
+ V m_ldxdir(I argc,const A *argv) { lddir(argc,argv,true); } // load values into current dir (XML)
+ V m_ldxrec(I argc,const A *argv) { ldrec(argc,argv,true); } // load values recursively (XML)
// save directories
- V m_svdir(I argc,const A *argv); // save values in current dir
- V m_svrec(I argc,const A *argv); // save values recursively
+ V m_svdir(I argc,const A *argv) { svdir(argc,argv,false); } // save values in current dir
+ V m_svrec(I argc,const A *argv) { svrec(argc,argv,false); } // save values recursively
+ V m_svxdir(I argc,const A *argv) { svdir(argc,argv,true); } // save values in current dir (XML)
+ V m_svxrec(I argc,const A *argv) { svrec(argc,argv,true); } // save values recursively (XML)
private:
static BL KeyChk(const A &a);
@@ -93,20 +107,29 @@ private:
V set(const S *tag,I argc,const A *argv,BL over);
V getdir(const S *tag);
- I getrec(const S *tag,I level,BL cntonly = false,const AtomList &rdir = AtomList());
- I getsub(const S *tag,I level,BL cntonly = false,const AtomList &rdir = AtomList());
+ I getrec(const S *tag,I level,BL order,BL cntonly = false,const AtomList &rdir = AtomList());
+ I getsub(const S *tag,I level,BL order,BL cntonly = false,const AtomList &rdir = AtomList());
V paste(const S *tag,I argc,const A *argv,BL repl);
V copy(const S *tag,I argc,const A *argv,BL cut);
V copyall(const S *tag,BL cut,I lvls);
V copyrec(const S *tag,I argc,const A *argv,BL cut);
+ V load(I argc,const A *argv,BL xml);
+ V save(I argc,const A *argv,BL xml);
+ V lddir(I argc,const A *argv,BL xml); // load values into current dir
+ V ldrec(I argc,const A *argv,BL xml); // load values recursively
+ V svdir(I argc,const A *argv,BL xml); // save values in current dir
+ V svrec(I argc,const A *argv,BL xml); // save values recursively
+
V echodir() { if(echo) getdir(MakeSymbol("echo")); }
BL priv,absdir,echo;
+ I vcnt,dcnt;
pooldata *pl;
AtomList curdir;
pooldir *clip;
+ const S *holdname;
static pooldata *head,*tail;
@@ -121,6 +144,8 @@ private:
FLEXT_ATTRVAR_B(echo)
FLEXT_ATTRGET_B(priv)
// FLEXT_ATTRGET_B(curdir)
+ FLEXT_ATTRVAR_I(vcnt)
+ FLEXT_ATTRVAR_I(dcnt)
FLEXT_CALLBACK(m_reset)
@@ -144,6 +169,9 @@ private:
FLEXT_CALLBACK(m_getall)
FLEXT_CALLBACK_V(m_getrec)
FLEXT_CALLBACK_V(m_getsub)
+ FLEXT_CALLBACK(m_ogetall)
+ FLEXT_CALLBACK_V(m_ogetrec)
+ FLEXT_CALLBACK_V(m_ogetsub)
FLEXT_CALLBACK(m_cntall)
FLEXT_CALLBACK_V(m_cntrec)
FLEXT_CALLBACK_V(m_cntsub)
@@ -164,6 +192,12 @@ private:
FLEXT_CALLBACK_V(m_ldrec)
FLEXT_CALLBACK_V(m_svdir)
FLEXT_CALLBACK_V(m_svrec)
+ FLEXT_CALLBACK_V(m_loadx)
+ FLEXT_CALLBACK_V(m_savex)
+ FLEXT_CALLBACK_V(m_ldxdir)
+ FLEXT_CALLBACK_V(m_ldxrec)
+ FLEXT_CALLBACK_V(m_svxdir)
+ FLEXT_CALLBACK_V(m_svxrec)
};
FLEXT_NEW_V("pool",pool);
@@ -175,7 +209,7 @@ pooldata *pool::head,*pool::tail;
V pool::setup(t_classid c)
{
post("");
- post("pool %s - hierarchical storage object, (C)2002 Thomas Grill",POOL_VERSION);
+ post("pool %s - hierarchical storage object,(C)2002-2003 Thomas Grill",POOL_VERSION);
post("");
head = tail = NULL;
@@ -184,6 +218,8 @@ V pool::setup(t_classid c)
FLEXT_CADDATTR_VAR1(c,"absdir",absdir);
FLEXT_CADDATTR_VAR1(c,"echodir",echo);
FLEXT_CADDATTR_GET(c,"private",priv);
+ FLEXT_CADDATTR_VAR1(c,"valcnt",vcnt);
+ FLEXT_CADDATTR_VAR1(c,"dircnt",dcnt);
FLEXT_CADDMETHOD_(c,0,"reset",m_reset);
FLEXT_CADDMETHOD_(c,0,"set",m_set);
@@ -207,6 +243,9 @@ V pool::setup(t_classid c)
FLEXT_CADDMETHOD_(c,0,"getall",m_getall);
FLEXT_CADDMETHOD_(c,0,"getrec",m_getrec);
FLEXT_CADDMETHOD_(c,0,"getsub",m_getsub);
+ FLEXT_CADDMETHOD_(c,0,"ogetall",m_ogetall);
+ FLEXT_CADDMETHOD_(c,0,"ogetrec",m_ogetrec);
+ FLEXT_CADDMETHOD_(c,0,"ogetsub",m_ogetsub);
FLEXT_CADDMETHOD_(c,0,"cntall",m_cntall);
FLEXT_CADDMETHOD_(c,0,"cntrec",m_cntrec);
FLEXT_CADDMETHOD_(c,0,"cntsub",m_cntsub);
@@ -227,13 +266,20 @@ V pool::setup(t_classid c)
FLEXT_CADDMETHOD_(c,0,"ldrec",m_ldrec);
FLEXT_CADDMETHOD_(c,0,"svdir",m_svdir);
FLEXT_CADDMETHOD_(c,0,"svrec",m_svrec);
+ FLEXT_CADDMETHOD_(c,0,"loadx",m_loadx);
+ FLEXT_CADDMETHOD_(c,0,"savex",m_savex);
+ FLEXT_CADDMETHOD_(c,0,"ldxdir",m_ldxdir);
+ FLEXT_CADDMETHOD_(c,0,"ldxrec",m_ldxrec);
+ FLEXT_CADDMETHOD_(c,0,"svxdir",m_svxdir);
+ FLEXT_CADDMETHOD_(c,0,"svxrec",m_svxrec);
}
pool::pool(I argc,const A *argv):
absdir(true),echo(false),pl(NULL),
- clip(NULL)
+ clip(NULL),
+ vcnt(VCNT),dcnt(DCNT)
{
- SetPool(argc >= 1 && IsSymbol(argv[0])?GetSymbol(argv[0]):NULL);
+ holdname = argc >= 1 && IsSymbol(argv[0])?GetSymbol(argv[0]):NULL;
AddInAnything();
AddOutList();
@@ -247,6 +293,15 @@ pool::~pool()
FreePool();
}
+BL pool::Init()
+{
+ if(flext_base::Init()) {
+ SetPool(holdname);
+ return true;
+ }
+ else return false;
+}
+
V pool::SetPool(const S *s)
{
if(pl) FreePool();
@@ -257,7 +312,7 @@ V pool::SetPool(const S *s)
}
else {
priv = true;
- pl = new pooldata;
+ pl = new pooldata(NULL,vcnt,dcnt);
}
}
@@ -316,7 +371,7 @@ V pool::m_mkdir(I argc,const A *argv,BL abs)
AtomList ndir;
if(abs) ndir(argc,argv);
else (ndir = curdir).Append(argc,argv);
- if(!pl->MkDir(ndir)) {
+ if(!pl->MkDir(ndir,vcnt,dcnt)) {
post("%s - mkdir: directory couldn't be created",thisName());
}
}
@@ -491,7 +546,7 @@ V pool::m_geti(I ix)
echodir();
}
-I pool::getrec(const S *tag,I level,BL cntonly,const AtomList &rdir)
+I pool::getrec(const S *tag,I level,BL order,BL cntonly,const AtomList &rdir)
{
AtomList gldir(curdir);
gldir.Append(rdir);
@@ -527,7 +582,7 @@ I pool::getrec(const S *tag,I level,BL cntonly,const AtomList &rdir)
else {
I lv = level > 0?level-1:-1;
for(I i = 0; i < cnt; ++i) {
- ret += getrec(tag,lv,cntonly,AtomList(rdir).Append(*r[i]));
+ ret += getrec(tag,lv,order,cntonly,AtomList(rdir).Append(*r[i]));
}
delete[] r;
}
@@ -538,7 +593,15 @@ I pool::getrec(const S *tag,I level,BL cntonly,const AtomList &rdir)
V pool::m_getall()
{
- getrec(MakeSymbol("getall"),0);
+ getrec(MakeSymbol("getall"),0,false);
+ ToOutBang(3);
+
+ echodir();
+}
+
+V pool::m_ogetall()
+{
+ getrec(MakeSymbol("ogetall"),0,true);
ToOutBang(3);
echodir();
@@ -556,21 +619,41 @@ V pool::m_getrec(I argc,const A *argv)
else
post("%s - getrec: invalid level specification - set to infinite",thisName());
}
- getrec(MakeSymbol("getrec"),lvls);
+ getrec(MakeSymbol("getrec"),lvls,false);
+ ToOutBang(3);
+
+ echodir();
+}
+
+
+V pool::m_ogetrec(I argc,const A *argv)
+{
+ I lvls = -1;
+ if(argc > 0) {
+ if(CanbeInt(argv[0])) {
+ if(argc > 1)
+ post("%s - ogetrec: superfluous arguments ignored",thisName());
+ lvls = GetAInt(argv[0]);
+ }
+ else
+ post("%s - ogetrec: invalid level specification - set to infinite",thisName());
+ }
+ getrec(MakeSymbol("ogetrec"),lvls,true);
ToOutBang(3);
echodir();
}
-I pool::getsub(const S *tag,I level,BL cntonly,const AtomList &rdir)
+I pool::getsub(const S *tag,I level,BL order,BL cntonly,const AtomList &rdir)
{
AtomList gldir(curdir);
gldir.Append(rdir);
I ret = 0;
- const A **r;
+ const A **r = NULL;
+ // CntSub is not used here because it doesn't allow checking for valid directory
I cnt = pl->GetSub(gldir,r);
if(!r)
post("%s - %s: error retrieving directories",thisName(),GetString(tag));
@@ -588,7 +671,7 @@ I pool::getsub(const S *tag,I level,BL cntonly,const AtomList &rdir)
}
if(level != 0)
- ret += getsub(tag,lv,cntonly,AtomList(rdir).Append(*r[i]));
+ ret += getsub(tag,lv,order,cntonly,AtomList(rdir).Append(*r[i]));
}
delete[] r;
}
@@ -609,7 +692,27 @@ V pool::m_getsub(I argc,const A *argv)
post("%s - getsub: invalid level specification - set to 0",thisName());
}
- getsub(MakeSymbol("getsub"),lvls);
+ getsub(MakeSymbol("getsub"),lvls,false);
+ ToOutBang(3);
+
+ echodir();
+}
+
+
+V pool::m_ogetsub(I argc,const A *argv)
+{
+ I lvls = 0;
+ if(argc > 0) {
+ if(CanbeInt(argv[0])) {
+ if(argc > 1)
+ post("%s - ogetsub: superfluous arguments ignored",thisName());
+ lvls = GetAInt(argv[0]);
+ }
+ else
+ post("%s - ogetsub: invalid level specification - set to 0",thisName());
+ }
+
+ getsub(MakeSymbol("ogetsub"),lvls,true);
ToOutBang(3);
echodir();
@@ -619,7 +722,7 @@ V pool::m_getsub(I argc,const A *argv)
V pool::m_cntall()
{
const S *tag = MakeSymbol("cntall");
- I cnt = getrec(tag,0,true);
+ I cnt = getrec(tag,0,false,true);
ToOutSymbol(3,tag);
ToOutBang(2);
ToOutBang(1);
@@ -643,7 +746,7 @@ V pool::m_cntrec(I argc,const A *argv)
post("%s - %s: invalid level specification - set to infinite",thisName(),GetString(tag));
}
- I cnt = getrec(tag,lvls,true);
+ I cnt = getrec(tag,lvls,false,true);
ToOutSymbol(3,tag);
ToOutBang(2);
ToOutBang(1);
@@ -668,7 +771,7 @@ V pool::m_cntsub(I argc,const A *argv)
post("%s - %s: invalid level specification - set to 0",thisName(),GetString(tag));
}
- I cnt = getsub(tag,lvls,true);
+ I cnt = getsub(tag,lvls,false,true);
ToOutSymbol(3,tag);
ToOutBang(2);
ToOutBang(1);
@@ -760,58 +863,60 @@ V pool::copyrec(const S *tag,I argc,const A *argv,BL cut)
copyall(tag,cut,lvls);
}
-V pool::m_load(I argc,const A *argv)
+V pool::load(I argc,const A *argv,BL xml)
{
+ const C *sym = xml?"loadx":"load";
const C *flnm = NULL;
if(argc > 0) {
- if(argc > 1) post("%s - load: superfluous arguments ignored",thisName());
+ if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
- post("%s - load: no filename given",thisName());
- else if(!pl->Load(flnm))
- post("%s - load: error loading data",thisName());
+ post("%s - %s: no filename given",thisName(),sym);
+ else if(!(xml?pl->LoadXML(flnm):pl->Load(flnm)))
+ post("%s - %s: error loading data",thisName(),sym);
echodir();
}
-V pool::m_save(I argc,const A *argv)
+V pool::save(I argc,const A *argv,BL xml)
{
+ const C *sym = xml?"savex":"save";
const C *flnm = NULL;
if(argc > 0) {
- if(argc > 1) post("%s - save: superfluous arguments ignored",thisName());
+ if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
- post("%s - save: no filename given",thisName());
- else if(!pl->Save(flnm))
- post("%s - save: error saving data",thisName());
+ post("%s - %s: no filename given",thisName(),sym);
+ else if(!(xml?pl->SaveXML(flnm):pl->Save(flnm)))
+ post("%s - %s: error saving data",thisName(),sym);
echodir();
}
-V pool::m_lddir(I argc,const A *argv)
+V pool::lddir(I argc,const A *argv,BL xml)
{
+ const C *sym = xml?"ldxdir":"lddir";
const C *flnm = NULL;
if(argc > 0) {
- if(argc > 1) post("%s - lddir: superfluous arguments ignored",thisName());
+ if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
- post("%s - lddir: invalid filename",thisName());
- else {
- if(!pl->LdDir(curdir,flnm,0))
- post("%s - lddir: directory couldn't be loaded",thisName());
- }
+ post("%s - %s: invalid filename",thisName(),sym);
+ else if(!(xml?pl->LdDirXML(curdir,flnm,0):pl->LdDir(curdir,flnm,0)))
+ post("%s - %s: directory couldn't be loaded",thisName(),sym);
echodir();
}
-V pool::m_ldrec(I argc,const A *argv)
+V pool::ldrec(I argc,const A *argv,BL xml)
{
+ const C *sym = xml?"ldxrec":"ldrec";
const C *flnm = NULL;
I depth = -1;
BL mkdir = true;
@@ -821,59 +926,61 @@ V pool::m_ldrec(I argc,const A *argv)
if(argc >= 2) {
if(CanbeInt(argv[1])) depth = GetAInt(argv[1]);
else
- post("%s - ldrec: invalid depth argument - set to -1",thisName());
+ post("%s - %s: invalid depth argument - set to -1",thisName(),sym);
if(argc >= 3) {
if(CanbeBool(argv[2])) mkdir = GetABool(argv[2]);
else
- post("%s - ldrec: invalid mkdir argument - set to true",thisName());
+ post("%s - %s: invalid mkdir argument - set to true",thisName(),sym);
- if(argc > 3) post("%s - ldrec: superfluous arguments ignored",thisName());
+ if(argc > 3) post("%s - %s: superfluous arguments ignored",thisName(),sym);
}
}
}
if(!flnm)
- post("%s - ldrec: invalid filename",thisName());
+ post("%s - %s: invalid filename",thisName(),sym);
else {
- if(!pl->LdDir(curdir,flnm,depth,mkdir))
- post("%s - ldrec: directory couldn't be saved",thisName());
+ if(!(xml?pl->LdDirXML(curdir,flnm,depth,mkdir):pl->LdDir(curdir,flnm,depth,mkdir)))
+ post("%s - %s: directory couldn't be saved",thisName(),sym);
}
echodir();
}
-V pool::m_svdir(I argc,const A *argv)
+V pool::svdir(I argc,const A *argv,BL xml)
{
+ const C *sym = xml?"svxdir":"svdir";
const C *flnm = NULL;
if(argc > 0) {
- if(argc > 1) post("%s - svdir: superfluous arguments ignored",thisName());
+ if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
- post("%s - svdir: invalid filename",thisName());
+ post("%s - %s: invalid filename",thisName(),sym);
else {
- if(!pl->SvDir(curdir,flnm,0,absdir))
- post("%s - svdir: directory couldn't be saved",thisName());
+ if(!(xml?pl->SvDirXML(curdir,flnm,0,absdir):pl->SvDir(curdir,flnm,0,absdir)))
+ post("%s - %s: directory couldn't be saved",thisName(),sym);
}
echodir();
}
-V pool::m_svrec(I argc,const A *argv)
+V pool::svrec(I argc,const A *argv,BL xml)
{
+ const C *sym = xml?"svxrec":"svrec";
const C *flnm = NULL;
if(argc > 0) {
- if(argc > 1) post("%s - svrec: superfluous arguments ignored",thisName());
+ if(argc > 1) post("%s - %s: superfluous arguments ignored",thisName(),sym);
if(IsString(argv[0])) flnm = GetString(argv[0]);
}
if(!flnm)
- post("%s - svrec: invalid filename",thisName());
+ post("%s - %s: invalid filename",thisName(),sym);
else {
- if(!pl->SvDir(curdir,flnm,-1,absdir))
- post("%s - svrec: directory couldn't be saved",thisName());
+ if(!(xml?pl->SvDirXML(curdir,flnm,-1,absdir):pl->SvDir(curdir,flnm,-1,absdir)))
+ post("%s - %s: directory couldn't be saved",thisName(),sym);
}
echodir();
diff --git a/externals/grill/pool/pool.cpp b/externals/grill/pool/pool.cpp
index 886debc6..5eb48294 100644
--- a/externals/grill/pool/pool.cpp
+++ b/externals/grill/pool/pool.cpp
@@ -15,6 +15,8 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include <ctype.h>
#include <stdlib.h>
+#define VBITS 6
+#define DBITS 5
inline I compare(I a,I b) { return a == b?0:(a < b?-1:1); }
inline I compare(F a,F b) { return a == b?0:(a < b?-1:1); }
@@ -78,41 +80,67 @@ poolval *poolval::Dup() const
}
-pooldir::pooldir(const A &d,pooldir *p):
- parent(p),dirs(NULL),vals(NULL),nxt(NULL)
+pooldir::pooldir(const A &d,pooldir *p,I vcnt,I dcnt):
+ parent(p),nxt(NULL),vals(NULL),dirs(NULL),
+ vbits(vcnt?Int2Bits(vcnt):VBITS),dbits(dcnt?Int2Bits(dcnt):DBITS),
+ vsize(1<<vbits),dsize(1<<dbits)
{
+ Reset();
CopyAtom(&dir,&d);
}
pooldir::~pooldir()
{
- Clear(true);
+ Reset(false);
+
if(nxt) delete nxt;
}
V pooldir::Clear(BL rec,BL dironly)
{
- if(rec && dirs) { delete dirs; dirs = NULL; }
- if(!dironly && vals) { delete vals; vals = NULL; }
+ if(rec && dirs) {
+ for(I i = 0; i < dsize; ++i) if(dirs[i].d) { delete dirs[i].d; dirs[i].d = NULL; }
+ }
+ if(!dironly && vals) {
+ for(I i = 0; i < vsize; ++i) if(vals[i].v) { delete vals[i].v; vals[i].v = NULL; }
+ }
}
-pooldir *pooldir::AddDir(I argc,const A *argv)
+V pooldir::Reset(BL realloc)
+{
+ Clear(true,false);
+
+ if(dirs) delete[] dirs;
+ if(vals) delete[] vals;
+
+ if(realloc) {
+ dirs = new direntry[dsize];
+ ZeroMem(dirs,dsize*sizeof *dirs);
+ vals = new valentry[vsize];
+ ZeroMem(vals,vsize*sizeof *vals);
+ }
+ else
+ dirs = NULL,vals = NULL;
+}
+
+pooldir *pooldir::AddDir(I argc,const A *argv,I vcnt,I dcnt)
{
if(!argc) return this;
- I c = 1;
- pooldir *prv = NULL,*ix = dirs;
+ I c = 1,dix = DIdx(argv[0]);
+ pooldir *prv = NULL,*ix = dirs[dix].d;
for(; ix; prv = ix,ix = ix->nxt) {
c = compare(argv[0],ix->dir);
if(c <= 0) break;
}
if(c || !ix) {
- pooldir *nd = new pooldir(argv[0],this);
+ pooldir *nd = new pooldir(argv[0],this,vcnt,dcnt);
nd->nxt = ix;
if(prv) prv->nxt = nd;
- else dirs = nd;
+ else dirs[dix].d = nd;
+ dirs[dix].cnt++;
ix = nd;
}
@@ -123,8 +151,8 @@ pooldir *pooldir::GetDir(I argc,const A *argv,BL rmv)
{
if(!argc) return this;
- I c = 1;
- pooldir *prv = NULL,*ix = dirs;
+ I c = 1,dix = DIdx(argv[0]);
+ pooldir *prv = NULL,*ix = dirs[dix].d;
for(; ix; prv = ix,ix = ix->nxt) {
c = compare(argv[0],ix->dir);
if(c <= 0) break;
@@ -138,7 +166,8 @@ pooldir *pooldir::GetDir(I argc,const A *argv,BL rmv)
else if(rmv) {
pooldir *nd = ix->nxt;
if(prv) prv->nxt = nd;
- else dirs = nd;
+ else dirs[dix].d = nd;
+ dirs[dix].cnt--;
ix->nxt = NULL;
return ix;
}
@@ -160,8 +189,8 @@ BL pooldir::DelDir(I argc,const A *argv)
V pooldir::SetVal(const A &key,AtomList *data,BL over)
{
- I c = 1;
- poolval *prv = NULL,*ix = vals;
+ I c = 1,vix = VIdx(key);
+ poolval *prv = NULL,*ix = vals[vix].v;
for(; ix; prv = ix,ix = ix->nxt) {
c = compare(key,ix->key);
if(c <= 0) break;
@@ -175,7 +204,8 @@ V pooldir::SetVal(const A &key,AtomList *data,BL over)
nv->nxt = ix;
if(prv) prv->nxt = nv;
- else vals = nv;
+ else vals[vix].v = nv;
+ vals[vix].cnt++;
}
}
else if(over) {
@@ -184,9 +214,12 @@ V pooldir::SetVal(const A &key,AtomList *data,BL over)
if(data)
ix->Set(data);
else {
+ // delete key
+
poolval *nv = ix->nxt;
if(prv) prv->nxt = nv;
- else vals = nv;
+ else vals[vix].v = nv;
+ vals[vix].cnt--;
ix->nxt = NULL;
delete ix;
}
@@ -195,8 +228,8 @@ V pooldir::SetVal(const A &key,AtomList *data,BL over)
poolval *pooldir::RefVal(const A &key)
{
- I c = 1;
- poolval *ix = vals;
+ I c = 1,vix = VIdx(key);
+ poolval *ix = vals[vix].v;
for(; ix; ix = ix->nxt) {
c = compare(key,ix->key);
if(c <= 0) break;
@@ -205,13 +238,17 @@ poolval *pooldir::RefVal(const A &key)
return c || !ix?NULL:ix;
}
+
poolval *pooldir::RefVali(I rix)
{
- I c = 0;
- poolval *ix = vals;
- for(; ix && c < rix; ix = ix->nxt,++c) {}
-
- return c == rix?ix:NULL;
+ for(I vix = 0; vix < vsize; ++vix)
+ if(rix > vals[vix].cnt) rix -= vals[vix].cnt;
+ else {
+ poolval *ix = vals[vix].v;
+ for(; ix && rix; ix = ix->nxt) --rix;
+ if(ix && !rix) return ix;
+ }
+ return NULL;
}
flext::AtomList *pooldir::PeekVal(const A &key)
@@ -222,8 +259,8 @@ flext::AtomList *pooldir::PeekVal(const A &key)
flext::AtomList *pooldir::GetVal(const A &key,BL cut)
{
- I c = 1;
- poolval *prv = NULL,*ix = vals;
+ I c = 1,vix = VIdx(key);
+ poolval *prv = NULL,*ix = vals[vix].v;
for(; ix; prv = ix,ix = ix->nxt) {
c = compare(key,ix->key);
if(c <= 0) break;
@@ -236,7 +273,8 @@ flext::AtomList *pooldir::GetVal(const A &key,BL cut)
if(cut) {
poolval *nv = ix->nxt;
if(prv) prv->nxt = nv;
- else vals = nv;
+ else vals[vix].v = nv;
+ vals[vix].cnt--;
ix->nxt = NULL;
ret = ix->data; ix->data = NULL;
delete ix;
@@ -247,11 +285,10 @@ flext::AtomList *pooldir::GetVal(const A &key,BL cut)
}
}
-I pooldir::CntAll()
+I pooldir::CntAll() const
{
I cnt = 0;
- poolval *ix = vals;
- for(; ix; ix = ix->nxt,++cnt) {}
+ for(I vix = 0; vix < vsize; ++vix) cnt += vals[vix].cnt;
return cnt;
}
@@ -260,10 +297,11 @@ I pooldir::GetKeys(AtomList &keys)
I cnt = CntAll();
keys(cnt);
- poolval *ix = vals;
- for(I i = 0; ix; ++i,ix = ix->nxt)
- SetAtom(keys[i],ix->key);
-
+ for(I vix = 0; vix < vsize; ++vix) {
+ poolval *ix = vals[vix].v;
+ for(I i = 0; ix; ++i,ix = ix->nxt)
+ SetAtom(keys[i],ix->key);
+ }
return cnt;
}
@@ -273,35 +311,42 @@ I pooldir::GetAll(A *&keys,AtomList *&lst,BL cut)
keys = new A[cnt];
lst = new AtomList[cnt];
- poolval *ix = vals;
- for(I i = 0; ix; ++i) {
- SetAtom(keys[i],ix->key);
- lst[i] = *ix->data;
-
- if(cut) {
- poolval *t = ix;
- vals = ix = ix->nxt;
- t->nxt = NULL; delete t;
+ for(I i = 0,vix = 0; vix < vsize; ++vix) {
+ poolval *ix = vals[vix].v;
+ for(; ix; ++i) {
+ SetAtom(keys[i],ix->key);
+ lst[i] = *ix->data;
+
+ if(cut) {
+ poolval *t = ix;
+ vals[vix].v = ix = ix->nxt;
+ vals[vix].cnt--;
+ t->nxt = NULL; delete t;
+ }
+ else
+ ix = ix->nxt;
}
- else
- ix = ix->nxt;
}
+ return cnt;
+}
+
+I pooldir::CntSub() const
+{
+ I cnt = 0;
+ for(I dix = 0; dix < dsize; ++dix) cnt += dirs[dix].cnt;
return cnt;
}
+
I pooldir::GetSub(const A **&lst)
{
- I cnt = 0;
- pooldir *ix = dirs;
- for(; ix; ix = ix->nxt,++cnt) {}
+ const I cnt = CntSub();
lst = new const A *[cnt];
-
- ix = dirs;
- for(I i = 0; ix; ix = ix->nxt,++i) {
- lst[i] = &ix->dir;
+ for(I i = 0,dix = 0; dix < dsize; ++dix) {
+ pooldir *ix = dirs[dix].d;
+ for(; ix; ix = ix->nxt) lst[i++] = &ix->dir;
}
-
return cnt;
}
@@ -310,15 +355,19 @@ BL pooldir::Paste(const pooldir *p,I depth,BL repl,BL mkdir)
{
BL ok = true;
- for(poolval *ix = p->vals; ix; ix = ix->nxt) {
- SetVal(ix->key,new AtomList(*ix->data),repl);
+ for(I vi = 0; vi < p->vsize; ++vi) {
+ for(poolval *ix = p->vals[vi].v; ix; ix = ix->nxt) {
+ SetVal(ix->key,new AtomList(*ix->data),repl);
+ }
}
if(ok && depth) {
- for(pooldir *dix = p->dirs; ok && dix; dix = dix->nxt) {
- pooldir *ndir = mkdir?AddDir(1,&dix->dir):GetDir(1,&dix->dir);
- if(ndir) {
- ok = ndir->Paste(dix,depth > 0?depth-1:depth,repl,mkdir);
+ for(I di = 0; di < p->dsize; ++di) {
+ for(pooldir *dix = p->dirs[di].d; ok && dix; dix = dix->nxt) {
+ pooldir *ndir = mkdir?AddDir(1,&dix->dir):GetDir(1,&dix->dir);
+ if(ndir) {
+ ok = ndir->Paste(dix,depth > 0?depth-1:depth,repl,mkdir);
+ }
}
}
}
@@ -331,26 +380,30 @@ BL pooldir::Copy(pooldir *p,I depth,BL cut)
BL ok = true;
if(cut) {
- if(p->vals)
- ok = false;
- else
- p->vals = vals, vals = NULL;
+ for(I vi = 0; vi < vsize; ++vi) {
+ for(poolval *ix = vals[vi].v; ix; ix = ix->nxt)
+ p->SetVal(ix->key,ix->data);
+ vals[vi].cnt = 0;
+ vals[vi].v = NULL;
+ }
}
else {
- // inefficient!! p->SetVal has to search through list unnecessarily!!
- for(poolval *ix = vals; ix; ix = ix->nxt) {
- p->SetVal(ix->key,new AtomList(*ix->data));
+ for(I vi = 0; vi < vsize; ++vi) {
+ for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) {
+ p->SetVal(ix->key,new AtomList(*ix->data));
+ }
}
}
if(ok && depth) {
- // also quite inefficient for cut
- for(pooldir *dix = dirs; ok && dix; dix = dix->nxt) {
- pooldir *ndir = p->AddDir(1,&dix->dir);
- if(ndir)
- ok = ndir->Copy(dix,depth > 0?depth-1:depth,cut);
- else
- ok = false;
+ for(I di = 0; di < dsize; ++di) {
+ for(pooldir *dix = dirs[di].d; ok && dix; dix = dix->nxt) {
+ pooldir *ndir = p->AddDir(1,&dix->dir);
+ if(ndir)
+ ok = ndir->Copy(dix,depth > 0?depth-1:depth,cut);
+ else
+ ok = false;
+ }
}
}
@@ -436,17 +489,18 @@ static V WriteAtom(ostream &os,const A &a)
static V WriteAtoms(ostream &os,const flext::AtomList &l)
{
for(I i = 0; i < l.Count(); ++i) {
+// if(IsSymbol(l[i]) os << "\"";
WriteAtom(os,l[i]);
- os << ' ';
+// if(IsSymbol(l[i]) os << "\"";
+ if(i < l.Count()-1) os << ' ';
}
}
BL pooldir::LdDir(istream &is,I depth,BL mkdir)
{
- BL r;
for(I i = 1; !is.eof(); ++i) {
AtomList d,k,*v = new AtomList;
- r = ReadAtoms(is,d,',');
+ BL r = ReadAtoms(is,d,',');
r = r && ReadAtoms(is,k,',') && k.Count() == 1;
r = r && ReadAtoms(is,*v,'\n') && v->Count();
@@ -472,10 +526,10 @@ BL pooldir::LdDir(istream &is,I depth,BL mkdir)
BL pooldir::SvDir(ostream &os,I depth,const AtomList &dir)
{
- {
- for(poolval *ix = vals; ix; ix = ix->nxt) {
+ for(I vi = 0; vi < vsize; ++vi) {
+ for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) {
WriteAtoms(os,dir);
- os << ", ";
+ os << " , ";
WriteAtom(os,ix->key);
os << " , ";
WriteAtoms(os,*ix->data);
@@ -484,13 +538,77 @@ BL pooldir::SvDir(ostream &os,I depth,const AtomList &dir)
}
if(depth) {
I nd = depth > 0?depth-1:-1;
- for(pooldir *ix = dirs; ix; ix = ix->nxt) {
- ix->SvDir(os,nd,AtomList(dir).Append(ix->dir));
+ for(I di = 0; di < dsize; ++di) {
+ for(pooldir *ix = dirs[di].d; ix; ix = ix->nxt) {
+ ix->SvDir(os,nd,AtomList(dir).Append(ix->dir));
+ }
}
}
return true;
}
+BL pooldir::LdDirXML(istream &is,I depth,BL mkdir)
+{
+/*
+ for(I i = 1; !is.eof(); ++i) {
+ AtomList d,k,*v = new AtomList;
+ BL r = ReadAtoms(is,d,',');
+ r = r && ReadAtoms(is,k,',') && k.Count() == 1;
+ r = r && ReadAtoms(is,*v,'\n') && v->Count();
+
+ if(r) {
+ if(depth < 0 || d.Count() <= depth) {
+ pooldir *nd = mkdir?AddDir(d):GetDir(d);
+ if(nd) {
+ nd->SetVal(k[0],v); v = NULL;
+ }
+ #ifdef FLEXT_DEBUG
+ else
+ post("pool - directory was not found",i);
+ #endif
+ }
+ }
+ else if(!is.eof())
+ post("pool - format mismatch encountered, skipped line %i",i);
+
+ if(v) delete v;
+ }
+ return true;
+*/
+ return false;
+}
+
+BL pooldir::SvDirXML(ostream &os,I depth,const AtomList &dir)
+{
+ if(dir.Count()) {
+ os << "<dir key=\"";
+ WriteAtom(os,dir[dir.Count()-1]);
+ os << "\">" << endl;
+ }
+
+ for(I vi = 0; vi < vsize; ++vi) {
+ for(poolval *ix = vals[vi].v; ix; ix = ix->nxt) {
+ os << "<value key=\"";
+ WriteAtom(os,ix->key);
+ os << "\">";
+ WriteAtoms(os,*ix->data);
+ os << "</value>" << endl;
+ }
+ }
+
+ if(depth) {
+ I nd = depth > 0?depth-1:-1;
+ for(I di = 0; di < dsize; ++di) {
+ for(pooldir *ix = dirs[di].d; ix; ix = ix->nxt) {
+ ix->SvDirXML(os,nd,AtomList(dir).Append(ix->dir));
+ }
+ }
+ }
+
+ if(dir.Count()) os << "</dir>" << endl;
+ return true;
+}
+
diff --git a/externals/grill/pool/pool.cw b/externals/grill/pool/pool.cw
index a42f2abf..0169ea73 100755
--- a/externals/grill/pool/pool.cw
+++ b/externals/grill/pool/pool.cw
Binary files differ
diff --git a/externals/grill/pool/pool.dsp b/externals/grill/pool/pool.dsp
index dd2209ae..f59a4e15 100644
--- a/externals/grill/pool/pool.dsp
+++ b/externals/grill/pool/pool.dsp
@@ -101,6 +101,10 @@ SOURCE=.\pool.cpp
# End Source File
# Begin Source File
+SOURCE=.\pool.dtd
+# End Source File
+# Begin Source File
+
SOURCE=.\pool.h
# End Source File
# Begin Source File
diff --git a/externals/grill/pool/pool.dtd b/externals/grill/pool/pool.dtd
new file mode 100644
index 00000000..c5cb5568
--- /dev/null
+++ b/externals/grill/pool/pool.dtd
@@ -0,0 +1,5 @@
+<!ELEMENT pool ((dir|value)*)>
+<!ELEMENT dir ((dir|value)*)>
+<!ATTLIST dir key CDATA #REQUIRED>
+<!ELEMENT value ANY>
+<!ATTLIST value key CDATA #REQUIRED>
diff --git a/externals/grill/pool/pool.h b/externals/grill/pool/pool.h
index 2fdbbd28..59195555 100644
--- a/externals/grill/pool/pool.h
+++ b/externals/grill/pool/pool.h
@@ -15,14 +15,15 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#include <flext.h>
-#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401)
-#error You need at least flext version 0.4.1
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 402)
+#error You need at least flext version 0.4.2
#endif
#include <iostream.h>
typedef void V;
typedef int I;
+typedef unsigned long UL;
typedef float F;
typedef char C;
typedef bool BL;
@@ -48,10 +49,12 @@ class pooldir:
public flext
{
public:
- pooldir(const A &dir,pooldir *parent);
+ pooldir(const A &dir,pooldir *parent,I vcnt = 0,I dcnt = 0);
~pooldir();
V Clear(BL rec,BL dironly = false);
+ V Reset(BL realloc = true);
+
BL Empty() const { return !dirs && !vals; }
BL HasDirs() const { return dirs != NULL; }
BL HasVals() const { return vals != NULL; }
@@ -60,16 +63,17 @@ public:
pooldir *GetDir(const AtomList &d,BL cut = false) { return GetDir(d.Count(),d.Atoms(),cut); }
BL DelDir(I argc,const A *argv);
BL DelDir(const AtomList &d) { return DelDir(d.Count(),d.Atoms()); }
- pooldir *AddDir(I argc,const A *argv);
- pooldir *AddDir(const AtomList &d) { return AddDir(d.Count(),d.Atoms()); }
+ pooldir *AddDir(I argc,const A *argv,I vcnt = 0,I dcnt = 0);
+ pooldir *AddDir(const AtomList &d,I vcnt = 0,I dcnt = 0) { return AddDir(d.Count(),d.Atoms(),vcnt,dcnt); }
V SetVal(const A &key,AtomList *data,BL over = true);
V ClrVal(const A &key) { SetVal(key,NULL); }
AtomList *PeekVal(const A &key);
AtomList *GetVal(const A &key,BL cut = false);
- I CntAll();
+ I CntAll() const;
I GetAll(A *&keys,AtomList *&lst,BL cut = false);
I GetKeys(AtomList &keys);
+ I CntSub() const;
I GetSub(const A **&dirs);
poolval *RefVal(const A &key);
@@ -79,27 +83,42 @@ public:
BL Copy(pooldir *p,I depth,BL cur);
BL LdDir(istream &is,I depth,BL mkdir);
+ BL LdDirXML(istream &is,I depth,BL mkdir);
BL SvDir(ostream &os,I depth,const AtomList &dir = AtomList());
+ BL SvDirXML(ostream &os,I depth,const AtomList &dir = AtomList());
+
+ int VSize() const { return vsize; }
+ int DSize() const { return dsize; }
+
+protected:
+ int VIdx(const A &v) const { return FoldBits(AtomHash(v),vbits); }
+ int DIdx(const A &d) const { return FoldBits(AtomHash(d),dbits); }
A dir;
pooldir *nxt;
- pooldir *parent,*dirs;
- poolval *vals;
+ pooldir *parent;
+ const I vbits,dbits,vsize,dsize;
+
+ struct valentry { int cnt; poolval *v; };
+ struct direntry { int cnt; pooldir *d; };
+
+ valentry *vals;
+ direntry *dirs;
};
class pooldata:
public flext
{
public:
- pooldata(const S *s = NULL);
+ pooldata(const S *s = NULL,I vcnt = 0,I dcnt = 0);
~pooldata();
V Push() { ++refs; }
BL Pop() { return --refs > 0; }
V Reset();
- BL MkDir(const AtomList &d);
+ BL MkDir(const AtomList &d,I vcnt = 0,I dcnt = 0);
BL ChkDir(const AtomList &d);
BL RmDir(const AtomList &d);
@@ -112,6 +131,7 @@ public:
poolval *Refi(const AtomList &d,I ix);
I CntAll(const AtomList &d);
I GetAll(const AtomList &d,A *&keys,AtomList *&lst);
+ I CntSub(const AtomList &d);
I GetSub(const AtomList &d,const t_atom **&dirs);
BL Paste(const AtomList &d,const pooldir *clip,I depth = -1,BL repl = true,BL mkdir = true);
@@ -122,6 +142,10 @@ public:
BL SvDir(const AtomList &d,const C *flnm,I depth,BL absdir);
BL Load(const C *flnm) { return LdDir(AtomList(),flnm,-1); }
BL Save(const C *flnm) { return SvDir(AtomList(),flnm,-1,true); }
+ BL LdDirXML(const AtomList &d,const C *flnm,I depth,BL mkdir = true);
+ BL SvDirXML(const AtomList &d,const C *flnm,I depth,BL absdir);
+ BL LoadXML(const C *flnm) { return LdDirXML(AtomList(),flnm,-1); }
+ BL SaveXML(const C *flnm) { return SvDirXML(AtomList(),flnm,-1,true); }
I refs;
const S *sym;
diff --git a/externals/grill/pool/pool.help b/externals/grill/pool/pool.help
index dfef05f1..959ca32f 100755
--- a/externals/grill/pool/pool.help
+++ b/externals/grill/pool/pool.help
Binary files differ
diff --git a/externals/grill/pool/pool.pd b/externals/grill/pool/pool.pd
index 4d5592e3..70fc7461 100644
--- a/externals/grill/pool/pool.pd
+++ b/externals/grill/pool/pool.pd
@@ -1,10 +1,10 @@
-#N canvas 25 23 980 683 12;
+#N canvas 12 3 926 682 12;
#X msg 295 108 set 1 2 3;
-#X obj 254 615 print K;
+#X obj 308 619 print K;
#X msg 607 211 getall;
#X msg 295 137 set A k g;
-#X obj 233 646 print V;
-#X obj 272 584 print D;
+#X obj 259 648 print V;
+#X obj 357 593 print D;
#X msg 295 167 set A l m;
#X msg 298 196 set 2 34;
#X msg 297 227 set 3 17;
@@ -19,11 +19,11 @@
#X msg 40 234 absdir \$1;
#X text 427 85 clear value;
#X text 428 159 get value;
-#X obj 291 557 print C;
-#X text 363 557 command;
-#X text 345 584 directory (abs or rel to current);
-#X text 308 647 data value;
-#X text 326 615 data key;
+#X obj 406 564 print C;
+#X text 478 564 command;
+#X text 430 593 directory (abs or rel to current);
+#X text 334 649 data value;
+#X text 380 619 data key;
#X msg 41 314 pool pool1;
#X msg 42 343 pool;
#X text 86 343 set to private;
@@ -32,7 +32,7 @@
#X msg 613 111 clrall;
#X text 604 89 clear all values in dir;
#X text 607 190 get all values in dir;
-#X text 314 479 pool name can be given as argument;
+#X text 175 500 pool name can be given as argument;
#X text 603 136 clear all values and dirs;
#X msg 611 158 clrrec;
#X msg 605 258 getrec;
@@ -54,9 +54,8 @@
#X msg 609 364 cntrec;
#X text 677 362 ... and subdirs;
#X text 673 376 (depth may be given);
-#X msg 296 282 add 3 14;
#X text 294 261 set but don't replace;
-#N canvas 0 0 512 538 dirs 0;
+#N canvas 0 0 514 540 dirs 0;
#X msg 109 27 mkdir fld1;
#X msg 111 122 chdir;
#X msg 110 217 updir;
@@ -96,29 +95,51 @@
#X connect 23 0 26 0;
#X restore 718 511 pd dirs;
#X text 715 485 directory operations;
-#N canvas 0 0 469 436 file 0;
+#N canvas 0 0 815 447 file 0;
#X text 117 207 save dir and subdirs;
#X text 117 165 save data in current dir;
-#X msg 117 184 svdir c:/temp/pool.dat;
-#X msg 117 226 svrec c:/temp/pool.dat;
-#X msg 116 272 lddir c:/temp/pool.dat;
-#X msg 116 319 ldrec c:/temp/pool.dat;
#X text 117 253 load data into current dir;
#X text 115 300 load data into current dir and below;
#X text 132 340 depth (default -1) and;
#X text 134 356 mkdir flag (default 1) can be given;
#X text 117 37 save all;
#X text 117 81 load all (add to existing data);
-#X msg 118 100 load c:/temp/pool.dat;
-#X msg 120 54 save c:/temp/pool.dat;
#X text 22 12 file operations;
#X obj 22 188 s \$0-pool;
-#X connect 2 0 15 0;
-#X connect 3 0 15 0;
-#X connect 4 0 15 0;
-#X connect 5 0 15 0;
-#X connect 12 0 15 0;
-#X connect 13 0 15 0;
+#X text 473 209 save dir and subdirs;
+#X text 473 167 save data in current dir;
+#X text 473 255 load data into current dir;
+#X text 471 302 load data into current dir and below;
+#X text 488 342 depth (default -1) and;
+#X text 490 358 mkdir flag (default 1) can be given;
+#X text 473 39 save all;
+#X text 473 83 load all (add to existing data);
+#X obj 378 190 s \$0-pool;
+#X text 444 12 XML format;
+#X msg 120 54 save pool.dat;
+#X msg 118 100 load pool.dat;
+#X msg 117 184 svdir pool.dat;
+#X msg 117 226 svrec pool.dat;
+#X msg 116 272 lddir pool.dat;
+#X msg 116 319 ldrec pool.dat;
+#X msg 476 56 savex pool.xml;
+#X msg 474 102 loadx pool.xml;
+#X msg 473 186 svxdir pool.xml;
+#X msg 473 228 svxrec pool.xml;
+#X msg 472 274 ldxdir pool.xml;
+#X msg 472 321 ldxrec pool.xml;
+#X connect 20 0 9 0;
+#X connect 21 0 9 0;
+#X connect 22 0 9 0;
+#X connect 23 0 9 0;
+#X connect 24 0 9 0;
+#X connect 25 0 9 0;
+#X connect 26 0 18 0;
+#X connect 27 0 18 0;
+#X connect 28 0 18 0;
+#X connect 29 0 18 0;
+#X connect 30 0 18 0;
+#X connect 31 0 18 0;
#X restore 719 566 pd file;
#X text 717 543 file operations;
#X text 717 600 clipboard operations;
@@ -162,51 +183,54 @@
#X connect 23 0 26 0;
#X restore 719 623 pd clip;
#X text 717 454 more commands:;
-#X obj 349 429 r \$0-pool;
-#X text 174 500 data is shared among pool objects with the same name
+#X obj 289 389 r \$0-pool;
+#X text 174 517 data is shared among pool objects with the same name
;
#X obj 26 10 cnv 15 850 40 empty empty pool 10 22 0 24 -260818 -1 0
;
#X text 272 33 http://www.parasitaere-kapazitaeten.net;
-#X obj 317 529 print A;
-#X text 382 529 attributes;
+#X obj 456 541 print A;
+#X text 521 541 attributes;
#X msg 43 490 getattributes;
#X msg 136 132 getechodir;
#X msg 132 232 getabsdir;
#X msg 146 313 getpool;
-#X obj 260 478 pool;
#X text 272 13 a hierarchical storage object \, (C)2002-2003 Thomas
Grill;
-#X connect 0 0 72 0;
-#X connect 2 0 72 0;
-#X connect 3 0 72 0;
-#X connect 6 0 72 0;
-#X connect 7 0 72 0;
-#X connect 8 0 72 0;
-#X connect 9 0 72 0;
-#X connect 10 0 72 0;
-#X connect 11 0 72 0;
-#X connect 12 0 72 0;
+#X msg 296 282 add 2 14;
+#X obj 260 478 pool @valcnt 10 @dircnt 5;
+#X text 332 442 expected value and directory counts;
+#X text 332 457 can be given for optimal performance;
+#X connect 0 0 73 0;
+#X connect 2 0 73 0;
+#X connect 3 0 73 0;
+#X connect 6 0 73 0;
+#X connect 7 0 73 0;
+#X connect 8 0 73 0;
+#X connect 9 0 73 0;
+#X connect 10 0 73 0;
+#X connect 11 0 73 0;
+#X connect 12 0 73 0;
#X connect 13 0 12 0;
#X connect 14 0 15 0;
-#X connect 15 0 72 0;
-#X connect 23 0 72 0;
-#X connect 24 0 72 0;
-#X connect 26 0 72 0;
-#X connect 28 0 72 0;
-#X connect 33 0 72 0;
-#X connect 34 0 72 0;
-#X connect 45 0 72 0;
-#X connect 48 0 72 0;
-#X connect 50 0 72 0;
-#X connect 53 0 72 0;
-#X connect 62 0 72 0;
-#X connect 68 0 72 0;
-#X connect 69 0 72 0;
-#X connect 70 0 72 0;
-#X connect 71 0 72 0;
-#X connect 72 0 4 0;
-#X connect 72 1 1 0;
-#X connect 72 2 5 0;
-#X connect 72 3 18 0;
-#X connect 72 4 66 0;
+#X connect 15 0 73 0;
+#X connect 23 0 73 0;
+#X connect 24 0 73 0;
+#X connect 26 0 73 0;
+#X connect 28 0 73 0;
+#X connect 33 0 73 0;
+#X connect 34 0 73 0;
+#X connect 45 0 73 0;
+#X connect 48 0 73 0;
+#X connect 50 0 73 0;
+#X connect 61 0 73 0;
+#X connect 67 0 73 0;
+#X connect 68 0 73 0;
+#X connect 69 0 73 0;
+#X connect 70 0 73 0;
+#X connect 72 0 73 0;
+#X connect 73 0 4 0;
+#X connect 73 1 1 0;
+#X connect 73 2 5 0;
+#X connect 73 3 18 0;
+#X connect 73 4 65 0;
diff --git a/externals/grill/pool/readme.txt b/externals/grill/pool/readme.txt
index 56d7b7b5..62e42669 100644
--- a/externals/grill/pool/readme.txt
+++ b/externals/grill/pool/readme.txt
@@ -52,17 +52,23 @@ o CodeWarrior: edit "pool.cw" and build
Version history:
-0.1.1:
+0.2.0:
- attributes (pool,private,echodir,absdir)
- added "geti" message for retrieval of a value at an index
- fixed bug in "get" message if key not present
- adapted source to flext 0.4.1 - register methods at class creation
+- extensive use of hashing for keys and directories
+- database can be saved/loaded as XML data
0.1.0:
- first public release
---------------------------------------------------------------------------
+BUGS:
+- pool does not handle symbols with spaces or all digits
+
+
TODO list:
general:
diff --git a/externals/grill/xsample/config-pd-darwin.txt b/externals/grill/xsample/config-pd-darwin.txt
index 7fa15a68..0d4ef217 100755
--- a/externals/grill/xsample/config-pd-darwin.txt
+++ b/externals/grill/xsample/config-pd-darwin.txt
@@ -29,3 +29,8 @@ INSTDIR=${PD}/extra
# where should the xsample help be installed?
# (leave blank to omit installation)
HELPDIR=${PD}/doc/5.reference
+
+# additional compiler flags
+# (check whether they fit your system!)
+UFLAGS=-malign-power -maltivec
+
diff --git a/externals/grill/xsample/config-pd-linux.txt b/externals/grill/xsample/config-pd-linux.txt
index 26e62e49..a58077ec 100755
--- a/externals/grill/xsample/config-pd-linux.txt
+++ b/externals/grill/xsample/config-pd-linux.txt
@@ -26,3 +26,9 @@ INSTDIR=${PD}/extra
# where should the xsample help be installed?
# (leave blank to omit installation)
HELPDIR=${PD}/doc/5.reference
+
+# additional compiler flags
+# (check whether they fit to your system!)
+UFLAGS=-mcpu=pentiumpro # gcc 2.95
+# UFLAGS=-mcpu=pentium3 -msse -mfpmath=sse # gcc 3.2
+
diff --git a/externals/grill/xsample/make-files.txt b/externals/grill/xsample/make-files.txt
index d96d8485..1607b051 100755
--- a/externals/grill/xsample/make-files.txt
+++ b/externals/grill/xsample/make-files.txt
@@ -3,5 +3,5 @@ SRCS= \
main.cpp play.cpp groove.cpp record.cpp inter.cpp
HDRS= \
- main.h inter.ci
+ main.h inter.h
diff --git a/externals/grill/xsample/makefile.pd-darwin b/externals/grill/xsample/makefile.pd-darwin
index 0dbb0611..f51f550f 100755
--- a/externals/grill/xsample/makefile.pd-darwin
+++ b/externals/grill/xsample/makefile.pd-darwin
@@ -18,7 +18,7 @@ FLEXTLIB=$(FLEXTPATH)/flext.a
# compiler stuff
INCLUDES=$(PDINC)
FLAGS=-DFLEXT_SYS=2
-CFLAGS=-O6 -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes # -maltivec
+CFLAGS=${UFLAGS} -O6 -Wno-unused -Wno-parentheses -Wno-switch -Wstrict-prototypes -funroll-loops -fmove-all-movables -frerun-loop-opt -fno-rtti -fno-exceptions
LIBS=m
LDFLAGS=-bundle -bundle_loader $(PDBIN)
diff --git a/externals/grill/xsample/makefile.pd-linux b/externals/grill/xsample/makefile.pd-linux
index 9e6dabaf..c8742ea0 100644
--- a/externals/grill/xsample/makefile.pd-linux
+++ b/externals/grill/xsample/makefile.pd-linux
@@ -17,8 +17,7 @@ FLEXTLIB=$(FLEXTPATH)/flext.a
# compiler stuff
INCLUDES=$(PDINC)
FLAGS=-DFLEXT_SYS=2
-CFLAGS=-O6 -mcpu=pentiumpro -funroll-loops -fmove-all-movables -frerun-loop-opt -finline-functions
-#CFLAGS=-O6 -mcpu=pentium3 -msse -mfpmath=sse -funroll-loops -fmove-all-movables -frerun-loop-opt -finline-functions
+CFLAGS=${UFLAGS} -O6 -funroll-loops -fmove-all-movables -frerun-loop-opt -finline-functions -fno-rtti -fno-exceptions
LIBS=m
# ----------------------------------------------
diff --git a/externals/grill/xsample/maxmsp/xgroove~.help b/externals/grill/xsample/maxmsp/xgroove~.help
index ee8a244e..e00533b1 100644
--- a/externals/grill/xsample/maxmsp/xgroove~.help
+++ b/externals/grill/xsample/maxmsp/xgroove~.help
Binary files differ
diff --git a/externals/grill/xsample/maxmsp/xplay~.help b/externals/grill/xsample/maxmsp/xplay~.help
index 5a210f74..1dbe02d1 100644
--- a/externals/grill/xsample/maxmsp/xplay~.help
+++ b/externals/grill/xsample/maxmsp/xplay~.help
Binary files differ
diff --git a/externals/grill/xsample/pd/xgroove~.pd b/externals/grill/xsample/pd/xgroove~.pd
index da24d9ec..f856025d 100644
--- a/externals/grill/xsample/pd/xgroove~.pd
+++ b/externals/grill/xsample/pd/xgroove~.pd
@@ -1,174 +1,174 @@
-#N canvas 92 110 839 558 12;
-#X obj 258 240 hsl 128 15 0.001 3 1 1 empty empty empty 20 8 0 8 -225271
--1 -1 0 1;
-#X floatatom 255 261 8 0 0;
-#X floatatom 275 312 8 0 0;
-#X floatatom 350 312 8 0 0;
-#X floatatom 273 372 8 0 0;
-#X floatatom 348 372 8 0 0;
-#X obj 275 419 loadbang;
-#X obj 274 445 metro 30;
-#X obj 250 470 snapshot~;
-#X floatatom 250 494 8 0 0;
-#X msg 258 82 loop \$1;
-#X obj 159 27 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1
--1;
-#X msg 158 47 stop;
-#N canvas 0 0 450 300 graph7 0;
-#X array buf 300 float 1;
-#A 0 0.841115 0.9094 0.95923 0.989636 0.999991 0.990063 0.960094 0.910649
-0.842757 0.757796 0.65746 0.543816 0.419143 0.285978 0.147021 0.00508036
--0.136962 -0.276228 -0.409895 -0.535265 -0.649771 -0.751121 -0.83725
--0.906401 -0.957205 -0.988587 -0.999947 -0.991051 -0.962051 -0.913577
--0.846573 -0.762418 -0.662823 -0.549777 -0.425604 -0.292801 -0.154064
--0.0122066 0.129898 0.269372 0.403387 0.529223 0.644347 0.746395 0.833328
-0.903378 0.955105 0.987498 0.99986 0.991967 0.963983 0.91644 0.850346
-0.767009 0.668129 0.555721 0.432034 0.299602 0.161097 0.0193266 -0.122836
--0.262506 -0.396859 -0.523173 -0.638875 -0.741645 -0.82937 -0.900294
--0.952984 -0.986339 -0.999729 -0.992844 -0.965842 -0.919283 -0.854067
--0.771564 -0.673418 -0.561622 -0.438457 -0.306392 -0.168126 -0.0264512
-0.115759 0.255627 0.390308 0.517083 0.633384 0.736837 0.825374 0.89717
-0.95079 0.985156 0.999531 0.993672 0.967666 0.922048 0.857765 0.776069
-0.678665 0.567504 0.444838 0.313167 0.175141 0.0335691 -0.108684 -0.248732
--0.383745 -0.510974 -0.627851 -0.732014 -0.821324 -0.894008 -0.948562
--0.983895 -0.999309 -0.994439 -0.96944 -0.924788 -0.861391 -0.780556
--0.683878 -0.573355 -0.451214 -0.319922 -0.182154 -0.0406903 0.101596
-0.241826 0.37715 0.504839 0.62229 0.727131 0.81725 0.890784 0.946286
-0.982602 0.999003 0.99518 0.971156 0.927473 0.864993 0.784974 0.689065
-0.579174 0.457555 0.326665 0.189149 0.047805 -0.0945095 -0.234908 -0.370551
--0.498674 -0.616703 -0.722227 -0.813114 -0.887541 -0.943952 -0.981256
--0.998669 -0.995836 -0.972845 -0.93011 -0.868543 -0.789377 -0.694202
--0.584975 -0.463879 -0.333389 -0.196144 -0.0549212 0.0874133 0.227976
-0.363918 0.492493 0.611072 0.717282 0.80895 0.88422 0.941593 0.979852
-0.998275 0.996467 0.974453 0.932714 0.872048 0.793723 0.699318 0.590728
-0.47018 0.340094 0.20312 0.0620311 -0.0803164 -0.221037 -0.357277 -0.486275
--0.605431 -0.712297 -0.804743 -0.880878 -0.939154 -0.97842 -0.99783
--0.997035 -0.976038 -0.935246 -0.875523 -0.798037 -0.704388 -0.596471
--0.476452 -0.346789 -0.210093 -0.0691412 0.0732124 0.21408 0.350613
-0.480039 0.599733 0.707289 0.800488 0.87748 0.936691 0.976908 0.997349
-0.997554 0.977556 0.937754 0.87893 0.802314 0.709426 0.602164 0.482708
-0.353456 0.217051 0.0762439 -0.0661074 -0.207122 -0.343933 -0.473779
--0.594024 -0.702224 -0.796211 -0.87404 -0.934169 -0.975372 -0.996792
--0.998035 -0.979032 -0.940196 -0.882319 -0.806539 -0.714434 -0.60784
--0.48893 -0.36012 -0.224 -0.0833475 0.0589955 0.200142 0.337238 0.467489
-0.588274 0.69714 0.791867 0.870566 0.931602 0.973768 0.996211 0.998443
-0.980464 0.9426 0.885637 0.810741 0.719392 0.613481 0.495132 0.366748
-0.230939 0.0904412 -0.0518851 -0.193161 -0.33052 -0.461188 -0.582499
--0.692013 -0.787507 -0.867028 -0.928998 -0.972125 -0.995556 -0.998827
--0.98183 -0.944959 -0.888927 -0.81488 -0.724336 -0.619089 -0.501311
--0.373371;
-#X coords 0 1 299 -1 300 200 1;
-#X restore 521 23 graph;
-#X obj 144 486 dac~;
-#X msg 157 86 reset;
-#X text 290 292 min/max points;
-#X text 289 390 min/max points;
-#X text 323 494 position;
-#X text 181 24 start;
-#X text 198 45 stop;
-#X msg 156 113 help;
-#X text 416 234 speed;
-#X text 337 254 (float or signal);
-#X obj 656 365 table buf2;
-#X floatatom 519 380 8 0 0;
-#X obj 519 353 soundfiler;
-#X msg 158 172 set buf2;
-#X msg 157 144 set buf;
-#X msg 372 82 interp \$1;
-#X msg 240 312 all;
-#X obj 198 341 xgroove~ buf;
-#X text 255 10 looping mode;
-#X text 370 9 interpolation;
-#X msg 20 170 pos 100;
-#X msg 35 199 pos 200;
-#X obj 152 447 *~;
-#X obj 22 242 ramp 10;
-#X msg 10 105 xzone \$1;
-#X obj 13 62 hsl 128 15 0 300 0 0 empty empty empty -2 -6 0 8 -262144
--1 -1 0 1;
-#X floatatom 10 83 5 0 0;
-#X obj 258 32 vdl 15 0 0 3 empty empty empty 0 -6 0 8 -262144 -1 -1
-0;
-#X text 277 29 once;
-#X text 277 45 forward;
-#X text 277 61 bidir;
-#X obj 372 31 vdl 15 0 0 3 empty empty empty 0 -6 0 8 -262144 -1 -1
-0;
-#X text 391 28 none;
-#X text 391 44 linear;
-#X text 391 60 4-point;
-#X obj 520 299 openpanel;
-#X msg 521 326 read -resize \$1 buf2;
-#X obj 521 275 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
--1;
-#X obj 256 134 vdl 15 0 0 4 empty empty empty 0 -6 0 8 -262144 -1 -1
-0;
-#X text 255 113 units;
-#X msg 256 199 units \$1;
-#X obj 364 134 vdl 15 0 0 4 empty empty empty 0 -6 0 8 -262144 -1 -1
-0;
-#X text 363 113 scale mode;
-#X msg 364 199 sclmode \$1;
-#X text 275 131 frames;
-#X text 275 147 buffer sz;
-#X text 275 163 ms;
-#X text 275 178 s;
-#X text 383 147 units in loop;
-#X text 383 163 buffer;
-#X text 383 178 loop;
-#X text 383 131 units in buffer;
-#X obj 524 440 osc~ 1000;
-#X obj 524 498 tabwrite~ buf;
-#X obj 536 467 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
--1;
-#X msg 557 468 stop;
-#X obj 319 343 print A;
-#X msg 131 213 getattributes;
-#X msg 177 248 getmax;
-#X msg 120 248 getmin;
-#X connect 0 0 1 0;
-#X connect 1 0 31 0;
-#X connect 2 0 31 1;
-#X connect 3 0 31 2;
-#X connect 6 0 7 0;
-#X connect 7 0 8 0;
-#X connect 8 0 9 0;
-#X connect 10 0 31 0;
-#X connect 11 0 31 0;
-#X connect 12 0 31 0;
-#X connect 15 0 31 0;
-#X connect 21 0 31 0;
-#X connect 26 0 25 0;
-#X connect 27 0 31 0;
-#X connect 28 0 31 0;
-#X connect 29 0 31 0;
-#X connect 30 0 31 0;
-#X connect 31 0 36 1;
-#X connect 31 1 8 0;
-#X connect 31 2 4 0;
-#X connect 31 3 5 0;
-#X connect 31 5 70 0;
-#X connect 34 0 37 0;
-#X connect 35 0 37 0;
-#X connect 36 0 14 0;
-#X connect 36 0 14 1;
-#X connect 37 0 36 0;
-#X connect 37 1 31 0;
-#X connect 38 0 31 0;
-#X connect 39 0 40 0;
-#X connect 40 0 38 0;
-#X connect 41 0 10 0;
-#X connect 45 0 29 0;
-#X connect 49 0 50 0;
-#X connect 50 0 26 0;
-#X connect 51 0 49 0;
-#X connect 52 0 54 0;
-#X connect 54 0 31 0;
-#X connect 55 0 57 0;
-#X connect 57 0 31 0;
-#X connect 66 0 67 0;
-#X connect 68 0 67 0;
-#X connect 69 0 67 0;
-#X connect 71 0 31 0;
-#X connect 72 0 31 0;
-#X connect 73 0 31 0;
+#N canvas 92 110 841 560 12;
+#X obj 258 240 hsl 128 15 0.001 3 1 1 empty empty empty 20 8 0 8 -225271
+-1 -1 3600 1;
+#X floatatom 255 261 8 0 0 0 - - -;
+#X floatatom 275 312 8 0 0 0 - - -;
+#X floatatom 350 312 8 0 0 0 - - -;
+#X floatatom 273 372 8 0 0 0 - - -;
+#X floatatom 348 372 8 0 0 0 - - -;
+#X obj 275 419 loadbang;
+#X obj 274 445 metro 30;
+#X obj 250 470 snapshot~;
+#X floatatom 250 494 8 0 0 0 - - -;
+#X msg 258 82 loop \$1;
+#X obj 159 27 bng 15 250 50 0 empty empty empty 20 8 0 8 -258699 -1
+-1;
+#X msg 158 47 stop;
+#N canvas 0 0 450 300 graph7 0;
+#X array buf 300 float 1;
+#A 0 0.841115 0.9094 0.95923 0.989636 0.999991 0.990063 0.960094 0.910649
+0.842757 0.757796 0.65746 0.543816 0.419143 0.285978 0.147021 0.00508036
+-0.136962 -0.276228 -0.409895 -0.535265 -0.649771 -0.751121 -0.83725
+-0.906401 -0.957205 -0.988587 -0.999947 -0.991051 -0.962051 -0.913577
+-0.846573 -0.762418 -0.662823 -0.549777 -0.425604 -0.292801 -0.154064
+-0.0122066 0.129898 0.269372 0.403387 0.529223 0.644347 0.746395 0.833328
+0.903378 0.955105 0.987498 0.99986 0.991967 0.963983 0.91644 0.850346
+0.767009 0.668129 0.555721 0.432034 0.299602 0.161097 0.0193266 -0.122836
+-0.262506 -0.396859 -0.523173 -0.638875 -0.741645 -0.82937 -0.900294
+-0.952984 -0.986339 -0.999729 -0.992844 -0.965842 -0.919283 -0.854067
+-0.771564 -0.673418 -0.561622 -0.438457 -0.306392 -0.168126 -0.0264512
+0.115759 0.255627 0.390308 0.517083 0.633384 0.736837 0.825374 0.89717
+0.95079 0.985156 0.999531 0.993672 0.967666 0.922048 0.857765 0.776069
+0.678665 0.567504 0.444838 0.313167 0.175141 0.0335691 -0.108684 -0.248732
+-0.383745 -0.510974 -0.627851 -0.732014 -0.821324 -0.894008 -0.948562
+-0.983895 -0.999309 -0.994439 -0.96944 -0.924788 -0.861391 -0.780556
+-0.683878 -0.573355 -0.451214 -0.319922 -0.182154 -0.0406903 0.101596
+0.241826 0.37715 0.504839 0.62229 0.727131 0.81725 0.890784 0.946286
+0.982602 0.999003 0.99518 0.971156 0.927473 0.864993 0.784974 0.689065
+0.579174 0.457555 0.326665 0.189149 0.047805 -0.0945095 -0.234908 -0.370551
+-0.498674 -0.616703 -0.722227 -0.813114 -0.887541 -0.943952 -0.981256
+-0.998669 -0.995836 -0.972845 -0.93011 -0.868543 -0.789377 -0.694202
+-0.584975 -0.463879 -0.333389 -0.196144 -0.0549212 0.0874133 0.227976
+0.363918 0.492493 0.611072 0.717282 0.80895 0.88422 0.941593 0.979852
+0.998275 0.996467 0.974453 0.932714 0.872048 0.793723 0.699318 0.590728
+0.47018 0.340094 0.20312 0.0620311 -0.0803164 -0.221037 -0.357277 -0.486275
+-0.605431 -0.712297 -0.804743 -0.880878 -0.939154 -0.97842 -0.99783
+-0.997035 -0.976038 -0.935246 -0.875523 -0.798037 -0.704388 -0.596471
+-0.476452 -0.346789 -0.210093 -0.0691412 0.0732124 0.21408 0.350613
+0.480039 0.599733 0.707289 0.800488 0.87748 0.936691 0.976908 0.997349
+0.997554 0.977556 0.937754 0.87893 0.802314 0.709426 0.602164 0.482708
+0.353456 0.217051 0.0762439 -0.0661074 -0.207122 -0.343933 -0.473779
+-0.594024 -0.702224 -0.796211 -0.87404 -0.934169 -0.975372 -0.996792
+-0.998035 -0.979032 -0.940196 -0.882319 -0.806539 -0.714434 -0.60784
+-0.48893 -0.36012 -0.224 -0.0833475 0.0589955 0.200142 0.337238 0.467489
+0.588274 0.69714 0.791867 0.870566 0.931602 0.973768 0.996211 0.998443
+0.980464 0.9426 0.885637 0.810741 0.719392 0.613481 0.495132 0.366748
+0.230939 0.0904412 -0.0518851 -0.193161 -0.33052 -0.461188 -0.582499
+-0.692013 -0.787507 -0.867028 -0.928998 -0.972125 -0.995556 -0.998827
+-0.98183 -0.944959 -0.888927 -0.81488 -0.724336 -0.619089 -0.501311
+-0.373371;
+#X coords 0 1 299 -1 300 200 1;
+#X restore 521 23 graph;
+#X obj 144 486 dac~;
+#X msg 157 86 reset;
+#X text 290 292 min/max points;
+#X text 289 390 min/max points;
+#X text 323 494 position;
+#X text 181 24 start;
+#X text 198 45 stop;
+#X msg 156 113 help;
+#X text 416 234 speed;
+#X text 337 254 (float or signal);
+#X obj 656 365 table buf2;
+#X floatatom 519 380 8 0 0 0 - - -;
+#X obj 519 353 soundfiler;
+#X msg 158 172 set buf2;
+#X msg 157 144 set buf;
+#X msg 372 82 interp \$1;
+#X msg 240 312 all;
+#X obj 198 341 xgroove~ buf;
+#X text 255 10 looping mode;
+#X text 370 9 interpolation;
+#X msg 20 170 pos 100;
+#X msg 35 199 pos 200;
+#X obj 152 447 *~;
+#X obj 22 242 ramp 10;
+#X msg 10 105 xzone \$1;
+#X obj 13 62 hsl 128 15 0 300 0 0 empty empty empty -2 -6 0 8 -262144
+-1 -1 800 1;
+#X floatatom 10 83 5 0 0 0 - - -;
+#X obj 258 32 vdl 15 0 0 3 empty empty empty 0 -6 0 8 -262144 -1 -1
+0;
+#X text 277 29 once;
+#X text 277 45 forward;
+#X text 277 61 bidir;
+#X obj 372 31 vdl 15 0 0 3 empty empty empty 0 -6 0 8 -262144 -1 -1
+0;
+#X text 391 28 none;
+#X text 391 44 linear;
+#X text 391 60 4-point;
+#X obj 520 299 openpanel;
+#X msg 521 326 read -resize \$1 buf2;
+#X obj 521 275 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X obj 256 134 vdl 15 0 0 4 empty empty empty 0 -6 0 8 -262144 -1 -1
+0;
+#X text 255 113 units;
+#X msg 256 199 units \$1;
+#X obj 364 134 vdl 15 0 0 4 empty empty empty 0 -6 0 8 -262144 -1 -1
+0;
+#X text 363 113 scale mode;
+#X msg 364 199 sclmode \$1;
+#X text 275 131 frames;
+#X text 275 147 buffer sz;
+#X text 275 163 ms;
+#X text 275 178 s;
+#X text 383 147 units in loop;
+#X text 383 163 buffer;
+#X text 383 178 loop;
+#X text 383 131 units in buffer;
+#X obj 524 440 osc~ 1000;
+#X obj 524 498 tabwrite~ buf;
+#X obj 536 467 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X msg 557 468 stop;
+#X obj 319 343 print A;
+#X msg 131 213 getattributes;
+#X msg 177 248 getmax;
+#X msg 120 248 getmin;
+#X connect 0 0 1 0;
+#X connect 1 0 31 0;
+#X connect 2 0 31 1;
+#X connect 3 0 31 2;
+#X connect 6 0 7 0;
+#X connect 7 0 8 0;
+#X connect 8 0 9 0;
+#X connect 10 0 31 0;
+#X connect 11 0 31 0;
+#X connect 12 0 31 0;
+#X connect 15 0 31 0;
+#X connect 21 0 31 0;
+#X connect 26 0 25 0;
+#X connect 27 0 31 0;
+#X connect 28 0 31 0;
+#X connect 29 0 31 0;
+#X connect 30 0 31 0;
+#X connect 31 0 36 1;
+#X connect 31 1 8 0;
+#X connect 31 2 4 0;
+#X connect 31 3 5 0;
+#X connect 31 5 70 0;
+#X connect 34 0 37 0;
+#X connect 35 0 37 0;
+#X connect 36 0 14 0;
+#X connect 36 0 14 1;
+#X connect 37 0 36 0;
+#X connect 37 1 31 0;
+#X connect 38 0 31 0;
+#X connect 39 0 40 0;
+#X connect 40 0 38 0;
+#X connect 41 0 10 0;
+#X connect 45 0 29 0;
+#X connect 49 0 50 0;
+#X connect 50 0 26 0;
+#X connect 51 0 49 0;
+#X connect 52 0 54 0;
+#X connect 54 0 31 0;
+#X connect 55 0 57 0;
+#X connect 57 0 31 0;
+#X connect 66 0 67 0;
+#X connect 68 0 67 0;
+#X connect 69 0 67 0;
+#X connect 71 0 31 0;
+#X connect 72 0 31 0;
+#X connect 73 0 31 0;
diff --git a/externals/grill/xsample/readme.txt b/externals/grill/xsample/readme.txt
index 8f88cd2d..07aa5a6a 100644
--- a/externals/grill/xsample/readme.txt
+++ b/externals/grill/xsample/readme.txt
@@ -10,13 +10,10 @@ Donations for further development of the package are highly appreciated.
IMPORTANT INFORMATION for all MaxMSP users:
-It is advisable to put the xsample shared library file into the "startup" folder. Hence it will be
+It is advisable to put the xsample shared library file into the "max-startup" folder. Hence it will be
loaded at Max startup.
-If you want to load the xsample library on demand, please run MakeAliases inside the MPW folder.
-This will create aliases to the several xsample objects contained in the library.
-Move these into the "externals" folder.
-(This latter procedure is only tested for OS 9.2, you may experience problems with other MacOS versions)
+If you want to load the xsample library on demand, create a [xsample] object in Max/MSP.
----------------------------------------------------------------------------
@@ -44,15 +41,24 @@ o Microsoft Visual C++ 6: edit "xsample.dsp" project file
pd - linux:
-----------
-o GCC for linux: run "make -f makefile.pd-linux" and as root "make -f makefile.pd-linux install"
+o GCC: edit "config-pd-linux.txt" and run "sh ./build-pd-linux.sh"
> various versions of GCC die during compile with template optimization turned on
-Max/MSP - MacOS:
+pd - OSX:
+-----------
+o GCC: edit "config-pd-darwin.txt" and run "sh ./build-pd-darwin.sh"
+> various versions of GCC die during compile with template optimization turned on
+
+Max/MSP - MacOS9:
----------------
-o Metrowerks CodeWarrior V6: edit "xsample.cw" project file functions
+o Metrowerks CodeWarrior: edit "xsample.cw" project file functions
o Apple MPW-PR: edit & use the "flext.mpw" makefile
+Max/MSP - MacOSX:
+----------------
+o Metrowerks CodeWarrior: edit "xsample.cw" project file functions
+
----------------------------------------------------------------------------
@@ -71,7 +77,7 @@ Goals/features of the package:
Version history:
-0.2.5:
+0.3.0:
- added resources to MaxMSP build
- xgroove~, xrecord~: introduced a loop/end bang outlet
- added MaxMSP buffer resize recognition
@@ -80,7 +86,8 @@ Version history:
- introduced attributes
- restructured make procedures
- corrected names of PD makefile, set help names
-- fixed scale mode bug
+- fixed scale mode bug with xgroove~
+- added validity check for buffers
0.2.4:
- according to flext 0.2.3 changed sample type to t_sample (S)
@@ -125,7 +132,6 @@ Version history:
TODO list:
general:
-- Documentation and better example patches
- do a smooth (line~) mixin in xrecord~ help patch
diff --git a/externals/grill/xsample/source/groove.cpp b/externals/grill/xsample/source/groove.cpp
index 62f0c291..60bf617b 100644
--- a/externals/grill/xsample/source/groove.cpp
+++ b/externals/grill/xsample/source/groove.cpp
@@ -103,8 +103,10 @@ private:
virtual V m_signal(I n,S *const *in,S *const *out)
{
- bufchk();
- posfun(n,in,out);
+ if(bufchk())
+ posfun(n,in,out);
+ else
+ zerofun(n,in,out);
}
FLEXT_CALLBACK_F(m_pos)
@@ -195,11 +197,11 @@ xgroove::xgroove(I argc,const t_atom *argv):
AddOutFloat("Ending point (rounded to frame)"); // play max
AddOutBang("Bang on loop end/rollover"); // loop bang
-
znbuf = new S *[outchns];
for(I i = 0; i < outchns; ++i) znbuf[i] = new S[0];
- znpos = new S[0];
+ znpos = new S[0]; // don't know vector size yet -> m_dsp
znidx = new S[0];
+ znmul = new S[XZONE_TABLE+1];
m_xshape();
}
@@ -304,9 +306,6 @@ V xgroove::m_xshape(I argc,const t_atom *argv)
else if(xshparam > 1) xshparam = 1;
}
- if(znmul) delete[] znmul;
- znmul = new S[XZONE_TABLE+1];
-
I i;
switch(xshape) {
case 1:
@@ -393,13 +392,11 @@ V xgroove::s_pos_off(I n,S *const *invecs,S *const *outvecs)
{
S *pos = outvecs[outchns];
- I si;
- for(si = 0; si < n; ++si) pos[si] = curpos;
+ SetSamples(pos,n,curpos);
playfun(n,&pos,outvecs);
- const F oscl = scale(curpos);
- for(si = 0; si < n; ++si) pos[si] = oscl;
+ SetSamples(pos,n,scale(curpos));
}
V xgroove::s_pos_once(I n,S *const *invecs,S *const *outvecs)
@@ -427,7 +424,7 @@ V xgroove::s_pos_once(I n,S *const *invecs,S *const *outvecs)
playfun(n,&pos,outvecs);
- for(I i = 0; i < n; ++i) pos[i] = scale(pos[i]);
+ arrscale(n,pos,pos);
}
else
s_pos_off(n,invecs,outvecs);
@@ -467,7 +464,7 @@ V xgroove::s_pos_loop(I n,S *const *invecs,S *const *outvecs)
playfun(n,&pos,outvecs);
- for(I i = 0; i < n; ++i) pos[i] = scale(pos[i]);
+ arrscale(n,pos,pos);
}
else
s_pos_off(n,invecs,outvecs);
@@ -523,15 +520,16 @@ V xgroove::s_pos_loopzn(I n,S *const *invecs,S *const *outvecs)
playfun(n,&pos,outvecs);
- for(I i = 0; i < n; ++i) pos[i] = scale(pos[i]);
+ arrscale(n,pos,pos);
if(inzn) {
// only if we were in cross-fade zone
playfun(n,&znpos,znbuf);
- for(I i = 0; i < n; ++i) znpos[i] = XZONE_TABLE-znidx[i];
- zonefun(znmul,0,XZONE_TABLE+1,1,n,1,1,&znidx,&znidx);
- zonefun(znmul,0,XZONE_TABLE+1,1,n,1,1,&znpos,&znpos);
+ arrscale(n,znidx,znpos,-XZONE_TABLE,-1);
+
+ zonefun(znmul,0,XZONE_TABLE+1,n,1,1,&znidx,&znidx);
+ zonefun(znmul,0,XZONE_TABLE+1,n,1,1,&znpos,&znpos);
for(I o = 0; o < outchns; ++o) {
F *ov = outvecs[o],*ob = znbuf[o];
@@ -582,7 +580,7 @@ V xgroove::s_pos_bidir(I n,S *const *invecs,S *const *outvecs)
bidir = (I)bd;
playfun(n,&pos,outvecs);
- for(I i = 0; i < n; ++i) pos[i] = scale(pos[i]);
+ arrscale(n,pos,pos);
}
else
s_pos_off(n,invecs,outvecs);
@@ -614,6 +612,8 @@ V xgroove::s_dsp()
SETSIGFUN(posfun,SIGFUN(s_pos_loopzn));
+ // linear interpolation should be just ok for fade zone, no?
+/*
if(interp == xsi_4p)
switch(outchns) {
case 1: SETSTFUN(zonefun,TMPLSTF(st_play4,1,1)); break;
@@ -622,12 +622,14 @@ V xgroove::s_dsp()
default: SETSTFUN(zonefun,TMPLSTF(st_play4,1,-1));
}
else if(interp == xsi_lin)
+*/
switch(outchns) {
case 1: SETSTFUN(zonefun,TMPLSTF(st_play2,1,1)); break;
case 2: SETSTFUN(zonefun,TMPLSTF(st_play2,1,2)); break;
case 4: SETSTFUN(zonefun,TMPLSTF(st_play2,1,4)); break;
default: SETSTFUN(zonefun,TMPLSTF(st_play2,1,-1));
}
+/*
else
switch(outchns) {
case 1: SETSTFUN(zonefun,TMPLSTF(st_play1,1,1)); break;
@@ -635,6 +637,7 @@ V xgroove::s_dsp()
case 4: SETSTFUN(zonefun,TMPLSTF(st_play1,1,4)); break;
default: SETSTFUN(zonefun,TMPLSTF(st_play1,1,-1));
}
+*/
}
else
SETSIGFUN(posfun,SIGFUN(s_pos_loop));
diff --git a/externals/grill/xsample/source/inter.cpp b/externals/grill/xsample/source/inter.cpp
index 42221e1c..f3fba86c 100644
--- a/externals/grill/xsample/source/inter.cpp
+++ b/externals/grill/xsample/source/inter.cpp
@@ -16,7 +16,7 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#endif
#ifndef TMPLOPT
-#include "inter.ci"
+#include "inter.h"
#endif
void xinter::setup(t_classid c)
@@ -53,6 +53,13 @@ V xinter::m_stop()
V xinter::s_dsp()
{
+ switch(outchns) {
+ case 1: SETSIGFUN(zerofun,TMPLFUN(s_play0,-1,1)); break;
+ case 2: SETSIGFUN(zerofun,TMPLFUN(s_play0,-1,2)); break;
+ case 4: SETSIGFUN(zerofun,TMPLFUN(s_play0,-1,4)); break;
+ default: SETSIGFUN(zerofun,TMPLFUN(s_play0,-1,-1));
+ }
+
if(doplay) {
if(interp == xsi_4p)
switch(buf->Channels()*1000+outchns) {
diff --git a/externals/grill/xsample/source/inter.ci b/externals/grill/xsample/source/inter.h
index 1ce98f61..697c66df 100644..100755
--- a/externals/grill/xsample/source/inter.ci
+++ b/externals/grill/xsample/source/inter.h
@@ -11,23 +11,18 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#ifndef __INTER_H
#define __INTER_H
-TMPLDEF V xinter::st_play0(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
+TMPLDEF V xinter::st_play0(const S *,const I ,const I ,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
{
- // stopped
- SIGCHNS(BCHNS,inchns,OCHNS,outchns);
-
-// const S *pos = invecs[0];
- S *const *sig = outvecs;
-
- for(I ci = 0; ci < outchns; ++ci)
- for(I si = 0; si < n; ++si) sig[ci][si] = 0;
+ // stopped/invalid buffer -> output zero
+ for(I ci = 0; ci < outchns; ++ci) ZeroSamples(outvecs[ci],n);
}
-TMPLDEF V xinter::st_play1(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
+TMPLDEF V xinter::st_play1(const S *bdt,const I smin,const I smax,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
{
SIGCHNS(BCHNS,inchns,OCHNS,outchns);
- const S *pos = invecs[0];
+ // position info are frame units
+ const S *pos = invecs[0];
S *const *sig = outvecs;
register I si = 0;
@@ -55,20 +50,20 @@ TMPLDEF V xinter::st_play1(const S *bdt,const I smin,const I smax,const F s2u,co
}
// clear rest of output channels (if buffer has less channels)
- for(I ci = OCHNS; ci < outchns; ++ci)
- for(si = 0; si < n; ++si) sig[ci][si] = 0;
+ for(I ci = OCHNS; ci < outchns; ++ci) ZeroSamples(sig[ci],n);
}
-TMPLDEF V xinter::st_play2(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
+TMPLDEF V xinter::st_play2(const S *bdt,const I smin,const I smax,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
{
const I plen = smax-smin; //curlen;
if(plen < 2) {
- st_play1 TMPLCALL (bdt,smin,smax,s2u,n,inchns,outchns,invecs,outvecs);
+ st_play1 TMPLCALL (bdt,smin,smax,n,inchns,outchns,invecs,outvecs);
return;
}
SIGCHNS(BCHNS,inchns,OCHNS,outchns);
+ // position info are frame units
const S *pos = invecs[0];
S *const *sig = outvecs;
register I si = 0;
@@ -105,21 +100,21 @@ TMPLDEF V xinter::st_play2(const S *bdt,const I smin,const I smax,const F s2u,co
}
// clear rest of output channels (if buffer has less channels)
- for(I ci = OCHNS; ci < outchns; ++ci)
- for(si = 0; si < n; ++si) sig[ci][si] = 0;
+ for(I ci = OCHNS; ci < outchns; ++ci) ZeroSamples(sig[ci],n);
}
-TMPLDEF V xinter::st_play4(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
+TMPLDEF V xinter::st_play4(const S *bdt,const I smin,const I smax,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
{
const I plen = smax-smin; //curlen;
if(plen < 4) {
- if(plen < 2) st_play1 TMPLCALL (bdt,smin,smax,s2u,n,inchns,outchns,invecs,outvecs);
- else st_play2 TMPLCALL (bdt,smin,smax,s2u,n,inchns,outchns,invecs,outvecs);
+ if(plen < 2) st_play1 TMPLCALL (bdt,smin,smax,n,inchns,outchns,invecs,outvecs);
+ else st_play2 TMPLCALL (bdt,smin,smax,n,inchns,outchns,invecs,outvecs);
return;
}
SIGCHNS(BCHNS,inchns,OCHNS,outchns);
+ // position info are frame units
const S *pos = invecs[0];
S *const *sig = outvecs;
register I si = 0;
@@ -167,29 +162,28 @@ TMPLDEF V xinter::st_play4(const S *bdt,const I smin,const I smax,const F s2u,co
}
// clear rest of output channels (if buffer has less channels)
- for(I ci = OCHNS; ci < outchns; ++ci)
- for(si = 0; si < n; ++si) sig[ci][si] = 0;
+ for(I ci = OCHNS; ci < outchns; ++ci) ZeroSamples(sig[ci],n);
}
-TMPLDEF V xinter::s_play0(I n,S *const *invecs,S *const *outvecs)
+TMPLDEF inline V xinter::s_play0(I n,S *const *invecs,S *const *outvecs)
{
- st_play0 TMPLCALL (buf->Data(),curmin,curmax,s2u,n,buf->Channels(),outchns,invecs,outvecs);
+ st_play0 TMPLCALL (buf->Data(),curmin,curmax,n,buf->Channels(),outchns,invecs,outvecs);
}
-TMPLDEF V xinter::s_play1(I n,S *const *invecs,S *const *outvecs)
+TMPLDEF inline V xinter::s_play1(I n,S *const *invecs,S *const *outvecs)
{
- st_play1 TMPLCALL (buf->Data(),curmin,curmax,s2u,n,buf->Channels(),outchns,invecs,outvecs);
+ st_play1 TMPLCALL (buf->Data(),curmin,curmax,n,buf->Channels(),outchns,invecs,outvecs);
}
-TMPLDEF V xinter::s_play2(I n,S *const *invecs,S *const *outvecs)
+TMPLDEF inline V xinter::s_play2(I n,S *const *invecs,S *const *outvecs)
{
- st_play2 TMPLCALL (buf->Data(),curmin,curmax,s2u,n,buf->Channels(),outchns,invecs,outvecs);
+ st_play2 TMPLCALL (buf->Data(),curmin,curmax,n,buf->Channels(),outchns,invecs,outvecs);
}
-TMPLDEF V xinter::s_play4(I n,S *const *invecs,S *const *outvecs)
+TMPLDEF inline V xinter::s_play4(I n,S *const *invecs,S *const *outvecs)
{
- st_play4 TMPLCALL (buf->Data(),curmin,curmax,s2u,n,buf->Channels(),outchns,invecs,outvecs);
+ st_play4 TMPLCALL (buf->Data(),curmin,curmax,n,buf->Channels(),outchns,invecs,outvecs);
}
diff --git a/externals/grill/xsample/source/main.cpp b/externals/grill/xsample/source/main.cpp
index 2a39950d..2392bdb1 100644
--- a/externals/grill/xsample/source/main.cpp
+++ b/externals/grill/xsample/source/main.cpp
@@ -72,6 +72,18 @@ xsample::~xsample()
}
+BL xsample::bufchk()
+{
+ if(buf->Valid()) {
+ if(buf->Update()) {
+// post("%s - buffer updated",thisName());
+ m_refresh();
+ }
+ return true;
+ }
+ else
+ return false;
+}
I xsample::m_set(I argc,const t_atom *argv)
{
@@ -115,7 +127,7 @@ V xsample::m_loadbang()
V xsample::m_units(xs_unit mode)
{
- bufchk();
+ if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed)
if(mode != xsu__) unitmode = mode;
switch(unitmode) {
@@ -138,7 +150,7 @@ V xsample::m_units(xs_unit mode)
V xsample::m_sclmode(xs_sclmd mode)
{
- bufchk();
+ if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed)
if(mode != xss__) sclmode = mode;
switch(sclmode) {
@@ -162,7 +174,7 @@ V xsample::m_sclmode(xs_sclmd mode)
V xsample::m_min(F mn)
{
- bufchk();
+ if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed)
mn /= s2u; // conversion to samples
if(mn < 0) mn = 0;
@@ -175,7 +187,7 @@ V xsample::m_min(F mn)
V xsample::m_max(F mx)
{
- bufchk();
+ if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed)
mx /= s2u; // conversion to samples
if(mx > buf->Frames()) mx = (F)buf->Frames();
@@ -188,7 +200,7 @@ V xsample::m_max(F mx)
V xsample::m_all()
{
- bufchk();
+ if(!bufchk()) return; // if invalid do nothing (actually, it should be delayed)
// curlen = (curmax = buf->Frames())-(curmin = 0);
curmin = 0; curmax = buf->Frames();
@@ -203,5 +215,44 @@ V xsample::m_dsp(I /*n*/,S *const * /*insigs*/,S *const * /*outsigs*/)
}
+V xsample::arrscale(I n,const S *src,S *dst,S add,S mul)
+{
+ int n8 = n>>3;
+ n -= n8<<3;
+ while(n8--) {
+ dst[0] = (src[0]+add)*mul;
+ dst[1] = (src[1]+add)*mul;
+ dst[2] = (src[2]+add)*mul;
+ dst[3] = (src[3]+add)*mul;
+ dst[4] = (src[4]+add)*mul;
+ dst[5] = (src[5]+add)*mul;
+ dst[6] = (src[6]+add)*mul;
+ dst[7] = (src[7]+add)*mul;
+ src += 8,dst += 8;
+ }
+
+ while(n--) *(dst++) = (*(src++)+add)*mul;
+}
+
+V xsample::arrmul(I n,const S *src,S *dst,S mul)
+{
+ int n8 = n>>3;
+ n -= n8<<3;
+ while(n8--) {
+ dst[0] = src[0]*mul;
+ dst[1] = src[1]*mul;
+ dst[2] = src[2]*mul;
+ dst[3] = src[3]*mul;
+ dst[4] = src[4]*mul;
+ dst[5] = src[5]*mul;
+ dst[6] = src[6]*mul;
+ dst[7] = src[7]*mul;
+ src += 8,dst += 8;
+ }
+
+ while(n--) *(dst++) = *(src++)*mul;
+}
+
+
diff --git a/externals/grill/xsample/source/main.h b/externals/grill/xsample/source/main.h
index 94f8885f..03d5d261 100644
--- a/externals/grill/xsample/source/main.h
+++ b/externals/grill/xsample/source/main.h
@@ -11,19 +11,18 @@ WARRANTIES, see the file, "license.txt," in this distribution.
#ifndef __XSAMPLE_H
#define __XSAMPLE_H
-#define XSAMPLE_VERSION "0.2.5pre3"
+#define XSAMPLE_VERSION "0.3.0pre4"
#define FLEXT_ATTRIBUTES 1
#include <flext.h>
-#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 401)
-#error You need at least flext version 0.4.1
+#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 402)
+#error You need at least flext version 0.4.2
#endif
-// most compilers are somehow broken.....
-// in other words: can't handle all C++ features
+// most compilers are somehow broken - in other words - can't handle all C++ features
#if defined(_MSC_VER)
// MS VC 6.0 can't handle <int,int> templates?! -> no optimization
@@ -123,8 +122,14 @@ protected:
F s2u; // sample to unit conversion factor
inline F scale(F smp) const { return (smp-sclmin)*sclmul; }
+
+ static V arrscale(I n,const S *in,S *out,S add,S mul);
+ inline V arrscale(I n,const S *in,S *out) const { arrscale(n,in,out,(S)-sclmin,sclmul); }
+
+ static V arrmul(I n,const S *in,S *out,S mul);
+ inline V arrmul(I n,const S *in,S *out) const { arrmul(n,in,out,(S)(1./s2u)); }
- BL bufchk() { if(buf->Update()) { m_refresh(); return true; } return false; }
+ BL bufchk();
V mg_buffer(AtomList &l) { if(buf) { l(1); SetSymbol(l[0],buf->Symbol()); } else l(); }
inline V ms_buffer(const AtomList &l) { m_set(l.Count(),l.Atoms()); }
@@ -182,7 +187,7 @@ protected:
TMPLDEF static V st_##NAME(thisType *obj,I n,S *const *in,S *const *out) { obj->NAME TMPLCALL (n,in,out); } \
TMPLDEF V NAME(I n,S *const *in,S *const *out)
- #define TMPLSTFUN(NAME) TMPLDEF static V NAME(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
+ #define TMPLSTFUN(NAME) TMPLDEF static V NAME(const S *bdt,const I smin,const I smax,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
#define SETSIGFUN(VAR,FUN) v_##VAR = FUN
@@ -193,7 +198,7 @@ protected:
V (*v_##NAME)(thisType *obj,I n,S *const *in,S *const *out)
#define DEFSTCALL(NAME) \
- V (*NAME)(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
+ V (*NAME)(const S *bdt,const I smin,const I smax,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
#else
#ifdef TMPLOPT
@@ -212,7 +217,7 @@ protected:
#define DEFSIGFUN(NAME) V NAME(I n,S *const *in,S *const *out)
#define TMPLSIGFUN(NAME) TMPLDEF V NAME(I n,S *const *in,S *const *out)
- #define TMPLSTFUN(NAME) TMPLDEF static V NAME(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
+ #define TMPLSTFUN(NAME) TMPLDEF static V NAME(const S *bdt,const I smin,const I smax,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
#define SETSIGFUN(VAR,FUN) v_##VAR = FUN
@@ -223,7 +228,7 @@ protected:
#define SETSTFUN(VAR,FUN) VAR = FUN
#define DEFSTCALL(NAME) \
- V (*NAME)(const S *bdt,const I smin,const I smax,const F s2u,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
+ V (*NAME)(const S *bdt,const I smin,const I smax,const I n,const I inchns,const I outchns,S *const *invecs,S *const *outvecs)
#endif
@@ -285,6 +290,7 @@ protected:
TMPLSTFUN(st_play4);
DEFSIGCALL(playfun);
+ DEFSIGCALL(zerofun);
virtual V s_dsp();
@@ -296,7 +302,7 @@ private:
};
#ifdef TMPLOPT
-#include "inter.ci"
+#include "inter.h"
#endif
#endif
diff --git a/externals/grill/xsample/source/play.cpp b/externals/grill/xsample/source/play.cpp
index 50f32e75..037bc1bb 100644
--- a/externals/grill/xsample/source/play.cpp
+++ b/externals/grill/xsample/source/play.cpp
@@ -32,11 +32,7 @@ public:
private:
static V setup(t_classid c);
- virtual V m_signal(I n,S *const *in,S *const *out)
- {
- bufchk();
- playfun(n,in,out);
- }
+ virtual V m_signal(I n,S *const *in,S *const *out);
};
FLEXT_LIB_DSP_V("xplay~",xplay)
@@ -91,7 +87,20 @@ BL xplay::Init()
else
return false;
}
-
+
+V xplay::m_signal(I n,S *const *in,S *const *out)
+{
+ // check whether buffer is invalid or changed
+ if(bufchk()) {
+ // convert position units to frames
+ arrmul(n,in[0],out[0]);
+ // call resample routine
+ playfun(n,out,out);
+ }
+ else
+ zerofun(n,out,out);
+}
+
V xplay::m_help()
@@ -117,8 +126,8 @@ V xplay::m_help()
post("\tstop: stop playing");
post("\treset: checks buffer");
post("\trefresh: checks buffer and refreshes outlets");
- post("\tunits 0/1/2/3: set units to samples/buffer size/ms/s");
- post("\tinterp 0/1/2: set interpolation to off/4-point/linear");
+ post("\t@units 0/1/2/3: set units to samples/buffer size/ms/s");
+ post("\t@interp 0/1/2: set interpolation to off/4-point/linear");
post("");
}
diff --git a/externals/grill/xsample/source/record.cpp b/externals/grill/xsample/source/record.cpp
index ce169e9a..d6b9e70e 100644
--- a/externals/grill/xsample/source/record.cpp
+++ b/externals/grill/xsample/source/record.cpp
@@ -69,8 +69,7 @@ private:
DEFSIGCALL(recfun);
virtual V m_signal(I n,S *const *in,S *const *out)
{
- bufchk();
- recfun(n,in,out);
+ if(bufchk()) recfun(n,in,out);
}
FLEXT_CALLVAR_F(mg_pos,m_pos)
diff --git a/externals/grill/xsample/xsample.cw b/externals/grill/xsample/xsample.cw
index d893d3ef..70783c4d 100755
--- a/externals/grill/xsample/xsample.cw
+++ b/externals/grill/xsample/xsample.cw
Binary files differ
diff --git a/externals/grill/xsample/xsample.dsp b/externals/grill/xsample/xsample.dsp
index ec5bffb5..18119476 100644
--- a/externals/grill/xsample/xsample.dsp
+++ b/externals/grill/xsample/xsample.dsp
@@ -109,6 +109,10 @@ SOURCE=.\source\inter.cpp
# End Source File
# Begin Source File
+SOURCE=.\source\inter.h
+# End Source File
+# Begin Source File
+
SOURCE=.\source\main.cpp
# End Source File
# Begin Source File