aboutsummaryrefslogtreecommitdiff
path: root/externals/grill/flext
diff options
context:
space:
mode:
Diffstat (limited to 'externals/grill/flext')
-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
11 files changed, 94 insertions, 28 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