aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormusil <tmusil@users.sourceforge.net>2009-02-01 05:22:01 +0000
committermusil <tmusil@users.sourceforge.net>2009-02-01 05:22:01 +0000
commit0c2bbab79dd04ed75310ae10358b613c20179fc5 (patch)
tree685ff6571beb6622fac17601d83e5db9fd8f0a83
parentb46b39e4bcbf55aa1f41250ba76a6a72f24c7ec9 (diff)
new object tab_get_size of array
svn path=/trunk/externals/iem/iem_tab/; revision=10705
-rw-r--r--src/tab_get_size.c72
-rw-r--r--tab_get_size-help.pd36
2 files changed, 108 insertions, 0 deletions
diff --git a/src/tab_get_size.c b/src/tab_get_size.c
new file mode 100644
index 0000000..1f5c73f
--- /dev/null
+++ b/src/tab_get_size.c
@@ -0,0 +1,72 @@
+/* For information on usage and redistribution, and for a DISCLAIMER OF ALL
+* WARRANTIES, see the file, "LICENSE.txt," in this distribution.
+
+iem_tab written by Thomas Musil, Copyright (c) IEM KUG Graz Austria 2000 - 2009 */
+
+#include "m_pd.h"
+#include "iemlib.h"
+#include "iem_tab.h"
+
+/* -------------------------- tab_get_size ------------------------------ */
+
+typedef struct _tab_get_size
+{
+ t_object x_obj;
+ t_symbol *x_sym_src;
+} t_tab_get_size;
+
+static t_class *tab_get_size_class;
+
+static void tab_get_size_set(t_tab_get_size *x, t_symbol *s)
+{
+ x->x_sym_src = s;
+}
+
+static void tab_get_size_bang(t_tab_get_size *x)
+{
+ int ok_src, size_src;
+ iemarray_t *beg_mem_src;
+
+ ok_src = iem_tab_check_arrays(gensym("tab_get_size"), x->x_sym_src, &beg_mem_src, &size_src, 0);
+
+ if(ok_src)
+ {
+ outlet_float(x->x_obj.ob_outlet, (t_float)size_src);
+ }
+}
+
+static void tab_get_size_free(t_tab_get_size *x)
+{
+}
+
+static void *tab_get_size_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_tab_get_size *x = (t_tab_get_size *)pd_new(tab_get_size_class);
+ t_symbol *src;
+
+ if((argc >= 1) &&
+ IS_A_SYMBOL(argv,0))
+ {
+ src = (t_symbol *)atom_getsymbolarg(0, argc, argv);
+ }
+ else
+ {
+ post("tab_get_size-ERROR: need 1 symbol argument:");
+ post(" destination_array_name");
+ return(0);
+ }
+
+ x->x_sym_src = src;
+ outlet_new(&x->x_obj, &s_float);
+ return(x);
+}
+
+void tab_get_size_setup(void)
+{
+ tab_get_size_class = class_new(gensym("tab_get_size"), (t_newmethod)tab_get_size_new, (t_method)tab_get_size_free,
+ sizeof(t_tab_get_size), 0, A_GIMME, 0);
+ class_addbang(tab_get_size_class, (t_method)tab_get_size_bang);
+ class_addmethod(tab_get_size_class, (t_method)tab_get_size_set, gensym("set"), A_DEFSYMBOL, 0);
+ class_addmethod(tab_get_size_class, (t_method)tab_get_size_set, gensym("get"), A_DEFSYMBOL, 0);
+// class_sethelpsymbol(tab_get_size_class, gensym("iemhelp2/tab_get_size-help"));
+}
diff --git a/tab_get_size-help.pd b/tab_get_size-help.pd
new file mode 100644
index 0000000..fe5fd1e
--- /dev/null
+++ b/tab_get_size-help.pd
@@ -0,0 +1,36 @@
+#N canvas 116 92 706 333 10;
+#N canvas 0 22 450 300 (subpatch) 0;
+#X array src 100 float 1;
+#A 0 -0.442858 -0.414287 -0.385715 -0.342858 -0.314287 -0.257144 -0.128572
+-0.0428573 0.128572 0.228572 0.285715 0.328572 0.400001 0.414287 0.457144
+0.457144 0.442858 0.385715 0.314287 0.257144 0.214286 0.1 0.0428572
+-0.0142858 -0.0428573 -0.114286 -0.142858 -0.200001 -0.242858 -0.285715
+-0.328572 -0.342858 -0.37143 -0.385715 -0.414287 -0.414287 -0.414287
+-0.414287 -0.400001 -0.357144 -0.314287 -0.257144 -0.185715 -0.0714288
+0.0142857 0.0571429 0.171429 0.328572 0.400001 0.442858 0.47143 0.485715
+0.485715 0.485715 0.485715 0.485715 0.442858 0.357144 0.242858 0.185715
+0.114286 0.0714285 -0.071429 -0.242858 -0.300001 -0.328573 -0.357144
+-0.37143 -0.385715 -0.400001 -0.442858 -0.457144 -0.47143 -0.457144
+-0.428573 -0.400001 -0.378573 -0.328572 -0.271429 -0.242858 -0.200001
+-0.128572 -0.0428574 -0.0285717 0.0142858 0.114286 0.128572 0.185715
+0.214286 0.257144 0.285715 0.314287 0.342858 0.357144 0.357144 0.357144
+0.357144 0.357144 0.342858 0.328572;
+#X coords 0 1 99 -1 200 140 1;
+#X restore 433 42 graph;
+#X obj 61 31 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X floatatom 60 102 5 0 0 0 - - -;
+#X text 93 224 IEM KUG;
+#X text 72 212 musil;
+#X text 107 212 @;
+#X text 115 212 iem.at;
+#X text 76 234 Graz \, Austria;
+#X text 201 68 initial arguments:;
+#X text 11 6 tab_sum;
+#X text 183 81 1.arg: <symbol> source-name;
+#X text 28 201 (c) Thomas Musil 2000 - 2009;
+#X obj 61 78 tab_get_size src;
+#X text 56 116 array size;
+#X text 90 29 <bang> calc size of array;
+#X connect 1 0 12 0;
+#X connect 12 0 2 0;