diff options
-rw-r--r-- | cupd/cupd.c | 58 | ||||
-rw-r--r-- | cupd/help-cupd.pd | 19 | ||||
-rw-r--r-- | cupd/makefile | 105 |
3 files changed, 182 insertions, 0 deletions
diff --git a/cupd/cupd.c b/cupd/cupd.c new file mode 100644 index 0000000..c1f9e3f --- /dev/null +++ b/cupd/cupd.c @@ -0,0 +1,58 @@ +#include "m_pd.h" + +t_class *cupd_class; + +typedef struct _cupd +{ + t_object x_obj; + t_int f_count; + t_float f_dir, f_prevdir, firstbang, floatset; + t_outlet *count; +} t_cupd; + +void cupd_float(t_cupd *y, t_floatarg f) +{ + y->f_count = f; + y->floatset = 1; +} + +void cupd_bang(t_cupd *y) +{ + int flag = y->f_dir != y->f_prevdir ? 1 : 0; + if (flag==1&&y->firstbang==0&&y->floatset==0) + { + y->f_count += y->f_dir == 0 ? 2 : -2; + outlet_float(y->count, y->f_count); + y->f_count += y->f_dir == 0 ? 1 : -1; + } + else + { + outlet_float(y->count, y->f_count); + y->f_count += y->f_dir == 0 ? 1 : -1; + y->firstbang = y->floatset = 0; + } + y->f_prevdir = y->f_dir; +} + +void *cupd_new(t_floatarg f) +{ + t_cupd *y = (t_cupd *)pd_new(cupd_class); + y->f_dir = f; + y->f_count = 0; + y->firstbang = 1; + floatinlet_new(&y->x_obj, &y->f_dir); + y->count = outlet_new(&y->x_obj, gensym("float")); + return(void *)y; +} + +void cupd_setup(void) +{ + cupd_class = class_new(gensym("cupd"), + (t_newmethod)cupd_new, + 0, sizeof(t_cupd), + 0, A_DEFFLOAT, 0); + post("cupd counts up ^_^ and down _^_"); + class_sethelpsymbol(cupd_class, gensym("help-cupd")); + class_addbang(cupd_class, cupd_bang); + class_addfloat(cupd_class, cupd_float); +} diff --git a/cupd/help-cupd.pd b/cupd/help-cupd.pd new file mode 100644 index 0000000..2bd8d67 --- /dev/null +++ b/cupd/help-cupd.pd @@ -0,0 +1,19 @@ +#N canvas 0 0 450 300 10; +#X obj 87 161 cupd; +#X obj 87 94 metro 100; +#X obj 87 56 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1 +; +#X obj 110 134 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 1 +1; +#X floatatom 87 201 5 0 0 0 - - -; +#X msg 197 102 160; +#X text 109 59 bang counts; +#X text 70 14 cupd counts up ^_^ and down _^_; +#X text 223 101 float sets next; +#X text 132 135 != 0 counts down \, 0 counts up; +#X text 69 235 aaaaah \, simplicity!; +#X connect 0 0 4 0; +#X connect 1 0 0 0; +#X connect 2 0 1 0; +#X connect 3 0 0 1; +#X connect 5 0 0 0; diff --git a/cupd/makefile b/cupd/makefile new file mode 100644 index 0000000..a8f6db9 --- /dev/null +++ b/cupd/makefile @@ -0,0 +1,105 @@ +current: + echo make pd_linux, pd_nt, pd_irix5, pd_irix6 or pd_darwin, then make install + +clean: ; rm -f *.pd_* *.o + +# ----------------------- NT ----------------------- + +pd_nt: cupd.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: cupd.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: cupd.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: cupd.pd_linux + +INSTALL_PREFIX=/usr/local +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: cupd.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 cupd.$(EXT) $(INSTALL_PREFIX)/lib/pd/extra + install -m 644 *.pd $(INSTALL_PREFIX)/lib/pd/doc/5.reference |