aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtab/makefile97
-rw-r--r--tab/tabosc4cloop~-help.pd78
-rw-r--r--tab/tabosc4cloop~.c205
-rw-r--r--tab/tabosc4c~-help.pd103
-rw-r--r--tab/tabosc4c~.c202
-rw-r--r--tab/tabread4c~-help.pd43
-rw-r--r--tab/tabread4c~.c137
7 files changed, 865 insertions, 0 deletions
diff --git a/tab/makefile b/tab/makefile
new file mode 100755
index 0000000..8250280
--- /dev/null
+++ b/tab/makefile
@@ -0,0 +1,97 @@
+current:
+ echo make pd_linux, pd_nt, pd_irix5, or pd_irix6
+
+clean: ; rm -f *.pd_linux *.o
+
+# ----------------------- NT -----------------------
+
+pd_nt: tabosc4c~.dll tabread4c~.dll
+
+.SUFFIXES: .dll
+
+PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo
+VC="C:\Program Files\Microsoft Visual Studio\Vc98"
+
+PDNTINCLUDE = /I. /I$(VC)\include /I..\..\..\pd\src\
+
+PDNTLDIR = $(VC)\lib
+PDNTLIB = $(PDNTLDIR)\libc.lib \
+ $(PDNTLDIR)\oldnames.lib \
+ $(PDNTLDIR)\kernel32.lib \
+ \pds\win32\pd36\bin\pd.lib
+
+.c.dll:
+ cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
+ link /dll /export:$*_setup $*.obj $(PDNTLIB)
+
+# ----------------------- IRIX 5.x -----------------------
+
+pd_irix5: tabosc4c~.pd_irix5 tabread4c~.pd_irix5
+
+.SUFFIXES: .pd_irix5
+
+SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
+
+
+SGIINCLUDE = -I../../../pd/src/
+
+.c.pd_irix5:
+ cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o
+ rm $*.o
+
+# ----------------------- IRIX 6.x -----------------------
+
+pd_irix6: tabosc4c~.pd_irix6 tabread4c~.pd_irix6
+
+.SUFFIXES: .pd_irix6
+
+SGICFLAGS6 = -n32 -DPD -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \
+ -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \
+ -Ofast=ip32
+
+.c.pd_irix6:
+ cc $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -IPA -n32 -shared -rdata_shared -o $*.pd_irix6 $*.o
+ rm $*.o
+
+# ----------------------- LINUX i386 -----------------------
+
+pd_linux: tabosc4c~.pd_linux tabread4c~.pd_linux tabosc4cloop~.pd_linux
+
+.SUFFIXES: .pd_linux
+
+LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \
+ -Wall -W -Wshadow -Wstrict-prototypes -Werror \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+LINUXINCLUDE = -I../../../pd/src/
+
+.c.pd_linux:
+ cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
+ ld -export_dynamic -shared -o $*.pd_linux $*.o -lc -lm
+ strip --strip-unneeded $*.pd_linux
+ rm $*.o
+
+# ----------------------- Mac OS X (Darwin) -----------------------
+
+
+pd_darwin: tabosc4c~.pd_darwin tabread4c~.pd_darwin
+
+.SUFFIXES: .pd_darwin
+
+DARWINCFLAGS = -DPD -DUNIX -DMACOSX -O2 \
+ -Wall -W -Wshadow -Wstrict-prototypes \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+# where is your m_pd.h ???
+DARWININCLUDE = -I/. -I../../../pd/src -I../../../pd/obj
+
+.c.pd_darwin:
+ cc $(DARWINCFLAGS) $(DARWININCLUDE) -o $*.o -c $*.c
+ cc -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o
+ rm -f $*.o ../$*.pd_darwin
+ ln -s $*/$*.pd_darwin ..
+
+
+
diff --git a/tab/tabosc4cloop~-help.pd b/tab/tabosc4cloop~-help.pd
new file mode 100644
index 0000000..caa3955
--- /dev/null
+++ b/tab/tabosc4cloop~-help.pd
@@ -0,0 +1,78 @@
+#N canvas 366 99 606 399 12;
+#X floatatom 40 42 9 0 0 0 - - -;
+#X obj 40 63 sig~ 100;
+#N canvas 0 0 450 300 (subpatch) 0;
+#X array array99 8 float 0;
+#X coords 0 1 7 -1 250 200 1;
+#X restore 250 120 graph;
+#X obj 251 14 loadbang;
+#X floatatom 40 -1 5 0 0 0 - - -;
+#X obj 40 19 mtof;
+#X floatatom 74 124 0 0 0 0 - - -;
+#N canvas 159 26 706 447 output 0;
+#X obj 414 196 t b;
+#X obj 414 134 f;
+#X obj 414 73 inlet;
+#X text 421 36 mute;
+#X obj 414 227 f;
+#X msg 521 218 0;
+#X msg 414 104 bang;
+#X obj 414 166 moses 1;
+#X obj 521 187 t b f;
+#X obj 486 143 moses 1;
+#X obj 102 181 dbtorms;
+#X obj 486 113 r master-lvl;
+#X obj 102 52 r master-lvl;
+#X obj 414 257 s master-lvl;
+#X obj 26 222 inlet~;
+#X obj 244 50 inlet;
+#X text 244 22 level;
+#X obj 244 122 s master-lvl;
+#X msg 118 80 set \$1;
+#X obj 118 109 outlet;
+#X msg 262 78 \; pd dsp 1;
+#X obj 102 238 line~;
+#X obj 26 259 *~;
+#X obj 26 295 dac~;
+#X obj 102 210 pack 0 50;
+#X text 24 195 audio;
+#X text 114 135 show level;
+#X connect 0 0 4 0;
+#X connect 1 0 7 0;
+#X connect 2 0 6 0;
+#X connect 4 0 13 0;
+#X connect 5 0 13 0;
+#X connect 6 0 1 0;
+#X connect 7 0 0 0;
+#X connect 7 1 8 0;
+#X connect 8 0 5 0;
+#X connect 9 1 4 1;
+#X connect 10 0 24 0;
+#X connect 11 0 1 1;
+#X connect 11 0 9 0;
+#X connect 12 0 10 0;
+#X connect 12 0 18 0;
+#X connect 14 0 22 0;
+#X connect 15 0 17 0;
+#X connect 15 0 20 0;
+#X connect 18 0 19 0;
+#X connect 21 0 22 1;
+#X connect 22 0 23 0;
+#X connect 22 0 23 1;
+#X connect 24 0 21 0;
+#X restore 40 150 pd output;
+#X msg 110 124 MUTE;
+#X obj 41 92 tabosc4cloop~ array99;
+#X msg 251 39 \; array99 resize 8 \; array99 0 0 0 -0.5 -0.5 1 -1 0.5
+0.5 \; pd dsp 1 \;;
+#X text 42 346 just like tabosc4c~ \, but does not need to copy the
+last 3 point in the beggining. So \, table must be a power of 2;
+#X connect 0 0 1 0;
+#X connect 1 0 9 0;
+#X connect 3 0 10 0;
+#X connect 4 0 5 0;
+#X connect 5 0 0 0;
+#X connect 6 0 7 1;
+#X connect 7 0 6 0;
+#X connect 8 0 7 2;
+#X connect 9 0 7 0;
diff --git a/tab/tabosc4cloop~.c b/tab/tabosc4cloop~.c
new file mode 100644
index 0000000..a2ac53c
--- /dev/null
+++ b/tab/tabosc4cloop~.c
@@ -0,0 +1,205 @@
+// GPL
+// most of this code comes from pd. just the interpolation shematic is diferent.
+// and the modulo for the position is made for all sample, so you do'nt need to copy the last 3 point in the beggining
+
+
+#include "m_pd.h"
+
+/******************** tabosc4cloop~ ***********************/
+
+/* this is all copied from d_osc.c... what include file could this go in? */
+#define UNITBIT32 1572864. /* 3*2^19; bit 32 has place value 1 */
+
+ /* machine-dependent definitions. These ifdefs really
+ should have been by CPU type and not by operating system! */
+#ifdef IRIX
+ /* big-endian. Most significant byte is at low address in memory */
+#define HIOFFSET 0 /* word offset to find MSB */
+#define LOWOFFSET 1 /* word offset to find LSB */
+#define int32 long /* a data type that has 32 bits */
+#endif /* IRIX */
+
+#ifdef MSW
+ /* little-endian; most significant byte is at highest address */
+#define HIOFFSET 1
+#define LOWOFFSET 0
+#define int32 long
+#endif
+
+#if defined(__FreeBSD__) || defined(__APPLE__)
+#include <machine/endian.h>
+#endif
+
+#ifdef __linux__
+#include <endian.h>
+#endif
+
+#if defined(__unix__) || defined(__APPLE__)
+#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN)
+#error No byte order defined
+#endif
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define HIOFFSET 1
+#define LOWOFFSET 0
+#else
+#define HIOFFSET 0 /* word offset to find MSB */
+#define LOWOFFSET 1 /* word offset to find LSB */
+#endif /* __BYTE_ORDER */
+#include <sys/types.h>
+#define int32 int32_t
+#endif /* __unix__ or __APPLE__*/
+
+union tabfudge
+{
+ double tf_d;
+ int32 tf_i[2];
+};
+
+static t_class *tabosc4cloop_tilde_class;
+
+typedef struct _tabosc4cloop_tilde
+{
+ t_object x_obj;
+ t_float x_fnpoints;
+ t_float x_finvnpoints;
+ t_word *x_vec;
+ t_symbol *x_arrayname;
+ t_float x_f;
+ double x_phase;
+ t_float x_conv;
+} t_tabosc4cloop_tilde;
+
+static void *tabosc4cloop_tilde_new(t_symbol *s)
+{
+ t_tabosc4cloop_tilde *x = (t_tabosc4cloop_tilde *)pd_new(tabosc4cloop_tilde_class);
+ x->x_arrayname = s;
+ x->x_vec = 0;
+ x->x_fnpoints = 512.;
+ x->x_finvnpoints = (1./512.);
+ outlet_new(&x->x_obj, gensym("signal"));
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
+ x->x_f = 0;
+ return (x);
+}
+
+static t_int *tabosc4cloop_tilde_perform(t_int *w)
+{
+ t_tabosc4cloop_tilde *x = (t_tabosc4cloop_tilde *)(w[1]);
+ t_sample *in = (t_sample *)(w[2]);
+ t_sample *out = (t_sample *)(w[3]);
+ int n = (int)(w[4]);
+ int normhipart;
+ union tabfudge tf;
+ double a0,a1,a2,a3; // CH
+ t_float fnpoints = x->x_fnpoints;
+ int mask = fnpoints -1;
+ t_float conv = fnpoints * x->x_conv;
+ int maxindex;
+ t_word *tab = x->x_vec, *addr;
+ int i;
+ double dphase = fnpoints * x->x_phase + UNITBIT32;
+
+ if (!tab) goto zero;
+ tf.tf_d = UNITBIT32;
+ normhipart = tf.tf_i[HIOFFSET];
+
+#if 1
+ while (n--)
+ {
+ t_sample frac, a, b, c, d, cminusb;
+ tf.tf_d = dphase;
+ dphase += *in++ * conv;
+ addr = tab + (tf.tf_i[HIOFFSET] & mask);
+// thx to dh
+ a = addr[0].w_float;
+ addr = tab + ((1+tf.tf_i[HIOFFSET]) & mask);
+ b = addr[0].w_float;
+ addr = tab + ((2+tf.tf_i[HIOFFSET]) & mask);
+ c = addr[0].w_float;
+ addr = tab + ((3+tf.tf_i[HIOFFSET]) & mask);
+ d = addr[0].w_float;
+ tf.tf_i[HIOFFSET] = normhipart;
+ frac = tf.tf_d - UNITBIT32;
+// CH
+ a0 = d - c - a + b;
+ a1 = a - b - a0;
+ a2 = c - a;
+ a3 = b;
+ *out++ = ((a0*frac+a1)*frac+a2)*frac+a3;
+
+ }
+#endif
+
+ tf.tf_d = UNITBIT32 * fnpoints;
+ normhipart = tf.tf_i[HIOFFSET];
+ tf.tf_d = dphase + (UNITBIT32 * fnpoints - UNITBIT32);
+ tf.tf_i[HIOFFSET] = normhipart;
+ x->x_phase = (tf.tf_d - UNITBIT32 * fnpoints) * x->x_finvnpoints;
+ return (w+5);
+ zero:
+ while (n--) *out++ = 0;
+
+ return (w+5);
+}
+
+void tabosc4cloop_tilde_set(t_tabosc4cloop_tilde *x, t_symbol *s)
+{
+ t_garray *a;
+ int npoints, pointsinarray;
+
+ x->x_arrayname = s;
+ if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
+ {
+ if (*s->s_name)
+ pd_error(x, "tabosc4cloop~: %s: no such array", x->x_arrayname->s_name);
+ x->x_vec = 0;
+ }
+ else if (!garray_getfloatwords(a, &pointsinarray, &x->x_vec))
+ {
+ pd_error(x, "%s: bad template for tabosc4cloop~", x->x_arrayname->s_name);
+ x->x_vec = 0;
+ }
+ else if (pointsinarray != (1 << ilog2(pointsinarray)))
+ {
+ pd_error(x, "%s: number of points (%d) not a power of 2",
+ x->x_arrayname->s_name, pointsinarray);
+ x->x_vec = 0;
+ garray_usedindsp(a);
+ }
+ else
+ {
+ x->x_fnpoints = pointsinarray;
+ x->x_finvnpoints = 1./pointsinarray;
+ garray_usedindsp(a);
+ }
+}
+
+static void tabosc4cloop_tilde_ft1(t_tabosc4cloop_tilde *x, t_float f)
+{
+ x->x_phase = f;
+}
+
+static void tabosc4cloop_tilde_dsp(t_tabosc4cloop_tilde *x, t_signal **sp)
+{
+ x->x_conv = 1. / sp[0]->s_sr;
+ tabosc4cloop_tilde_set(x, x->x_arrayname);
+
+ dsp_add(tabosc4cloop_tilde_perform, 4, x,
+ sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
+}
+
+void tabosc4cloop_tilde_setup(void)
+{
+ tabosc4cloop_tilde_class = class_new(gensym("tabosc4cloop~"),
+ (t_newmethod)tabosc4cloop_tilde_new, 0,
+ sizeof(t_tabosc4cloop_tilde), 0, A_DEFSYM, 0);
+ CLASS_MAINSIGNALIN(tabosc4cloop_tilde_class, t_tabosc4cloop_tilde, x_f);
+ class_addmethod(tabosc4cloop_tilde_class, (t_method)tabosc4cloop_tilde_dsp,
+ gensym("dsp"), 0);
+ class_addmethod(tabosc4cloop_tilde_class, (t_method)tabosc4cloop_tilde_set,
+ gensym("set"), A_SYMBOL, 0);
+ class_addmethod(tabosc4cloop_tilde_class, (t_method)tabosc4cloop_tilde_ft1,
+ gensym("ft1"), A_FLOAT, 0);
+}
+
diff --git a/tab/tabosc4c~-help.pd b/tab/tabosc4c~-help.pd
new file mode 100644
index 0000000..cce9642
--- /dev/null
+++ b/tab/tabosc4c~-help.pd
@@ -0,0 +1,103 @@
+#N canvas 79 60 755 582 12;
+#X floatatom 41 42 9 0 0 0 - - -;
+#X obj 41 63 sig~ 100;
+#N canvas 0 0 450 300 (subpatch) 0;
+#X array array99 11 float 0;
+#X coords 0 1 10 -1 250 200 1;
+#X restore 436 180 graph;
+#X obj 437 48 loadbang;
+#X floatatom 41 -1 5 0 0 0 - - -;
+#X obj 41 19 mtof;
+#X floatatom 77 307 0 0 0 0 - - -;
+#N canvas 159 26 706 447 output 0;
+#X obj 414 196 t b;
+#X obj 414 134 f;
+#X obj 414 73 inlet;
+#X text 421 36 mute;
+#X obj 414 227 f;
+#X msg 521 218 0;
+#X msg 414 104 bang;
+#X obj 414 166 moses 1;
+#X obj 521 187 t b f;
+#X obj 486 143 moses 1;
+#X obj 102 181 dbtorms;
+#X obj 486 113 r master-lvl;
+#X obj 102 52 r master-lvl;
+#X obj 414 257 s master-lvl;
+#X obj 26 222 inlet~;
+#X obj 244 50 inlet;
+#X text 244 22 level;
+#X obj 244 122 s master-lvl;
+#X msg 118 80 set \$1;
+#X obj 118 109 outlet;
+#X msg 262 78 \; pd dsp 1;
+#X obj 102 238 line~;
+#X obj 26 259 *~;
+#X obj 26 295 dac~;
+#X obj 102 210 pack 0 50;
+#X text 24 195 audio;
+#X text 114 135 show level;
+#X connect 0 0 4 0;
+#X connect 1 0 7 0;
+#X connect 2 0 6 0;
+#X connect 4 0 13 0;
+#X connect 5 0 13 0;
+#X connect 6 0 1 0;
+#X connect 7 0 0 0;
+#X connect 7 1 8 0;
+#X connect 8 0 5 0;
+#X connect 9 1 4 1;
+#X connect 10 0 24 0;
+#X connect 11 0 1 1;
+#X connect 11 0 9 0;
+#X connect 12 0 10 0;
+#X connect 12 0 18 0;
+#X connect 14 0 22 0;
+#X connect 15 0 17 0;
+#X connect 15 0 20 0;
+#X connect 18 0 19 0;
+#X connect 21 0 22 1;
+#X connect 22 0 23 0;
+#X connect 22 0 23 1;
+#X connect 24 0 21 0;
+#X restore 43 333 pd output;
+#X msg 113 307 MUTE;
+#X obj 42 123 tabosc4~ array99;
+#X obj 179 230 *~;
+#X msg 356 42 \$1 30;
+#X obj 359 19 hsl 128 15 0 1 0 0 empty empty empty -2 -8 0 10 -262144
+-1 -1 0 1;
+#X obj 357 89 -~ 1;
+#X obj 356 113 *~ -1;
+#X obj 356 66 line~;
+#X obj 43 231 *~;
+#X text 498 18 tabosc4~;
+#X text 279 17 tabosc4c~;
+#X msg 294 67 0;
+#X obj 178 123 tabosc4c~ array99;
+#X msg 437 75 \; array99 resize 11 \; array99 0 0 0 -0.5 -0.5 1 -1
+0.5 -1 0 0 0 \; pd dsp 1 \;;
+#X text 52 419 tabosc4c~ is a drop in remplacement for tabosc4~ \,
+but offer a true 4 points cubic interpolation. So \, quality is better
+than the standart interpolation;
+#X connect 0 0 1 0;
+#X connect 1 0 9 0;
+#X connect 1 0 20 0;
+#X connect 3 0 21 0;
+#X connect 4 0 5 0;
+#X connect 5 0 0 0;
+#X connect 6 0 7 1;
+#X connect 7 0 6 0;
+#X connect 8 0 7 2;
+#X connect 9 0 16 0;
+#X connect 10 0 7 0;
+#X connect 11 0 15 0;
+#X connect 12 0 11 0;
+#X connect 13 0 14 0;
+#X connect 14 0 10 1;
+#X connect 15 0 13 0;
+#X connect 15 0 16 1;
+#X connect 16 0 7 0;
+#X connect 19 0 9 1;
+#X connect 19 0 20 1;
+#X connect 20 0 10 0;
diff --git a/tab/tabosc4c~.c b/tab/tabosc4c~.c
new file mode 100644
index 0000000..56115e7
--- /dev/null
+++ b/tab/tabosc4c~.c
@@ -0,0 +1,202 @@
+// GPL
+// most of this code comes from pd. just the interpolation shematic is diferent.
+
+
+#include "m_pd.h"
+
+/******************** tabosc4c~ ***********************/
+
+/* this is all copied from d_osc.c... what include file could this go in? */
+#define UNITBIT32 1572864. /* 3*2^19; bit 32 has place value 1 */
+
+ /* machine-dependent definitions. These ifdefs really
+ should have been by CPU type and not by operating system! */
+#ifdef IRIX
+ /* big-endian. Most significant byte is at low address in memory */
+#define HIOFFSET 0 /* word offset to find MSB */
+#define LOWOFFSET 1 /* word offset to find LSB */
+#define int32 long /* a data type that has 32 bits */
+#endif /* IRIX */
+
+#ifdef MSW
+ /* little-endian; most significant byte is at highest address */
+#define HIOFFSET 1
+#define LOWOFFSET 0
+#define int32 long
+#endif
+
+#if defined(__FreeBSD__) || defined(__APPLE__)
+#include <machine/endian.h>
+#endif
+
+#ifdef __linux__
+#include <endian.h>
+#endif
+
+#if defined(__unix__) || defined(__APPLE__)
+#if !defined(BYTE_ORDER) || !defined(LITTLE_ENDIAN)
+#error No byte order defined
+#endif
+
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define HIOFFSET 1
+#define LOWOFFSET 0
+#else
+#define HIOFFSET 0 /* word offset to find MSB */
+#define LOWOFFSET 1 /* word offset to find LSB */
+#endif /* __BYTE_ORDER */
+#include <sys/types.h>
+#define int32 int32_t
+#endif /* __unix__ or __APPLE__*/
+
+union tabfudge
+{
+ double tf_d;
+ int32 tf_i[2];
+};
+
+static t_class *tabosc4c_tilde_class;
+
+typedef struct _tabosc4c_tilde
+{
+ t_object x_obj;
+ t_float x_fnpoints;
+ t_float x_finvnpoints;
+ t_word *x_vec;
+ t_symbol *x_arrayname;
+ t_float x_f;
+ double x_phase;
+ t_float x_conv;
+} t_tabosc4c_tilde;
+
+static void *tabosc4c_tilde_new(t_symbol *s)
+{
+ t_tabosc4c_tilde *x = (t_tabosc4c_tilde *)pd_new(tabosc4c_tilde_class);
+ x->x_arrayname = s;
+ x->x_vec = 0;
+ x->x_fnpoints = 512.;
+ x->x_finvnpoints = (1./512.);
+ outlet_new(&x->x_obj, gensym("signal"));
+ inlet_new(&x->x_obj, &x->x_obj.ob_pd, &s_float, gensym("ft1"));
+ x->x_f = 0;
+ return (x);
+}
+
+static t_int *tabosc4c_tilde_perform(t_int *w)
+{
+ t_tabosc4c_tilde *x = (t_tabosc4c_tilde *)(w[1]);
+ t_sample *in = (t_sample *)(w[2]);
+ t_sample *out = (t_sample *)(w[3]);
+ int n = (int)(w[4]);
+ int normhipart;
+ union tabfudge tf;
+ double a0,a1,a2; // CH
+ t_float fnpoints = x->x_fnpoints;
+ int mask = fnpoints - 1;
+ t_float conv = fnpoints * x->x_conv;
+ int maxindex;
+ t_word *tab = x->x_vec, *addr;
+ int i;
+ double dphase = fnpoints * x->x_phase + UNITBIT32;
+
+ if (!tab) goto zero;
+ tf.tf_d = UNITBIT32;
+ normhipart = tf.tf_i[HIOFFSET];
+
+#if 1
+ while (n--)
+ {
+ t_sample frac, a, b, c, d, cminusb;
+ tf.tf_d = dphase;
+ dphase += *in++ * conv;
+ addr = tab + (tf.tf_i[HIOFFSET] & mask);
+ tf.tf_i[HIOFFSET] = normhipart;
+ frac = tf.tf_d - UNITBIT32;
+ a = addr[0].w_float;
+ b = addr[1].w_float;
+ c = addr[2].w_float;
+ d = addr[3].w_float;
+// cminusb = c-b;
+// *out++ = b + frac * (
+// cminusb - 0.1666667f * (1.-frac) * (
+// (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b) ) );
+// CH
+ a0 = d - c - a + b;
+ a1 = a - b - a0;
+ a2 = c - a;
+ *out++ = ((a0*frac+a1)*frac+a2)*frac+b;
+ }
+#endif
+
+ tf.tf_d = UNITBIT32 * fnpoints;
+ normhipart = tf.tf_i[HIOFFSET];
+ tf.tf_d = dphase + (UNITBIT32 * fnpoints - UNITBIT32);
+ tf.tf_i[HIOFFSET] = normhipart;
+ x->x_phase = (tf.tf_d - UNITBIT32 * fnpoints) * x->x_finvnpoints;
+ return (w+5);
+ zero:
+ while (n--) *out++ = 0;
+
+ return (w+5);
+}
+
+void tabosc4c_tilde_set(t_tabosc4c_tilde *x, t_symbol *s)
+{
+ t_garray *a;
+ int npoints, pointsinarray;
+
+ x->x_arrayname = s;
+ if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
+ {
+ if (*s->s_name)
+ pd_error(x, "tabosc4c~: %s: no such array", x->x_arrayname->s_name);
+ x->x_vec = 0;
+ }
+ else if (!garray_getfloatwords(a, &pointsinarray, &x->x_vec))
+ {
+ pd_error(x, "%s: bad template for tabosc4c~", x->x_arrayname->s_name);
+ x->x_vec = 0;
+ }
+ else if ((npoints = pointsinarray - 3) != (1 << ilog2(pointsinarray - 3)))
+ {
+ pd_error(x, "%s: number of points (%d) not a power of 2 plus three",
+ x->x_arrayname->s_name, pointsinarray);
+ x->x_vec = 0;
+ garray_usedindsp(a);
+ }
+ else
+ {
+ x->x_fnpoints = npoints;
+ x->x_finvnpoints = 1./npoints;
+ garray_usedindsp(a);
+ }
+}
+
+static void tabosc4c_tilde_ft1(t_tabosc4c_tilde *x, t_float f)
+{
+ x->x_phase = f;
+}
+
+static void tabosc4c_tilde_dsp(t_tabosc4c_tilde *x, t_signal **sp)
+{
+ x->x_conv = 1. / sp[0]->s_sr;
+ tabosc4c_tilde_set(x, x->x_arrayname);
+
+ dsp_add(tabosc4c_tilde_perform, 4, x,
+ sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
+}
+
+void tabosc4c_tilde_setup(void)
+{
+ tabosc4c_tilde_class = class_new(gensym("tabosc4c~"),
+ (t_newmethod)tabosc4c_tilde_new, 0,
+ sizeof(t_tabosc4c_tilde), 0, A_DEFSYM, 0);
+ CLASS_MAINSIGNALIN(tabosc4c_tilde_class, t_tabosc4c_tilde, x_f);
+ class_addmethod(tabosc4c_tilde_class, (t_method)tabosc4c_tilde_dsp,
+ gensym("dsp"), 0);
+ class_addmethod(tabosc4c_tilde_class, (t_method)tabosc4c_tilde_set,
+ gensym("set"), A_SYMBOL, 0);
+ class_addmethod(tabosc4c_tilde_class, (t_method)tabosc4c_tilde_ft1,
+ gensym("ft1"), A_FLOAT, 0);
+}
+
diff --git a/tab/tabread4c~-help.pd b/tab/tabread4c~-help.pd
new file mode 100644
index 0000000..5400904
--- /dev/null
+++ b/tab/tabread4c~-help.pd
@@ -0,0 +1,43 @@
+#N canvas 106 72 743 605 10;
+#N canvas 0 0 450 300 (subpatch) 0;
+#X array array99 10 float 0;
+#X coords 0 1 9 -1 250 200 1;
+#X restore 461 80 graph;
+#X obj 69 195 line~;
+#X obj 36 139 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
+-1;
+#X msg 69 172 0 \, 10 1000;
+#X obj 70 219 tabread4c~ array99;
+#X obj 36 32 loadbang;
+#X obj 296 195 line~;
+#X msg 296 172 0 \, 10 1000;
+#X obj 297 219 tabread4~ array99;
+#X obj 298 241 tabwrite~ test_miller;
+#X obj 70 241 tabwrite~ test_cubic;
+#X obj 36 55 t b b;
+#N canvas 0 0 450 300 (subpatch) 0;
+#X array test_miller 44100 float 0;
+#X coords 0 1 44099 -1 250 200 1;
+#X restore 295 312 graph;
+#N canvas 0 0 450 300 (subpatch) 0;
+#X array test_cubic 44100 float 0;
+#X coords 0 1 44099 -1 250 200 1;
+#X restore 34 312 graph;
+#X text 49 530 tabread4c~ is a drop in remplacement for tabrad4~ \,
+but offer a true 4 points cubic interpolation. So \, quality is better
+than the standart interpolation;
+#X msg 63 77 \; array99 resize 10 \; array99 0 -0.5 -0.5 -0.5 0.5 0.5
+0.5 -0.5 0 0 \; pd dsp 1 \;;
+#X connect 1 0 4 0;
+#X connect 2 0 3 0;
+#X connect 2 0 7 0;
+#X connect 2 0 9 0;
+#X connect 2 0 10 0;
+#X connect 3 0 1 0;
+#X connect 4 0 10 0;
+#X connect 5 0 11 0;
+#X connect 6 0 8 0;
+#X connect 7 0 6 0;
+#X connect 8 0 9 0;
+#X connect 11 0 2 0;
+#X connect 11 1 15 0;
diff --git a/tab/tabread4c~.c b/tab/tabread4c~.c
new file mode 100644
index 0000000..00da57a
--- /dev/null
+++ b/tab/tabread4c~.c
@@ -0,0 +1,137 @@
+// GPL
+// most of this code comes from pd. just the interpolation shematic is diferent.
+
+#include "m_pd.h"
+
+/******************** tabread4c~ ***********************/
+
+static t_class *tabread4c_tilde_class;
+
+typedef struct _tabread4c_tilde
+{
+ t_object x_obj;
+ int x_npoints;
+ t_word *x_vec;
+ t_symbol *x_arrayname;
+ t_float x_f;
+} t_tabread4c_tilde;
+
+static void *tabread4c_tilde_new(t_symbol *s)
+{
+ t_tabread4c_tilde *x = (t_tabread4c_tilde *)pd_new(tabread4c_tilde_class);
+ x->x_arrayname = s;
+ x->x_vec = 0;
+ outlet_new(&x->x_obj, gensym("signal"));
+ x->x_f = 0;
+ return (x);
+}
+
+static t_int *tabread4c_tilde_perform(t_int *w)
+{
+ t_tabread4c_tilde *x = (t_tabread4c_tilde *)(w[1]);
+ t_sample *in = (t_sample *)(w[2]);
+ t_sample *out = (t_sample *)(w[3]);
+ int n = (int)(w[4]);
+ int maxindex;
+ t_word *buf = x->x_vec, *wp;
+ int i;
+ double a0,a1,a2; // CH
+
+ maxindex = x->x_npoints - 3;
+
+ if (!buf) goto zero;
+
+#if 0 /* test for spam -- I'm not ready to deal with this */
+ for (i = 0, xmax = 0, xmin = maxindex, fp = in1; i < n; i++, fp++)
+ {
+ t_sample f = *in1;
+ if (f < xmin) xmin = f;
+ else if (f > xmax) xmax = f;
+ }
+ if (xmax < xmin + x->c_maxextent) xmax = xmin + x->c_maxextent;
+ for (i = 0, splitlo = xmin+ x->c_maxextent, splithi = xmax - x->c_maxextent,
+ fp = in1; i < n; i++, fp++)
+ {
+ t_sample f = *in1;
+ if (f > splitlo && f < splithi) goto zero;
+ }
+#endif
+
+ for (i = 0; i < n; i++)
+ {
+ t_sample findex = *in++;
+ int index = findex;
+ t_sample frac, a, b, c, d, cminusb;
+ static int count;
+ if (index < 1)
+ index = 1, frac = 0;
+ else if (index > maxindex)
+ index = maxindex, frac = 1;
+ else frac = findex - index;
+ wp = buf + index;
+ a = wp[-1].w_float;
+ b = wp[0].w_float;
+ c = wp[1].w_float;
+ d = wp[2].w_float;
+ /* if (!i && !(count++ & 1023))
+ post("fp = %lx, shit = %lx, b = %f", fp, buf->b_shit, b); */
+// cminusb = c-b;
+// *out++ = b + frac * (
+// cminusb - 0.1666667f * (1.-frac) * (
+// (d - a - 3.0f * cminusb) * frac + (d + 2.0f*a - 3.0f*b)
+// CH
+ a0 = d - c - a + b;
+ a1 = a - b - a0;
+ a2 = c - a;
+ *out++ = ((a0*frac+a1)*frac+a2)*frac+b;
+ }
+ return (w+5);
+ zero:
+ while (n--) *out++ = 0;
+
+ return (w+5);
+}
+
+void tabread4c_tilde_set(t_tabread4c_tilde *x, t_symbol *s)
+{
+ t_garray *a;
+
+ x->x_arrayname = s;
+ if (!(a = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
+ {
+ if (*s->s_name)
+ pd_error(x, "tabread4c~: %s: no such array", x->x_arrayname->s_name);
+ x->x_vec = 0;
+ }
+ else if (!garray_getfloatwords(a, &x->x_npoints, &x->x_vec))
+ {
+ pd_error(x, "%s: bad template for tabread4c~", x->x_arrayname->s_name);
+ x->x_vec = 0;
+ }
+ else garray_usedindsp(a);
+}
+
+static void tabread4c_tilde_dsp(t_tabread4c_tilde *x, t_signal **sp)
+{
+ tabread4c_tilde_set(x, x->x_arrayname);
+
+ dsp_add(tabread4c_tilde_perform, 4, x,
+ sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
+
+}
+
+static void tabread4c_tilde_free(t_tabread4c_tilde *x)
+{
+}
+
+void tabread4c_tilde_setup(void)
+{
+ tabread4c_tilde_class = class_new(gensym("tabread4c~"),
+ (t_newmethod)tabread4c_tilde_new, (t_method)tabread4c_tilde_free,
+ sizeof(t_tabread4c_tilde), 0, A_DEFSYM, 0);
+ CLASS_MAINSIGNALIN(tabread4c_tilde_class, t_tabread4c_tilde, x_f);
+ class_addmethod(tabread4c_tilde_class, (t_method)tabread4c_tilde_dsp,
+ gensym("dsp"), 0);
+ class_addmethod(tabread4c_tilde_class, (t_method)tabread4c_tilde_set,
+ gensym("set"), A_SYMBOL, 0);
+}