aboutsummaryrefslogtreecommitdiff
path: root/src/niagara.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/niagara.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/niagara.c')
-rw-r--r--src/niagara.c110
1 files changed, 110 insertions, 0 deletions
diff --git a/src/niagara.c b/src/niagara.c
new file mode 100644
index 0000000..5764952
--- /dev/null
+++ b/src/niagara.c
@@ -0,0 +1,110 @@
+/******************************************************
+ *
+ * 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
+ *
+ ******************************************************/
+
+/* 3108:forum::für::umläute:2000 */
+
+#include "zexy.h"
+#include <string.h>
+#include <memory.h>
+
+
+/* ------------------------- niagara ------------------------------- */
+
+/*
+divides a package into 2 sub-packages at a specified point
+like the niagara-falls, some water goes down to the left side, the rest to the right side, devided by the rock
+*/
+
+static t_class *niagara_class;
+
+typedef struct _niagara
+{
+ t_object x_obj;
+ t_float rock;
+ t_outlet *left, *right;
+} t_niagara;
+
+static void niagara_list(t_niagara *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int n_l, n_r;
+ t_atom *ap_l, *ap_r;
+ int dumrock = x->rock;
+ int rock = ((dumrock < 0.f)?(argc+dumrock):dumrock);
+
+ n_l = (rock < argc)?rock:argc;
+ ap_l = argv;
+
+ n_r = argc - n_l;
+ ap_r = &argv[n_l];
+
+ if (n_r) outlet_list(x->right, s, n_r, ap_r);
+ if (n_l) outlet_list(x->left, s, n_l, ap_l);
+}
+
+static void niagara_any(t_niagara *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int n_l, n_r;
+ t_atom *ap_l, *ap_r;
+ t_symbol *s_r, *s_l;
+ int dumrock = x->rock;
+ int rock = ((dumrock < 0.f)?(argc+dumrock):dumrock-1);
+
+ n_l = (rock < argc)?rock:argc;
+ ap_l = argv;
+ s_l = s;
+
+ n_r = argc - n_l;
+ ap_r = &argv[n_l];
+
+ if (n_r) {
+ s_r = 0;
+ if (ap_r->a_type == A_FLOAT) s_r = gensym("list");
+ else {
+ s_r = atom_getsymbol(ap_r);
+ ap_r++;
+ n_r--;
+ }
+ outlet_anything(x->right, s_r, n_r, ap_r);
+ }
+
+ if (n_l+1 ) outlet_anything(x->left, s_l, n_l, ap_l);
+}
+
+static void *niagara_new(t_floatarg f)
+{
+ t_niagara *x = (t_niagara *)pd_new(niagara_class);
+
+ x->rock = f;
+
+ x->left = outlet_new(&x->x_obj, &s_list);
+ x->right = outlet_new(&x->x_obj, &s_list);
+
+ floatinlet_new(&x->x_obj, &x->rock);
+
+ return (x);
+}
+
+void niagara_setup(void)
+{
+ niagara_class = class_new(gensym("niagara"), (t_newmethod)niagara_new,
+ 0, sizeof(t_niagara), 0, A_DEFFLOAT, 0);
+
+ class_addlist (niagara_class, niagara_list);
+ class_addanything(niagara_class, niagara_any);
+
+ class_sethelpsymbol(niagara_class, gensym("zexy/niagara"));
+ zexy_register("niagara");
+}