aboutsummaryrefslogtreecommitdiff
path: root/pd/doc/6.externs
diff options
context:
space:
mode:
Diffstat (limited to 'pd/doc/6.externs')
-rw-r--r--pd/doc/6.externs/0.README.txt9
-rw-r--r--pd/doc/6.externs/dspobj~.c49
-rw-r--r--pd/doc/6.externs/foo1.c37
-rw-r--r--pd/doc/6.externs/foo2.c49
-rw-r--r--pd/doc/6.externs/makefile75
-rw-r--r--pd/doc/6.externs/test-dspobj~.pd11
-rw-r--r--pd/doc/6.externs/test-foo1.pd6
-rw-r--r--pd/doc/6.externs/test-foo2.pd8
8 files changed, 244 insertions, 0 deletions
diff --git a/pd/doc/6.externs/0.README.txt b/pd/doc/6.externs/0.README.txt
new file mode 100644
index 00000000..3b130116
--- /dev/null
+++ b/pd/doc/6.externs/0.README.txt
@@ -0,0 +1,9 @@
+EXTERNAL OBJECTS in Pd.
+
+Here are the sources for three simple external objects in Pd.
+To compile, type "make pd_linux", "nmake pd_nt", "make pd_irix5" or "make
+pd_irix6".
+
+The objects "foo1" and "foo2" are intended as very simple control objects, and
+"dspobj" is a tilde object.
+
diff --git a/pd/doc/6.externs/dspobj~.c b/pd/doc/6.externs/dspobj~.c
new file mode 100644
index 00000000..a8841f21
--- /dev/null
+++ b/pd/doc/6.externs/dspobj~.c
@@ -0,0 +1,49 @@
+#include "m_pd.h"
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/* ------------------------ dspobj~ ----------------------------- */
+
+/* tilde object to take absolute value. */
+
+static t_class *dspobj_class;
+
+typedef struct _dspobj
+{
+ t_object x_obj;
+} t_dspobj;
+
+static t_int *dspobj_perform(t_int *w)
+{
+ t_float *in = (t_float *)(w[1]);
+ t_float *out = (t_float *)(w[2]);
+ int n = (int)(w[3]);
+ while (n--)
+ {
+ float f = *(in++);
+ *out++ = (f > 0 ? f : -f);
+ }
+ return (w+4);
+}
+
+static void dspobj_dsp(t_dspobj *x, t_signal **sp)
+{
+ dsp_add(dspobj_perform, 3, sp[0]->s_vec, sp[1]->s_vec, sp[0]->s_n);
+}
+
+static void *dspobj_new(void)
+{
+ t_dspobj *x = (t_dspobj *)pd_new(dspobj_class);
+ outlet_new(&x->x_obj, gensym("signal"));
+ return (x);
+}
+
+void dspobj_tilde_setup(void)
+{
+ dspobj_class = class_new(gensym("dspobj~"), (t_newmethod)dspobj_new, 0,
+ sizeof(t_dspobj), 0, A_DEFFLOAT, 0);
+ class_addmethod(dspobj_class, nullfn, gensym("signal"), 0);
+ class_addmethod(dspobj_class, (t_method)dspobj_dsp, gensym("dsp"), 0);
+}
diff --git a/pd/doc/6.externs/foo1.c b/pd/doc/6.externs/foo1.c
new file mode 100644
index 00000000..48d0d344
--- /dev/null
+++ b/pd/doc/6.externs/foo1.c
@@ -0,0 +1,37 @@
+/* code for foo1 pd class */
+
+#include "m_pd.h"
+
+typedef struct foo1
+{
+ t_object t_ob;
+} t_foo1;
+
+void foo1_float(t_foo1 *x, t_floatarg f)
+{
+ post("foo1: %f", f);
+}
+
+void foo1_rats(t_foo1 *x)
+{
+ post("foo1: rats");
+}
+
+t_class *foo1_class;
+
+void *foo1_new(void)
+{
+ t_foo1 *x = (t_foo1 *)pd_new(foo1_class);
+ post("foo1_new");
+ return (void *)x;
+}
+
+void foo1_setup(void)
+{
+ post("foo1_setup");
+ foo1_class = class_new(gensym("foo1"), (t_newmethod)foo1_new, 0,
+ sizeof(t_foo1), 0, 0);
+ class_addmethod(foo1_class, (t_method)foo1_rats, gensym("rats"), 0);
+ class_addfloat(foo1_class, foo1_float);
+}
+
diff --git a/pd/doc/6.externs/foo2.c b/pd/doc/6.externs/foo2.c
new file mode 100644
index 00000000..e68ed996
--- /dev/null
+++ b/pd/doc/6.externs/foo2.c
@@ -0,0 +1,49 @@
+/* code for foo2 pd class */
+
+#include "m_pd.h"
+
+typedef struct foo2
+{
+ t_object t_ob;
+} t_foo2;
+
+void foo2_float(t_foo2 *x, t_floatarg f)
+{
+ post("foo2: %f", f);
+}
+
+void foo2_rats(t_foo2 *x)
+{
+ post("foo2: rats");
+}
+
+void foo2_ft1(t_foo2 *x, t_floatarg g)
+{
+ post("ft1: %f", g);
+}
+
+void foo2_free(void)
+{
+ post("foo2_free");
+}
+
+t_class *foo2_class;
+
+void *foo2_new(void)
+{
+ t_foo2 *x = (t_foo2 *)pd_new(foo2_class);
+ inlet_new(&x->t_ob, &x->t_ob.ob_pd, gensym("float"), gensym("ft1"));
+ post("foo2_new");
+ return (void *)x;
+}
+
+void foo2_setup(void)
+{
+ post("foo2_setup");
+ foo2_class = class_new(gensym("foo2"), (t_newmethod)foo2_new,
+ (t_method)foo2_free, sizeof(t_foo2), 0, 0);
+ class_addmethod(foo2_class, (t_method)foo2_rats, gensym("rats"), 0);
+ class_addmethod(foo2_class, (t_method)foo2_ft1, gensym("ft1"), A_FLOAT, 0);
+ class_addfloat(foo2_class, foo2_float);
+}
+
diff --git a/pd/doc/6.externs/makefile b/pd/doc/6.externs/makefile
new file mode 100644
index 00000000..f807ba0b
--- /dev/null
+++ b/pd/doc/6.externs/makefile
@@ -0,0 +1,75 @@
+current:
+ echo make pd_linux, pd_nt, pd_irix5, or pd_irix6
+
+clean: ; rm -f *.pd_linux *.o
+
+# ----------------------- NT -----------------------
+
+pd_nt: foo1.dll foo2.dll dspobj~.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:$*_setup $*.obj $(PDNTLIB)
+
+# ----------------------- IRIX 5.x -----------------------
+
+pd_irix5: foo1.pd_irix5 foo2.pd_irix5 dspobj~.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: foo1.pd_irix6 foo2.pd_irix6 dspobj~.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: foo1.pd_linux foo2.pd_linux dspobj~.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../../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
+
diff --git a/pd/doc/6.externs/test-dspobj~.pd b/pd/doc/6.externs/test-dspobj~.pd
new file mode 100644
index 00000000..4d1030b3
--- /dev/null
+++ b/pd/doc/6.externs/test-dspobj~.pd
@@ -0,0 +1,11 @@
+#N canvas 0 0 335 239 10;
+#X obj 90 124 dspobj~;
+#X obj 90 96 sig~ 0;
+#X msg 106 149 bang;
+#X obj 90 177 print~;
+#X floatatom 89 71;
+#X msg 202 37 \; pd dsp 1;
+#X connect 0 0 3 0;
+#X connect 1 0 0 0;
+#X connect 2 0 3 0;
+#X connect 4 0 1 0;
diff --git a/pd/doc/6.externs/test-foo1.pd b/pd/doc/6.externs/test-foo1.pd
new file mode 100644
index 00000000..280be821
--- /dev/null
+++ b/pd/doc/6.externs/test-foo1.pd
@@ -0,0 +1,6 @@
+#N canvas 68 38 269 168 10;
+#X obj 68 90 foo1;
+#X msg 68 52 5;
+#X msg 100 52 rats;
+#X connect 1 0 0 0;
+#X connect 2 0 0 0;
diff --git a/pd/doc/6.externs/test-foo2.pd b/pd/doc/6.externs/test-foo2.pd
new file mode 100644
index 00000000..be62e140
--- /dev/null
+++ b/pd/doc/6.externs/test-foo2.pd
@@ -0,0 +1,8 @@
+#N canvas 171 53 269 164 10;
+#X msg 100 52 rats;
+#X obj 68 90 foo2;
+#X msg 155 55 7;
+#X msg 68 52 4;
+#X connect 0 0 1 0;
+#X connect 2 0 1 1;
+#X connect 3 0 1 0;