aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-05-10 13:21:21 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2007-05-10 13:21:21 +0000
commite62d711e091ebce0fca62b5ab48e4d97a6dbce10 (patch)
tree1ae769f6fbad0598be174dd4d47b463396053ac3 /src
parent1161a321930269de225ed62d0eb18094a2cb3645 (diff)
added my own version of [pack] and [unpack] which do not have type-tagging
svn path=/trunk/externals/zexy/; revision=7648
Diffstat (limited to 'src')
-rw-r--r--src/Makefile26
-rw-r--r--src/matchbox.c7
-rw-r--r--src/pack.c153
-rw-r--r--src/unpack.c104
-rw-r--r--src/z_zexy.c2
-rw-r--r--src/z_zexy.h2
6 files changed, 291 insertions, 3 deletions
diff --git a/src/Makefile b/src/Makefile
index 9ded18f..86a472d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -76,7 +76,7 @@ externals: $(OBJECTS)
clean:
-rm -f *.$(EXT) *.o
-realclean: clean
+realclean: clean alias-clean
-rm -f *~ _* config.*
-rm -f *.d *.d.*
@@ -94,12 +94,18 @@ alias: alias-bin alias-abs
alias-bin: all
./makealias.sh ../src/alias ../src ../reference
-
alias-abs:
./makealias.sh ../abs/alias ../abs
+alias-clean: alias-clean-bin alias-clean-abs
+
+alias-clean-bin:
+ ./makealias.sh -clean ../src/alias ../src ../reference
-install: all install-abs install-bin install-doc
+alias-clean-abs:
+ ./makealias.sh -clean ../abs/alias ../abs
+
+install: all alias install-abs install-bin install-doc
install-bin:
-install -d $(INSTALL_BIN)
@@ -113,6 +119,20 @@ install-abs:
-install -d $(INSTALL_BIN)
-install -m 644 ../abs/*.pd $(INSTALL_BIN)
+
+uninstall-bin:
+ -install -d $(INSTALL_BIN)
+ -install -m 644 $(LIBNAME).$(EXT) $(INSTALL_BIN)
+
+uninstall-doc:
+ -install -d $(INSTALL_DOC)
+ -install -m 644 ../reference/*.pd $(INSTALL_DOC)
+
+uninstall-abs:
+ -install -d $(INSTALL_BIN)
+ -install -m 644 ../abs/*.pd $(INSTALL_BIN)
+
+
dist: all realclean
(cd ../..;tar czvf $(TARNAME) $(LIBNAME))
diff --git a/src/matchbox.c b/src/matchbox.c
index 3c6cec0..6e5eeea 100644
--- a/src/matchbox.c
+++ b/src/matchbox.c
@@ -14,6 +14,13 @@
*
******************************************************/
+// LATER: add a creation argument to specify the initial search mode
+
+// LATER: bind a "name" to the [matchbox] so several objects can share the same entries
+// if no name is given at creation time, the entries are local only
+
+// even LATER: dynamically bind to several searchlists (via "set" message)
+
#include "zexy.h"
diff --git a/src/pack.c b/src/pack.c
new file mode 100644
index 0000000..39ae244
--- /dev/null
+++ b/src/pack.c
@@ -0,0 +1,153 @@
+
+/* 1903:forum::für::umläute:2005 */
+
+/*
+ * mulitplex : zpack a specified input to the output
+ *
+ * THINK: should the selector-inlet be the first or the last ???
+ * pros/cons:
+ * the 1st inlet being the selector is not consistant with pd (hot/cold)
+ * but as it since the hot inlet is selectable, the whole object is not really consitant
+ * numbering would have to start with 1 (for the 1st not-leftmost inlet)
+ * if the selector is rightmost this would mean: cold is right(most), hot is (somewhere) left
+ * numbering would be ok
+ *
+ * conclusio: make the selector rightmost
+ *
+ */
+
+#include "zexy.h"
+#include <stdio.h>
+
+
+/* ------------------------- zpack ------------------------------- */
+
+/*
+ a zpacker
+*/
+
+static t_class *zpack_class;
+static t_class *zpackproxy_class;
+
+typedef struct _zpack
+{
+ t_object x_obj;
+ struct _zpackproxy **x_proxy;
+
+ t_inlet **in;
+
+ t_atom*x_argv;
+ int x_argc;
+} t_zpack;
+
+
+typedef struct _zpackproxy
+{
+ t_pd p_pd;
+ t_zpack *p_master;
+ int id;
+} t_zpackproxy;
+
+
+static void setatom(t_zpack *x, t_atom*from, int to) {
+ x->x_argv[to].a_type=from->a_type;
+ x->x_argv[to].a_w =from->a_w;
+}
+
+static void zpack_bang(t_zpack*x) {
+ outlet_list(x->x_obj.ob_outlet, gensym("list"), x->x_argc, x->x_argv);
+}
+
+static void zpack_list0(t_zpack*x, t_symbol *s, int argc, t_atom *argv) {
+ if(argc>0)
+ setatom(x, argv, 0);
+ zpack_bang(x);
+}
+
+static void zpack_list(t_zpackproxy *y, t_symbol *s, int argc, t_atom *argv)
+{
+ if(argc>0)
+ setatom(y->p_master, argv, y->id);
+}
+
+static void *zpack_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_zpack *x = (t_zpack *)pd_new(zpack_class);
+ int n =0;
+
+ x->x_argc = (argc < 1)?2:argc;
+
+
+ if(argc<1) {
+ x->x_argv=(t_atom*)getbytes(2*sizeof(t_atom));
+ SETFLOAT(x->x_argv+0, 0.f);
+ SETFLOAT(x->x_argv+1, 0.f);
+ } else {
+ int i=0;
+ x->x_argv=(t_atom*)getbytes(x->x_argc*sizeof(t_atom));
+ for(i=0; i<x->x_argc; i++)
+ setatom(x, argv+i, i);
+ }
+
+ x->in = (t_inlet **)getbytes(x->x_argc * sizeof(t_inlet *));
+ x->x_proxy = (t_zpackproxy**)getbytes(x->x_argc * sizeof(t_zpackproxy*));
+
+ x->in[0] =0;
+ x->x_proxy[0]=0;
+
+ for (n = 1; n<x->x_argc; n++) {
+ x->x_proxy[n]=(t_zpackproxy*)pd_new(zpackproxy_class);
+ x->x_proxy[n]->p_master = x;
+ x->x_proxy[n]->id=n;
+ x->in[n] = inlet_new ((t_object*)x, (t_pd*)x->x_proxy[n], 0,0);
+ }
+
+ outlet_new(&x->x_obj, 0);
+ return (x);
+}
+
+static void zpack_free(t_zpack*x){
+ const int count = x->x_argc;
+
+ if(x->in && x->x_proxy){
+ int n=0;
+ for(n=0; n<count; n++){
+ if(x->in[n]){
+ inlet_free(x->in[n]);
+ }
+ x->in[n]=0;
+ if(x->x_proxy[n]){
+ t_zpackproxy *y=x->x_proxy[n];
+ y->p_master=0;
+ y->id=0;
+ pd_free(&y->p_pd);
+ }
+ x->x_proxy[n]=0;
+ }
+ freebytes(x->in, x->x_argc * sizeof(t_inlet *));
+ freebytes(x->x_proxy, x->x_argc * sizeof(t_zpackproxy*));
+ }
+}
+
+void zpack_setup(void)
+{
+ zpack_class = class_new(gensym("pack"), (t_newmethod)zpack_new,
+ (t_method)zpack_free, sizeof(t_zpack), 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)zpack_new, gensym("zexy/pack"), A_GIMME, 0);
+ class_addbang(zpack_class, zpack_bang);
+ class_addlist(zpack_class, zpack_list0);
+
+ zpackproxy_class = class_new(gensym("zpack proxy"), 0, 0,
+ sizeof(t_zpackproxy),
+ CLASS_PD | CLASS_NOINLET, 0);
+ class_addlist(zpackproxy_class, zpack_list);
+
+
+ zexy_register("pack");
+}
+
+void pack_setup(void)
+{
+ zpack_setup();
+}
+
diff --git a/src/unpack.c b/src/unpack.c
new file mode 100644
index 0000000..5c1f7b1
--- /dev/null
+++ b/src/unpack.c
@@ -0,0 +1,104 @@
+/******************************************************
+ *
+ * zexy - implementation file
+ *
+ * copyleft (c) IOhannes m zmölnig
+ *
+ * 1999:forum::für::umläute:2004
+ *
+ * institute of electronic music and acoustics (iem)
+ *
+ ******************************************************
+ *
+ * license: GNU General Public License v.2
+ *
+ ******************************************************/
+
+
+/* 2305:forum::für::umläute:2001 */
+
+#include "zexy.h"
+#include <string.h>
+
+/* ------------------------- zunpack ------------------------------- */
+
+/* convert anythings to lists, pass through the rest */
+
+static t_class *zunpack_class;
+
+typedef struct _zunpack
+{
+ t_object x_obj;
+ t_outlet**x_out;
+ t_int*x_index;
+ t_int x_numouts;
+} t_zunpack;
+
+static void zunpack_list(t_zunpack *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int count=(argc<(x->x_numouts))?argc:x->x_numouts;
+
+ while(count--) {
+ outlet_list(x->x_out[count], gensym("list"), 1, argv+count);
+ }
+
+}
+
+static void zunpack_bang(t_zunpack *x)
+{
+ outlet_bang(x->x_out[0]);
+}
+
+static void zunpack_free(t_zunpack *x)
+{
+ int i=0;
+ for(i=0; i<x->x_numouts; i++) {
+ outlet_free(x->x_out[i]);
+ }
+ freebytes(x->x_index, x->x_numouts*sizeof(t_int));
+ freebytes(x->x_out, x->x_numouts*sizeof(t_outlet*));
+
+ x->x_numouts=0;
+ x->x_index=0;
+ x->x_out=0;
+}
+
+static void *zunpack_new(t_symbol*s, int argc, t_atom*argv)
+{
+ t_zunpack *x = (t_zunpack *)pd_new(zunpack_class);
+ int count=(argc>0)?argc:2;
+ int i=0;
+
+ x->x_numouts=count;
+ x->x_index=(t_int*) getbytes(count*sizeof(t_int));
+ x->x_out=(t_outlet**)getbytes(count*sizeof(t_outlet*));
+
+ for(i=0; i<count; i++) {
+ x->x_out[i] =outlet_new(&x->x_obj, 0);
+ x->x_index[i]=count;
+ if(i<argc && argv[i].a_type == A_FLOAT) {
+ x->x_index[i]=atom_getint(argv+i);
+ }
+ }
+
+ return (x);
+}
+
+void zunpack_setup(void)
+{
+
+ zunpack_class = class_new(gensym("unpack"),
+ (t_newmethod)zunpack_new, (t_method)zunpack_free, sizeof(t_zunpack),
+ 0, A_GIMME, 0);
+ class_addcreator((t_newmethod)zunpack_new, gensym("zexy/unpack"), A_GIMME, 0);
+
+ class_addbang(zunpack_class, zunpack_bang);
+ class_addlist(zunpack_class, zunpack_list);
+
+ zexy_register("unpack");
+}
+
+void unpack_setup(void)
+{
+ zunpack_setup();
+}
diff --git a/src/z_zexy.c b/src/z_zexy.c
index 4b3a62c..258949f 100644
--- a/src/z_zexy.c
+++ b/src/z_zexy.c
@@ -51,6 +51,7 @@ void z_zexy_setup(void)
noisi_tilde_setup(); /* noisi~ */
operating_system_setup(); /* operating_system */
pack_tilde_setup(); /* pack~ */
+ pack_setup(); /* pack */
packel_setup(); /* packel */
pdf_tilde_setup(); /* pdf~ */
prime_setup(); /* prime */
@@ -75,6 +76,7 @@ void z_zexy_setup(void)
tavg_tilde_setup(); /* tavg~ */
time_setup(); /* time */
unpack_tilde_setup(); /* unpack~ */
+ unpack_setup(); /* unpack */
urn_setup(); /* urn */
wrap_setup(); /* wrap */
z_tilde_setup(); /* z~ */
diff --git a/src/z_zexy.h b/src/z_zexy.h
index fb28f11..2a50ef5 100644
--- a/src/z_zexy.h
+++ b/src/z_zexy.h
@@ -49,6 +49,7 @@ void noish_tilde_setup(void); /* noish~ */
void noisi_tilde_setup(void); /* noisi~ */
void operating_system_setup(void); /* operating_system */
void pack_tilde_setup(void); /* pack~ */
+void pack_setup(void); /* pack */
void packel_setup(void); /* packel */
void pdf_tilde_setup(void); /* pdf~ */
void prime_setup(void); /* prime */
@@ -73,6 +74,7 @@ void tabset_setup(void); /* tabset */
void tavg_tilde_setup(void); /* tavg~ */
void time_setup(void); /* time */
void unpack_tilde_setup(void); /* unpack~ */
+void unpack_setup(void); /* unpack */
void urn_setup(void); /* urn */
void wrap_setup(void); /* wrap */
void z_tilde_setup(void); /* z~ */