aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Kelly <edkelly@users.sourceforge.net>2005-12-02 11:36:13 +0000
committerEd Kelly <edkelly@users.sourceforge.net>2005-12-02 11:36:13 +0000
commit086acfd07f8e995727662572243bbb6a4cdeab03 (patch)
tree7136884a3edb3f22a9bbf4faf8a9d835ebb9a3b7
parent505970825ef49caa59818dcc603faabb54802f8a (diff)
This commit was generated by cvs2svn to compensate for changes in r4111,
which included commits to RCS files with non-trunk default branches. svn path=/trunk/externals/ekext/; revision=4112
-rw-r--r--zeroxpos~/help-zeroxpos~.pd45
-rw-r--r--zeroxpos~/makefile106
-rw-r--r--zeroxpos~/zeroxpos~.c101
3 files changed, 252 insertions, 0 deletions
diff --git a/zeroxpos~/help-zeroxpos~.pd b/zeroxpos~/help-zeroxpos~.pd
new file mode 100644
index 0000000..31b0048
--- /dev/null
+++ b/zeroxpos~/help-zeroxpos~.pd
@@ -0,0 +1,45 @@
+#N canvas 0 22 454 304 10;
+#X msg 182 52 1;
+#X msg 192 68 2;
+#X msg 224 90 5;
+#X obj 33 76 osc~ 100;
+#X floatatom 183 112 5 0 0 0 - - -;
+#X text 187 37 find...;
+#X text 207 52 1st zero crossing in frame;
+#X text 219 68 2nd zero crossing in frame;
+#X text 249 90 5th zero crossing in frame;
+#X text 240 105 ...etc;
+#X msg 76 31 bang;
+#X text 74 15 do it!;
+#X floatatom 57 160 5 0 0 3 sample - -;
+#X floatatom 183 159 5 0 0 3 direction - -;
+#X msg 329 156 \; pd dsp 1;
+#X obj 329 140 loadbang;
+#X text 29 205 If you ask to find a number of zero-crossings which
+will return a result past the end of the frame \, it will carry the
+number into the next frame and find it there!;
+#X obj 263 36 loadbang;
+#N canvas 0 22 213 256 it's_in_here! 0;
+#X obj 35 125 zeroxpos~;
+#X floatatom 94 104 5 0 0 0 - - -;
+#X obj 94 82 inlet;
+#X obj 35 49 inlet~;
+#X obj 39 193 block~ 1024;
+#X obj 36 154 outlet;
+#X obj 93 154 outlet;
+#X connect 0 0 5 0;
+#X connect 0 1 6 0;
+#X connect 1 0 0 1;
+#X connect 2 0 1 0;
+#X connect 3 0 0 0;
+#X restore 77 130 pd it's_in_here!;
+#X connect 0 0 4 0;
+#X connect 1 0 4 0;
+#X connect 2 0 4 0;
+#X connect 3 0 18 0;
+#X connect 4 0 18 1;
+#X connect 10 0 18 0;
+#X connect 15 0 14 0;
+#X connect 17 0 0 0;
+#X connect 18 0 12 0;
+#X connect 18 1 13 0;
diff --git a/zeroxpos~/makefile b/zeroxpos~/makefile
new file mode 100644
index 0000000..3003da3
--- /dev/null
+++ b/zeroxpos~/makefile
@@ -0,0 +1,106 @@
+current:
+ echo make pd_linux, pd_nt, pd_irix5, pd_irix6 or pd_darwin
+
+clean: ; rm -f *.pd_* *.o
+
+# ----------------------- NT -----------------------
+
+pd_nt: zeroxpos~.dll
+
+INSTALL_PREFIX = "C:\pd\extra"
+EXT = dll
+.SUFFIXES: .obj .dll
+
+PDNTCFLAGS = /W3 /WX /DNT /DPD /nologo
+VC="D:\Program Files\Microsoft Visual Studio\Vc98"
+
+PDNTINCLUDE = /I. /I\tcl\include /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:$*_setup $*.obj $(PDNTLIB)
+
+# ----------------------- IRIX 5.x -----------------------
+
+pd_irix5: zeroxpos~.pd_irix5
+
+INSTALL_PREFIX = /usr/local
+EXT = pd_irix5
+.SUFFIXES: .pd_irix5
+
+SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
+
+SGIINCLUDE = -I/usr/local/include
+
+.c.pd_irix5:
+ cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -elf -shared -rdata_shared -o $*.pd_irix5 $*.o
+ rm $*.o
+
+# ----------------------- IRIX 5.x -----------------------
+
+pd_irix6: zeroxpos~.pd_irix6
+
+INSTALL_PREFIX = /usr/local
+EXT = pd_irix6
+.SUFFIXES: .pd_irix6
+
+SGICFLAGS5 = -o32 -DPD -DUNIX -DIRIX -O2
+
+SGIINCLUDE = -I/usr/local/include
+
+.c.pd_irix6:
+ cc $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
+ ld -elf -shared -rdata_shared -o $*.pd_irix6 $*.o
+ rm $*.o
+
+# ----------------------- LINUX i386 -----------------------
+
+pd_linux: zeroxpos~.pd_linux
+
+INSTALL_PREFIX = /usr
+EXT = 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/usr/local/include
+
+.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 OSX -----------------------
+
+pd_darwin: zeroxpos~.pd_darwin
+
+INSTALL_PREFIX = /usr/local
+EXT = 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
+
+# ----------------------------------------------
+
+install::
+ install -d $(INSTALL_PREFIX)/lib/pd/extra
+# install -m 644 *.$(EXT) $(INSTALL_PREFIX)/lib/pd/externs
+ -install -m 644 zeroxpos~.$(EXT) $(INSTALL_PREFIX)/lib/pd/extra
+ install -m 644 *.pd $(INSTALL_PREFIX)/lib/pd/doc/5.reference
+
diff --git a/zeroxpos~/zeroxpos~.c b/zeroxpos~/zeroxpos~.c
new file mode 100644
index 0000000..1c43608
--- /dev/null
+++ b/zeroxpos~/zeroxpos~.c
@@ -0,0 +1,101 @@
+#include "m_pd.h"
+
+static t_class *zeroxpos_tilde_class;
+
+typedef struct _zeroxpos_control
+{
+ t_float *c_input;
+ t_int final_pol;
+} t_zeroxpos_control;
+
+typedef struct _zeroxpos_tilde
+{
+ t_object x_obj;
+ t_zeroxpos_control x_ctl;
+ t_float f_num, f_dummy;
+ t_int i_bang, i_pol, i_count, i_ndx;
+ t_outlet *f_pos, *f_pol;
+} t_zeroxpos_tilde;
+
+t_int *zeroxpos_tilde_perform(t_int *w)
+{
+ t_zeroxpos_tilde *x = (t_zeroxpos_tilde *)(w[1]);
+ t_zeroxpos_control *ctl = (t_zeroxpos_control *)(w[2]);
+ int n = (int)(w[3]);
+ t_float *in = ctl->c_input;
+ int number = (int)x->f_num;
+ int count = x->i_count;
+ int polarity = 1;
+ int i = 0;
+ x->i_pol = 0;
+ x->i_ndx = -1;
+ int prev = ctl->final_pol;
+
+ for(i=0;i<n;i++)
+ {
+ polarity = in[i] >= 0 ? 1 : -1;
+ if((polarity < prev || polarity > prev) && count == number && x->i_bang == 1)
+ {
+ x->i_ndx = i;
+ x->i_pol = polarity;
+ count++;
+ x->i_bang = 0;
+ }
+ if((polarity < prev || polarity > prev) && count < number)
+ {
+ count++;
+ }
+ if(i==n-1)
+ {
+ ctl->final_pol = polarity;
+ x->i_count = count;
+ }
+ prev = polarity;
+ }
+ outlet_float(x->f_pol, (float)x->i_pol);
+ outlet_float(x->f_pos, (float)x->i_ndx);
+ return(w+4);
+}
+
+void zeroxpos_tilde_bang(t_zeroxpos_tilde *x)
+{
+ x->i_bang = 1;
+ x->i_count = 0;
+}
+
+void *zeroxpos_tilde_dsp(t_zeroxpos_tilde *x, t_signal **sp)
+{
+ x->x_ctl.c_input = sp[0]->s_vec;
+ dsp_add(zeroxpos_tilde_perform, 3, x, &x->x_ctl, sp[0]->s_n);
+ return (void *)x;
+}
+
+void *zeroxpos_tilde_new(t_floatarg f)
+{
+ t_zeroxpos_tilde *x = (t_zeroxpos_tilde *)pd_new(zeroxpos_tilde_class);
+ x->f_num = f > 0 ? f : 1;
+ x->x_ctl.final_pol = 1;
+ x->i_count = 0;
+ floatinlet_new (&x->x_obj, &x->f_num);
+ x->f_pos = outlet_new(&x->x_obj, gensym("float"));
+ x->f_pol = outlet_new(&x->x_obj, gensym("float"));
+ return (void *)x;
+}
+
+void zeroxpos_tilde_setup(void)
+{
+ zeroxpos_tilde_class = class_new(gensym("zeroxpos~"),
+ (t_newmethod)zeroxpos_tilde_new,
+ 0, sizeof(t_zeroxpos_tilde),
+ CLASS_DEFAULT, A_DEFFLOAT, 0);
+
+ post("|¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬zeroxpos~``````````````````````|");
+ post("|find 1st, 2nd or 3rd etc zero crossing point in frame|");
+ post("|````edward¬¬¬¬¬¬¬¬¬¬¬¬kelly``````````````````2005¬¬¬¬|");
+
+ class_sethelpsymbol(zeroxpos_tilde_class, gensym("help-zeroxpos~"));
+ class_addbang(zeroxpos_tilde_class, zeroxpos_tilde_bang);
+ class_addmethod(zeroxpos_tilde_class, (t_method)zeroxpos_tilde_dsp, gensym("dsp"), 0);
+ CLASS_MAINSIGNALIN(zeroxpos_tilde_class, t_zeroxpos_tilde, f_dummy);
+}
+