aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile154
-rw-r--r--src/propertybang.c86
-rw-r--r--src/saveargs.c92
3 files changed, 332 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile
new file mode 100644
index 0000000..767d012
--- /dev/null
+++ b/src/Makefile
@@ -0,0 +1,154 @@
+# Makefile
+# (c) 2006 IOhannes m zmölnig
+
+# path to pd
+## change this according to your setup!
+PDROOT?=../../pd
+#PDROOT=/home/zmoelnig/src/pd/
+
+# here we find the sources of pd (and evtl. the pd.lib)
+PDSRCDIR?=$(PDROOT)/src
+PDLIBDIR?=$(PDROOT)/bin
+
+# this is the filename-extension
+# people have to specify it at the cmdline: eg "make pd_linux"
+EXTENSION=$(MAKECMDGOALS)
+
+# if no filename-extension is supplied by the user
+# try to guess one, based on what "uname" tells us
+UNAME := $(shell uname -s)
+ifeq ($(UNAME),Linux)
+ DEFAULTEXTENSION= pd_linux
+else
+ ifeq ($(UNAME),Darwin)
+ DEFAULTEXTENSION= pd_darwin
+ else
+ ifeq (MINGW,$(findstring MINGW,$(UNAME)))
+ DEFAULTEXTENSION= pd_nt
+ else
+ ifeq ($(UNAME),IRIX)
+ UNAMEV := $(shell uname -R)
+ ifeq (6.,$(findstring 6.,$(UNAMEV)))
+ DEFAULTEXTENSION= pd_irix6
+ else
+ DEFAULTEXTENSION= pd_irix5
+ endif
+ else
+ DEFAULTEXTENSION=help
+ endif
+ endif
+ endif
+endif
+
+# if no extension is given, call "make" again with a guessed extension
+auto:
+ make $(DEFAULTEXTENSION)
+
+# just a stupid fallback
+help:
+ @echo "choose one command: make pd_linux (linux), make pd_darwin (osX), make pd_irix5 (IRIX5), make pd_irix6 (IRIX6), make dll (MSVC), make pd_nt (MinWG)"
+
+# delete old build files
+clean:
+ -rm -f *.dll *.pd_* *.o *.obj *~
+
+# we want to compile all C-files we find in the current directory
+SOURCES=$(sort $(filter %.c, $(wildcard *.c)))
+# each C-files maps will become an external with the given filename-extension
+TARGETS=$(SOURCES:.c=.$(EXTENSION))
+
+
+# ----------------------- Linux -----------------------
+
+pd_linux: $(TARGETS)
+
+LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -fPIC \
+ -Wall -W -Wshadow -Wstrict-prototypes -Werror \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+LINUXLDFLAGS = -export_dynamic -shared -lc -lm
+
+LINUXINCLUDE = -I$(PDSRCDIR)
+
+%.pd_linux: %.c
+ $(CC) $(LINUXLDFLAGS) $(LINUXCFLAGS) $(LINUXINCLUDE) -o $*.pd_linux $*.c
+ strip --strip-unneeded $*.pd_linux
+
+
+
+# ----------------------- Mac OSX -----------------------
+
+pd_darwin: $(TARGETS)
+
+DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \
+ -Wno-unused -Wno-parentheses -Wno-switch
+
+DARWININCLUDE = -I$(PDSRCDIR)
+
+DARWINLDFLAGS = -bundle -undefined suppress -flat_namespace
+
+%.pd_darwin: %.c
+ $(CC) $(DARWINCFLAGS) $(DARWININCLUDE) $(DARWINLDFLAGS) -o $*.pd_darwin $*.c
+
+
+# ----------------------- IRIX 5.x -----------------------
+pd_irix5: $(TARGETS)
+
+SGICFLAGS5 = -o32 -DPD -DSGI -O2
+
+SGIINCLUDE = -I$(PDSRCDIR)
+
+SGILDFLAGS = -elf -shared -rdata_shared
+
+%.pd_irix5: %.c
+ $(CC) $(SGICFLAGS5) $(SGIINCLUDE) -o $*.o -c $*.c
+ $(LD) $(SGILDFLAGS) -o $*.pd_irix5 $*.o
+ rm $*.o
+
+
+# ----------------------- IRIX 6.x -----------------------
+pd_irix6: $(TARGETS)
+
+SGICFLAGS6 = -DPD -DSGI -n32 \
+ -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \
+ -Ofast=ip32
+
+%.pd_irix6: %.c
+ $(CC) $(SGICFLAGS6) $(SGIINCLUDE) -o $*.o -c $*.c
+ $(LD) $(SGILDFLAGS) -o $*.pd_irix6 $*.o
+ rm $*.o
+
+
+# ----------------------- NT -----------------------
+dll: $(TARGETS)
+
+PDNTCFLAGS = /W3 /WX /DPD /DNT /D__WIN32__ /DMSW /nologo
+
+VC="C:\Programme\Microsoft Visual Studio\Vc98"
+
+PDNTINCLUDE = /I. /I$(PDROOT)\tcl\include /I$(PDSRCDIR)\src /I$(VC)\include
+
+PDNTLDIR = $(VC)\lib
+
+PDNTLIB = $(PDNTLDIR)\libc.lib \
+ $(PDNTLDIR)\oldnames.lib \
+ $(PDNTLDIR)\kernel32.lib \
+ $(PDLIBDIR)\pd.lib
+
+%.dll: %.c
+ cl $(PDNTCFLAGS) $(PDNTINCLUDE) /c $*.c
+ link /dll /export:$*_setup $*.obj $(PDNTLIB)
+
+
+pd_nt: $(TARGETS)
+
+MINGWCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \
+ -Wall -W -Wshadow -Wstrict-prototypes -Werror \
+ -Wno-unused -Wno-parentheses -Wno-switch -mms-bitfields
+
+MINGWLDFLAGS = -export_dynamic -shared -lm -lkernel32 -lcoldname -lcrtdll -lpd -L$(PDLIBDIR)
+
+MINGWINCLUDE = -I$(PDSRCDIR)
+
+%.pd_nt: %.c
+ $(CC) $(MINGWLDFLAGS) $(MINGWCFLAGS) $(MINGWINCLUDE) -o $*.dll $*.c
diff --git a/src/propertybang.c b/src/propertybang.c
new file mode 100644
index 0000000..d994582
--- /dev/null
+++ b/src/propertybang.c
@@ -0,0 +1,86 @@
+
+/******************************************************
+ *
+ * propertybang - implementation file
+ *
+ * copyleft (c) IOhannes m zm-bölnig-A
+ *
+ * 2007:forum::f-bür::umläute:2007-A
+ *
+ * institute of electronic music and acoustics (iem)
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+
+/*
+ * this object provides a way to make an abstraction "property" aware
+ * usage:
+ * + put this object into an abstraction
+ * + put the abstraction in a patch
+ * + you can now right-click on the abstraction and select the "properties" menu
+ * + selecting the "properties" menu, will send a bang to the outlet of this object
+ *
+ * nice, eh?
+ */
+
+
+#include "m_pd.h"
+#include "g_canvas.h"
+
+
+/* ------------------------- propertybang ---------------------------- */
+
+static t_class *propertybang_class;
+
+typedef struct _propertybang
+{
+ t_object x_obj;
+ t_symbol *x_d0name;
+} t_propertybang;
+
+
+static void propertybang_free(t_propertybang *x)
+{
+ pd_unbind(&x->x_obj.ob_pd, x->x_d0name);
+}
+
+static void propertybang_anything(t_propertybang *x, t_symbol*s, int argc, t_atom*argv) {
+ if(s==&s_bang && argc==0) {
+ outlet_bang(x->x_obj.ob_outlet);
+ }
+}
+
+static void propertybang_properties(t_gobj*z, t_glist*owner) {
+ // argh: z is the abstraction! but we need to access ourselfs!
+ // we handle this by binding to a special symbol. e.g. "$0-propertybang"
+
+ t_symbol*s_d0name=canvas_realizedollar((t_canvas*)z, gensym("$0 propertybang"));
+ pd_bang(s_d0name->s_thing);
+}
+
+static void *propertybang_new(void)
+{
+ t_propertybang *x = (t_propertybang *)pd_new(propertybang_class);
+ t_glist *glist=(t_glist *)canvas_getcurrent();
+ t_canvas *canvas=(t_canvas*)glist_getcanvas(glist);
+ t_class *class = ((t_gobj*)canvas)->g_pd;
+
+ outlet_new(&x->x_obj, &s_bang);
+
+ x->x_d0name=canvas_realizedollar(canvas, gensym("$0 propertybang"));
+ pd_bind(&x->x_obj.ob_pd, x->x_d0name);
+
+ class_setpropertiesfn(class, propertybang_properties);
+ return (x);
+}
+
+void propertybang_setup(void)
+{
+ propertybang_class = class_new(gensym("propertybang"), (t_newmethod)propertybang_new,
+ (t_method)propertybang_free, sizeof(t_propertybang), CLASS_NOINLET, 0);
+ class_addanything(propertybang_class, propertybang_anything);
+}
diff --git a/src/saveargs.c b/src/saveargs.c
new file mode 100644
index 0000000..35b4d12
--- /dev/null
+++ b/src/saveargs.c
@@ -0,0 +1,92 @@
+
+/******************************************************
+ *
+ * saveargs - implementation file
+ *
+ * copyleft (c) IOhannes m zm-bölnig-A
+ *
+ * 2007:forum::f-bür::umläute:2007-A
+ *
+ * institute of electronic music and acoustics (iem)
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+
+/*
+ * this object provides a way to manipulate the parent-patches arguments (and name!)
+ * usage:
+ * + put this object into an abstraction
+ * + put the abstraction in a patch
+ * + send the object a _list_ of arguments
+ * + the next time the patch (wherein the abstraction that holds this object lives)
+ * is saved, it will be saved with the new arguments instead of the old ones!
+ * - example: "list 2 3 4" will save the object as [<absname> 2 3 4]
+ * + you can also change the abstraction name itself by using a selector other than "list"
+ * - example: "bonkers 8 9" will save the object as [bonkers 8 9] regardless of it's original name
+ * - use with care!
+ *
+ * nice, eh?
+ */
+
+#include "m_pd.h"
+#include "g_canvas.h"
+
+
+/* ------------------------- saveargs ---------------------------- */
+
+static t_class *saveargs_class;
+
+typedef struct _saveargs
+{
+ t_object x_obj;
+
+ t_canvas *x_canvas;
+} t_saveargs;
+
+
+static void saveargs_list(t_saveargs *x, t_symbol*s, int argc, t_atom*argv)
+{
+ t_canvas*c=x->x_canvas;
+ t_binbuf*b=0;
+ t_atom name[1];
+
+ if(!x->x_canvas) return;
+ b=x->x_canvas->gl_obj.te_binbuf;
+
+ if(!b)return;
+
+ if(s==0 || s==gensym("") || s==&s_list || s==&s_bang || s==&s_float || s==&s_symbol || s==&s_) {
+ t_atom*ap=binbuf_getvec(b);
+ s=atom_getsymbol(ap);
+ }
+ SETSYMBOL(name, s);
+
+ binbuf_clear(b);
+ binbuf_add(b, 1, name);
+ binbuf_add(b, argc, argv);
+}
+
+static void saveargs_free(t_saveargs *x)
+{
+}
+
+static void *saveargs_new(void)
+{
+ t_saveargs *x = (t_saveargs *)pd_new(saveargs_class);
+ t_glist *glist=(t_glist *)canvas_getcurrent();
+ t_canvas *canvas=(t_canvas*)glist_getcanvas(glist);
+
+ x->x_canvas = canvas;
+ return (x);
+}
+
+void saveargs_setup(void)
+{
+ saveargs_class = class_new(gensym("saveargs"), (t_newmethod)saveargs_new,
+ (t_method)saveargs_free, sizeof(t_saveargs), 0, 0);
+ class_addanything(saveargs_class, (t_method)saveargs_list);
+}