aboutsummaryrefslogtreecommitdiff
path: root/src/tabset.c
diff options
context:
space:
mode:
authorIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-03-22 20:58:25 +0000
committerIOhannes m zmölnig <zmoelnig@users.sourceforge.net>2005-03-22 20:58:25 +0000
commit2b60d55c919e7588f5aff15936e83c300b3660bb (patch)
tree14d860de7f28083d3756ad91b627de70f26788f6 /src/tabset.c
parentc500bc542cb7cc78d6dac3f7da3bff626056b1aa (diff)
zexy-2.0:
- use of abstractions for objects that allow it - some objects are build both as externals and abstractions (as slower fallbacks) - code-layout is now 1:1 c-file<->object (this should allow for building of zexy as a collection of externals instead as a big library) - matrix-objects have moved to iemmatrix !! svn path=/trunk/externals/zexy/; revision=2641
Diffstat (limited to 'src/tabset.c')
-rw-r--r--src/tabset.c102
1 files changed, 102 insertions, 0 deletions
diff --git a/src/tabset.c b/src/tabset.c
new file mode 100644
index 0000000..9234935
--- /dev/null
+++ b/src/tabset.c
@@ -0,0 +1,102 @@
+/******************************************************
+ *
+ * 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
+ *
+ ******************************************************/
+
+/* hack : 2108:forum::für::umläute:1999 @ iem */
+
+#include "zexy.h"
+
+
+/* =================== tabset ====================== */
+
+static t_class *tabset_class;
+
+typedef struct _tabset
+{
+ t_object x_obj;
+ t_symbol *x_arrayname;
+} t_tabset;
+
+static void tabset_float(t_tabset *x, t_floatarg f)
+{
+ t_garray *A;
+ int npoints;
+ t_float *vec;
+
+ if (!(A = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
+ error("%s: no such array", x->x_arrayname->s_name);
+ else if (!garray_getfloatarray(A, &npoints, &vec))
+ error("%s: bad template for tabset", x->x_arrayname->s_name);
+ else {
+ while(npoints--)*vec++=f;
+ garray_redraw(A);
+ }
+}
+
+static void tabset_list(t_tabset *x, t_symbol *s, int argc, t_atom* argv)
+{
+ t_garray *A;
+ int npoints;
+ t_float *vec;
+
+ if (!(A = (t_garray *)pd_findbyclass(x->x_arrayname, garray_class)))
+ error("%s: no such array", x->x_arrayname->s_name);
+ else if (!garray_getfloatarray(A, &npoints, &vec))
+ error("%s: bad template for tabset", x->x_arrayname->s_name);
+ else {
+ if (argc>=npoints)
+ while(npoints--)*vec++=atom_getfloat(argv++);
+ else {
+ npoints-=argc;
+ while (argc--)*vec++=atom_getfloat(argv++);
+ while (npoints--)*vec++=0;
+ }
+ garray_redraw(A);
+ }
+}
+static void tabset_set(t_tabset *x, t_symbol *s)
+{
+ x->x_arrayname = s;
+}
+
+static void *tabset_new(t_symbol *s)
+{
+ t_tabset *x = (t_tabset *)pd_new(tabset_class);
+ x->x_arrayname = s;
+
+ return (x);
+}
+
+static void tabset_helper(void)
+{
+ post("\n%c tabset - object : set a table with a package of floats", HEARTSYMBOL);
+ post("'set <table>'\t: set another table\n"
+ "<list>\t\t: set the table"
+ "<float>\t\t: set the table to constant float\n");
+ post("creation\t: \"tabset <table>\"");
+}
+
+void tabset_setup(void)
+{
+ tabset_class = class_new(gensym("tabset"), (t_newmethod)tabset_new,
+ 0, sizeof(t_tabset), 0, A_DEFSYM, 0);
+ class_addfloat(tabset_class, (t_method)tabset_float);
+ class_addlist (tabset_class, (t_method)tabset_list);
+ class_addmethod(tabset_class, (t_method)tabset_set, gensym("set"),
+ A_SYMBOL, 0);
+
+ class_addmethod(tabset_class, (t_method)tabset_helper, gensym("help"), 0);
+ class_sethelpsymbol(tabset_class, gensym("zexy/tabset"));
+}