diff options
-rw-r--r-- | getpatchname/doc/help-getpatchname.pd | 14 | ||||
-rw-r--r-- | getpatchname/makefile | 58 | ||||
-rw-r--r-- | getpatchname/src/getpatchname.c | 54 |
3 files changed, 126 insertions, 0 deletions
diff --git a/getpatchname/doc/help-getpatchname.pd b/getpatchname/doc/help-getpatchname.pd new file mode 100644 index 0000000..a9ff019 --- /dev/null +++ b/getpatchname/doc/help-getpatchname.pd @@ -0,0 +1,14 @@ +#N canvas 0 0 450 300 10; +#X obj 160 101 loadbang; +#X symbolatom 160 170 20 0 0 0 - - -; +#X obj 239 102 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1 +-1; +#X text 22 16 getpatchname: This external returns the name of the current +patch as a symbol when sent a 'bang' message; +#X obj 160 131 getpatchname; +#X text 26 236 Note: at the moment it retains the name of the patch +returned when the object was instantiated. This will be revised in +future versions; +#X connect 0 0 4 0; +#X connect 2 0 4 0; +#X connect 4 0 1 0; diff --git a/getpatchname/makefile b/getpatchname/makefile new file mode 100644 index 0000000..54e60c8 --- /dev/null +++ b/getpatchname/makefile @@ -0,0 +1,58 @@ +NAME=getpatchname +CSYM=getpatchname + +LIBDIR=/usr/local/lib +PDDIR=$(LIBDIR)/pd +INSTALLPATH=$(PDDIR)/extra/ + +current: pd_linux + + +# ----------------------- Linux ----------------------- + +pd_linux: src/$(NAME).pd_linux + +.SUFFIXES: .pd_linux + +LINUXCFLAGS = -ggdb -DPD -O3 -fPIC -funroll-loops -fomit-frame-pointer \ + -Wall -W -Wshadow -Wstrict-prototypes -Werror \ + -Wno-unused -Wno-parentheses -Wno-switch + +# Debug +#LINUXCFLAGS = -ggdb -g -DPD -O0 -fPIC -funroll-loops -fomit-frame-pointer \ + -Wall -W -Wshadow -Wstrict-prototypes -Werror \ + -Wno-unused -Wno-parentheses -Wno-switch + +LINUXINCLUDE = -I/usr/include -I./include + +.c.pd_linux: + $(CC) $(LINUXCFLAGS) $(LINUXINCLUDE) -c src/$(NAME).c + ld -export_dynamic -shared -o $(NAME).pd_linux $(NAME).o -lc + strip --strip-unneeded $(NAME).pd_linux + rm -f *.o + +# ----------------------- Mac OSX ----------------------- + +pd_darwin: src/$(NAME).pd_darwin + +.SUFFIXES: .pd_darwin + +DARWINCFLAGS = -DPD -O3 -Wall -W -Wshadow -Wstrict-prototypes \ + -Wno-unused -Wno-parentheses -Wno-switch -L/usr/local/lib/ + +DARWININCLUDE = $(LINUXINCLUDE) + +.c.pd_darwin: + $(CC) $(DARWINCFLAGS) $(DARWININCLUDE) -c src/$(NAME).c + $(CC) -bundle -undefined suppress -flat_namespace -o $(NAME).pd_darwin $(NAME).o + rm -f *.o + +# ----------------------- Generic ----------------------- + +clean: + rm -f *.o *.pd_* so_locations + +install: + cp getpatchname.pd_linux $(INSTALLPATH) + install -d $(PDDIR)/doc/5.reference/getpatchname/ + install -m 644 doc/help-* $(PDDIR)/doc/5.reference/ diff --git a/getpatchname/src/getpatchname.c b/getpatchname/src/getpatchname.c new file mode 100644 index 0000000..c9116a8 --- /dev/null +++ b/getpatchname/src/getpatchname.c @@ -0,0 +1,54 @@ + +/* getpatchname - Returns the filename of the current patch + * + * Copyright (C) 2006 Jamie Bullock + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "m_pd.h" +#include "g_canvas.h" + +static t_class *getpatchname_class; + +typedef struct _getpatchname { + t_object x_obj; + t_symbol *patch_name; + t_outlet *outlet; +} t_getpatchname; + +void getpatchname_bang(t_getpatchname *x) +{ +/* At some point we need to be to get the new patch name if it changes, couldn't make this work though */ + outlet_symbol(x->outlet, x->patch_name); +} + +void *getpatchname_new(void) +{ + t_getpatchname *x = (t_getpatchname *)pd_new(getpatchname_class); + x->patch_name = canvas_getcurrent()->gl_name; + x->outlet = outlet_new(&x->x_obj, &s_symbol); + return (void *)x; +} + +void getpatchname_setup(void) { + getpatchname_class = class_new(gensym("getpatchname"), + (t_newmethod)getpatchname_new, + 0, sizeof(t_getpatchname), + CLASS_DEFAULT, 0); + class_addbang(getpatchname_class, getpatchname_bang); +} + + |