diff options
Diffstat (limited to 'pd/extra/lrshift~')
-rw-r--r-- | pd/extra/lrshift~/lrshift~.c | 74 | ||||
-rw-r--r-- | pd/extra/lrshift~/makefile | 97 |
2 files changed, 171 insertions, 0 deletions
diff --git a/pd/extra/lrshift~/lrshift~.c b/pd/extra/lrshift~/lrshift~.c new file mode 100644 index 00000000..285696e2 --- /dev/null +++ b/pd/extra/lrshift~/lrshift~.c @@ -0,0 +1,74 @@ +#include "m_pd.h" + +/* ------------------------ lrshift~ ----------------------------- */ + +static t_class *lrshift_tilde_class; + +typedef struct _lrshift_tilde +{ + t_object x_obj; + int x_n; +} t_lrshift_tilde; + +static t_int *leftshift_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out= (t_float *)(w[2]); + int n = (int)(w[3]); + int shift = (int)(w[4]); + in += shift; + n -= shift; + while (n--) + *out++ = *in++; + while (shift--) + *out++ = 0; + return (w+5); +} + +static t_int *rightshift_perform(t_int *w) +{ + t_float *in = (t_float *)(w[1]); + t_float *out= (t_float *)(w[2]); + int n = (int)(w[3]); + int shift = (int)(w[4]); + n -= shift; + in -= shift; + while (n--) + *--out = *--in; + while (shift--) + *--out = 0; + return (w+5); +} + +static void lrshift_tilde_dsp(t_lrshift_tilde *x, t_signal **sp) +{ + int n = sp[0]->s_n; + int shift = x->x_n; + if (shift > n) + shift = n; + if (shift < -n) + shift = -n; + if (shift < 0) + dsp_add(rightshift_perform, 4, + sp[0]->s_vec + n, sp[1]->s_vec + n, n, -shift); + else dsp_add(leftshift_perform, 4, + sp[0]->s_vec, sp[1]->s_vec, n, shift); +} + +static void *lrshift_tilde_new(t_floatarg f) +{ + t_lrshift_tilde *x = (t_lrshift_tilde *)pd_new(lrshift_tilde_class); + x->x_n = f; + outlet_new(&x->x_obj, gensym("signal")); + return (x); +} + +void lrshift_tilde_setup(void) +{ + lrshift_tilde_class = class_new(gensym("lrshift~"), + (t_newmethod)lrshift_tilde_new, 0, sizeof(t_lrshift_tilde), 0, + A_DEFFLOAT, 0); + class_addmethod(lrshift_tilde_class, nullfn, gensym("signal"), 0); + class_addmethod(lrshift_tilde_class, (t_method)lrshift_tilde_dsp, + gensym("dsp"), 0); +} diff --git a/pd/extra/lrshift~/makefile b/pd/extra/lrshift~/makefile new file mode 100644 index 00000000..99c1f83c --- /dev/null +++ b/pd/extra/lrshift~/makefile @@ -0,0 +1,97 @@ +NAME=lrshift~ +CSYM=lrshift_tilde + +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\tcl\include /I\ftp\pd\src /I$(VC)\include + +PDNTLDIR = $(VC)\lib +PDNTLIB = $(PDNTLDIR)\libc.lib \ + $(PDNTLDIR)\oldnames.lib \ + $(PDNTLDIR)\kernel32.lib \ + \ftp\pd\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 -f $*.o ../$*.pd_linux + ln -s $*.pd_linux .. + +# ----------------------- 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 = -fPIC -DPD -O2 -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 ../$*.pd_linux + ln -s $*/$*.pd_linux .. + +# ----------------------- 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 ../$*.pd_darwin + ln -s $*/$*.pd_darwin .. + +# ---------------------------------------------------------- + +clean: + rm -f *.o *.pd_* so_locations |