aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Blechmann <timblech@users.sourceforge.net>2005-06-24 19:39:18 +0000
committerIOhannes m zmölnig <zmoelnig@iem.at>2015-10-14 15:11:59 +0200
commit716c84be13ba425edf49a533ef5ffdfa5f6f4aaf (patch)
tree8b86a864a11bf50aebae7c4a6d3d882ee69ba061
parent49d037de7109de167d81dc1fb3cea7c781c20c99 (diff)
importing source
svn path=/trunk/externals/tb/; revision=3248
-rw-r--r--block_delay~/block_delay~.c99
-rw-r--r--block_delay~/makefile94
2 files changed, 193 insertions, 0 deletions
diff --git a/block_delay~/block_delay~.c b/block_delay~/block_delay~.c
new file mode 100644
index 0000000..f5cfa4c
--- /dev/null
+++ b/block_delay~/block_delay~.c
@@ -0,0 +1,99 @@
+/* this external is based on nop~ which was part of zexy-1.x, see the copyright notice below:
+
+ * ZEXY is published under the GNU GeneralPublicLicense, that must be shipped with ZEXY.
+ * if you are using Debian GNU/linux, the GNU-GPL can be found under /usr/share/common-licenses/GPL
+ * if you still haven't found a copy of the GNU-GPL, have a look at http://www.gnu.org
+ *
+ * "pure data" has it's own license, that comes shipped with "pure data".
+ *
+ * there are ABSOLUTELY NO WARRANTIES for anything
+
+ it does absolutely the same as z~ 64, but since it uses simd instructions, it's faster.
+*/
+
+
+
+/* ------------------------ block_delay~ ----------------------------- */
+/* this will pass trough the signal unchanged except for a delay of 1 block */
+
+#include "m_pd.h"
+
+static t_class *block_delay_tilde_class;
+
+typedef struct _block_delay
+{
+ t_object x_obj;
+ t_float *buf;
+ int n;
+ int toggle;
+} t_block_delay;
+
+
+static t_int *block_delay_tilde_perfsimd(t_int *w)
+{
+ t_float *in = (t_float *)w[1];
+ t_float *out = (t_float *)w[2];
+ t_block_delay *x = (t_block_delay *)w[3];
+ int n = x->n;
+ t_float *rp = x->buf + n * x->toggle, *wp = x->buf + n * (x->toggle ^= 1);
+
+ copyvec_simd(wp, in, n);
+ copyvec_simd(out, rp, n);
+
+ return (w+4);
+}
+
+static t_int *block_delay_tilde_perform(t_int *w)
+{
+ t_float *in = (t_float *)w[1];
+ t_float *out = (t_float *)w[2];
+ t_block_delay *x = (t_block_delay *)w[3];
+ int n = x->n;
+ t_float *rp = x->buf + n * x->toggle, *wp = x->buf + n * (x->toggle ^= 1);
+
+ while (n--) {
+ *wp++ = *in++;
+ *out++ = *rp++;
+ }
+
+ return (w+4);
+}
+
+static void block_delay_tilde_dsp(t_block_delay *x, t_signal **sp)
+{
+ if (x->n != sp[0]->s_n)
+ {
+ if (x->n)
+ freealignedbytes(x->buf, x->n * 2 * sizeof(t_float));
+ x->buf = (t_float *)getalignedbytes(sizeof(t_float) * 2 * (x->n = sp[0]->s_n));
+ }
+ if (simd_check2(sp[0]->s_n, sp[0]->s_vec, sp[1]->s_vec))
+ dsp_add(block_delay_tilde_perfsimd, 3, sp[0]->s_vec, sp[1]->s_vec, x);
+ else
+ dsp_add(block_delay_tilde_perform, 3, sp[0]->s_vec, sp[1]->s_vec, x);
+}
+
+static void block_delay_tilde_free(t_block_delay *x)
+{
+ if (x->buf)
+ freealignedbytes(x->buf, x->n * sizeof(t_float));
+}
+
+
+static void *block_delay_tilde_new(void)
+{
+ t_block_delay *x = (t_block_delay *)pd_new(block_delay_tilde_class);
+ outlet_new(&x->x_obj, gensym("signal"));
+ x->toggle = 0;
+ x->n = 0;
+
+ return (x);
+}
+
+void block_delay_tilde_setup(void)
+{
+ block_delay_tilde_class = class_new(gensym("block_delay~"), (t_newmethod)block_delay_tilde_new, (t_method)block_delay_tilde_free,
+ sizeof(t_block_delay), 0, A_DEFFLOAT, 0);
+ class_addmethod(block_delay_tilde_class, nullfn, gensym("signal"), 0);
+ class_addmethod(block_delay_tilde_class, (t_method)block_delay_tilde_dsp, gensym("dsp"), 0);
+}
diff --git a/block_delay~/makefile b/block_delay~/makefile
new file mode 100644
index 0000000..d2d0d21
--- /dev/null
+++ b/block_delay~/makefile
@@ -0,0 +1,94 @@
+NAME=block_delay~
+CSYM=block_delay~
+
+current: pd_linux
+
+# ----------------------- NT -----------------------
+
+pd_nt: $(NAME).dll
+
+.SUFFIXES: .dll
+
+PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo
+VC="C:\Program Files\Microsoft Visual Studio\Vc98"
+
+PDNTINCLUDE = /I. /I..\..\src /I$(VC)\include
+
+PDNTLDIR = $(VC)\lib
+PDNTLIB = $(PDNTLDIR)\libc.lib \
+ $(PDNTLDIR)\oldnames.lib \
+ $(PDNTLDIR)\kernel32.lib \
+ ..\..\bin\pd.lib
+
+.c.dll:
+ cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
+ link /dll /export:$(CSYM)_setup $*.obj $(PDNTLIB)
+
+# ----------------------- IRIX 5.x -----------------------
+
+pd_irix5: $(NAME).pd_irix5
+
+.SUFFIXES: .pd_irix5
+
+SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
+
+SGIINCLUDE = -I../../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: $(NAME).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 -n32 -IPA -shared -rdata_shared -o $*.pd_irix6 $*.o
+ rm $*.o
+
+# ----------------------- LINUX i386 -----------------------
+
+pd_linux: $(NAME).pd_linux
+
+.SUFFIXES: .pd_linux
+
+LINUXCFLAGS = -DPD -O3 -fPIC -funroll-loops -fomit-frame-pointer \
+ -Wall -W -Wshadow -Wstrict-prototypes -Werror \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+LINUXINCLUDE = -I../../../src
+
+LSTRIP = strip --strip-unneeded -R .note -R .comment
+
+.c.pd_linux:
+ cc $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
+ cc -Wl,-export_dynamic --shared -o $*.pd_linux $*.o -lm
+ $(LSTRIP) $*.pd_linux
+ rm -f $*.o
+
+# ----------------------- Mac OSX -----------------------
+
+pd_darwin: $(NAME).pd_darwin
+
+.SUFFIXES: .pd_darwin
+
+DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+.c.pd_darwin:
+ $(CC) $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
+ $(CC) -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o
+ rm -f $*.o
+
+# ----------------------------------------------------------
+
+clean:
+ rm -f *.o *.pd_* so_locations