[Gridflow-cvs] [svn] commit: r5997 - in /trunk: doc/flow_classes/#tabread-help.pd doc/flow_classes/#tabwrite-help.pd src/classes3.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Sun Aug 8 23:07:05 EDT 2010


Author: pboivin
Date: Sun Aug  8 23:07:04 2010
New Revision: 5997

Log:
new class: #tabwrite

Added:
    trunk/doc/flow_classes/#tabwrite-help.pd
Modified:
    trunk/doc/flow_classes/#tabread-help.pd
    trunk/src/classes3.cxx

Modified: trunk/doc/flow_classes/#tabread-help.pd
==============================================================================
--- trunk/doc/flow_classes/#tabread-help.pd (original)
+++ trunk/doc/flow_classes/#tabread-help.pd Sun Aug  8 23:07:04 2010
@@ -1,4 +1,4 @@
-#N canvas 399 114 632 639 10;
+#N canvas 470 22 632 639 10;
 #X obj 0 0 doc_h;
 #X obj 3 583 doc_also;
 #X obj 0 605 doc_f;
@@ -29,8 +29,6 @@
 ;
 #X obj 3 332 doc_i 1;
 #X obj 97 467 doc_m i0 set;
-#X text 232 467 \$1=table;
-#X text 232 489 Dynamically set the table to read from.;
 #X obj 137 204 display;
 #X msg 244 131 set tatable;
 #X obj 494 162 table tatable 10;
@@ -42,22 +40,28 @@
 #X obj 402 128 s tatable;
 #X obj 402 48 loadbang;
 #X obj 59 101 #for 0 10 1;
+#X text 232 489 Set the table to read from.;
+#X obj 157 583 tabwrite;
+#X obj 217 583 #tabwrite;
+#X text 232 467 \$1=table;
 #X connect 1 1 13 0;
-#X connect 3 0 36 0;
+#X connect 1 1 36 0;
+#X connect 1 1 37 0;
+#X connect 3 0 34 0;
 #X connect 5 0 4 0;
 #X connect 9 1 16 0;
 #X connect 14 1 17 0;
 #X connect 14 1 18 0;
 #X connect 14 1 20 0;
 #X connect 15 1 21 0;
-#X connect 19 0 30 0;
-#X connect 23 1 24 0;
-#X connect 23 1 25 0;
-#X connect 27 0 30 0;
-#X connect 30 0 5 0;
-#X connect 30 0 26 0;
-#X connect 31 0 34 0;
-#X connect 32 0 33 0;
-#X connect 35 0 32 0;
-#X connect 35 0 31 0;
-#X connect 36 0 30 0;
+#X connect 19 0 28 0;
+#X connect 23 1 35 0;
+#X connect 23 1 38 0;
+#X connect 25 0 28 0;
+#X connect 28 0 5 0;
+#X connect 28 0 24 0;
+#X connect 29 0 32 0;
+#X connect 30 0 31 0;
+#X connect 33 0 30 0;
+#X connect 33 0 29 0;
+#X connect 34 0 28 0;

Modified: trunk/src/classes3.cxx
==============================================================================
--- trunk/src/classes3.cxx (original)
+++ trunk/src/classes3.cxx Sun Aug  8 23:07:04 2010
@@ -1461,6 +1461,56 @@
 \end class {install("#tabread",1,1);}
 
 //****************************************************************
+
+\class GridTabwrite : FObject {
+	t_symbol *t;
+	PtrGrid r;
+	\constructor (t_symbol *table=&s_) {
+		t = table;
+	}
+	\decl 0 set (t_symbol *s) { t = s; }
+	\grin 0
+	\grin 1
+};
+
+GRID_INLET(0) {	
+	if (!r) RAISE("need right-hand grid first !");
+	in.set_chunk(-1);
+} GRID_FLOW {
+	int32 *rdata = (int32 *)*r;
+	int npoints, nval=in.dim.prod(), nidx=r->dim.prod();
+	t_garray *a;
+	t_word *vec;
+
+	if (!(a = (t_garray *)pd_findbyclass(t, garray_class)))
+		RAISE("%s: no such array", t->s_name);
+	else if (!garray_getfloatwords(a, &npoints, &vec))
+		RAISE("%s: bad template for tabread", t->s_name);
+	else {
+		for (int i=0; i<nidx; i++) {
+			int n = rdata[i];
+			if (n < 0)
+				n = 0;
+			else if (n >= npoints)
+				n = npoints-1;
+			// if there are less values than there are indexes, we loop over the value list
+			vec[n].w_float = data[i%nval];
+		}
+	}
+	garray_redraw(a);
+} GRID_END
+
+// hack du GRID_INPUT original de gridflow.hxx
+#define GRID_INPUT_INT32(I,V) \
+	GRID_INLET(I) { \
+		if (in.nt!=int32_e) RAISE("right inlet: expected int32"); \
+		V=new Grid(in.dim,NumberTypeE_type_of(data));} GRID_FLOW {COPY((T *)*(V)+in.dex,data,n);} GRID_FINISH
+
+GRID_INPUT_INT32(1,r) {} GRID_END
+
+\end class {install("#tabwrite",2,0);}
+
+//****************************************************************
 void startup_flow_objects3 () {
 	op_os8 = OP(*>>8);
 	\startall



More information about the Gridflow-cvs mailing list