[Gridflow-cvs] [svn] commit: r6588 - in /trunk: doc/flow_classes/#to~-help.pd src/classes3.cxx

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Wed Feb 9 13:10:39 EST 2011


Author: matju
Date: Wed Feb  9 13:10:37 2011
New Revision: 6588

Log:
[#to~]: add second argument for buffer size (in samples)

Modified:
    trunk/doc/flow_classes/#to~-help.pd
    trunk/src/classes3.cxx

Modified: trunk/doc/flow_classes/#to~-help.pd
==============================================================================
--- trunk/doc/flow_classes/#to~-help.pd (original)
+++ trunk/doc/flow_classes/#to~-help.pd Wed Feb  9 13:10:37 2011
@@ -1,10 +1,10 @@
 #N canvas 596 0 632 642 10;
 #X obj 0 0 doc_h;
-#X obj 0 632 doc_f;
+#X obj 0 789 doc_f;
 #X obj 278 87 s pd;
 #X msg 278 68 dsp 1;
 #X obj 278 49 loadbang;
-#X obj 3 612 doc_also;
+#X obj 3 769 doc_also;
 #X obj 160 215 #cast f;
 #X obj 160 30 bng 15 250 50 0 empty empty empty 17 7 0 10 -204786 -1
 -1;
@@ -12,24 +12,22 @@
 #X obj 160 104 #t;
 #X obj 160 85 # ^;
 #X floatatom 185 86 5 0 0 0 - - -;
-#X obj 3 436 doc_i 1;
-#X obj 14 466 doc_ii 0;
-#X obj 3 524 doc_o any;
-#X obj 14 554 doc_oo any;
-#X obj 97 554 doc_m oany <signal>;
-#X obj 3 374 doc_c 1;
+#X obj 3 593 doc_i 1;
+#X obj 14 623 doc_ii 0;
+#X obj 3 681 doc_o any;
+#X obj 14 711 doc_oo any;
+#X obj 97 711 doc_m oany <signal>;
 #X obj 14 404 doc_cc 0;
 #X obj 97 404 doc_m c0 float;
 #X text 232 404 number of output channels;
-#X obj 97 466 doc_m i0 grid;
-#X text 232 466 a grid of size (samples \, channels). any number of
+#X obj 97 623 doc_m i0 grid;
+#X text 232 623 a grid of size (samples \, channels). any number of
 samples may be given \, but the number of channels must be the same
 as the number of channels specified in the constructor.;
-#X text 232 554 the signal of outlet number n is made from the column
+#X text 232 711 the signal of outlet number n is made from the column
 number n of all the grids received \, end to end. when there are no
 more rows to play \, the output will be zero.;
-#X obj 103 612 #in~;
-#X obj 160 258 #to~ 2;
+#X obj 103 769 #in~;
 #X obj 198 343 dac~;
 #X obj 26 141 metro;
 #X msg 53 59 16384;
@@ -53,37 +51,56 @@
 #X obj 220 292 lop~ 2000;
 #X obj 160 292 lop~ 500;
 #X obj 160 147 # >> (3 6);
+#X obj 3 374 doc_c 2;
+#X obj 14 426 doc_cc 1;
+#X obj 97 426 doc_m c1 float;
+#X text 232 461 this has to be big enough so that it doesn't get empty
+when you are sending grids that are supposed to be connected \, else
+it will cause a kind of dropout \, which is not a dropout of the whole
+pd \, just a dropout of [#to~] \, because [#to~] plays zeroes when
+it doesn't have anything to play.;
+#X text 232 426 number of samples (per channel) to keep in advance.
+this has to be a power of two.;
+#X obj 139 769 #from~;
+#X obj 160 258 #to~ 2;
+#X text 232 535 default is 16384 (thus it takes 64k per channel. note
+that GridFlow's own buffers don't take double the RAM when in 64-bit
+mode \, unlike [table]);
 #X connect 3 0 2 0;
 #X connect 4 0 3 0;
-#X connect 5 1 24 0;
-#X connect 6 0 41 0;
-#X connect 7 0 35 0;
+#X connect 5 1 23 0;
+#X connect 5 1 50 0;
+#X connect 6 0 39 0;
+#X connect 7 0 33 0;
 #X connect 8 0 10 0;
-#X connect 9 0 40 0;
-#X connect 9 1 40 1;
+#X connect 9 0 38 0;
+#X connect 9 1 38 1;
 #X connect 10 0 9 0;
 #X connect 11 0 10 1;
-#X connect 16 1 23 0;
-#X connect 19 1 20 0;
-#X connect 21 1 22 0;
-#X connect 25 0 45 0;
-#X connect 25 1 44 0;
-#X connect 27 0 33 0;
-#X connect 27 0 35 0;
-#X connect 28 0 29 0;
-#X connect 29 0 32 0;
-#X connect 29 0 27 1;
-#X connect 31 0 28 0;
-#X connect 34 0 27 0;
-#X connect 35 0 8 0;
-#X connect 35 1 36 0;
-#X connect 36 0 11 0;
-#X connect 37 0 26 0;
-#X connect 38 0 26 1;
-#X connect 39 0 6 0;
-#X connect 40 0 46 0;
-#X connect 41 0 25 0;
-#X connect 42 0 39 0;
-#X connect 44 0 38 0;
-#X connect 45 0 37 0;
-#X connect 46 0 42 0;
+#X connect 16 1 22 0;
+#X connect 18 1 19 0;
+#X connect 20 1 21 0;
+#X connect 25 0 31 0;
+#X connect 25 0 33 0;
+#X connect 26 0 27 0;
+#X connect 27 0 30 0;
+#X connect 27 0 25 1;
+#X connect 29 0 26 0;
+#X connect 32 0 25 0;
+#X connect 33 0 8 0;
+#X connect 33 1 34 0;
+#X connect 34 0 11 0;
+#X connect 35 0 24 0;
+#X connect 36 0 24 1;
+#X connect 37 0 6 0;
+#X connect 38 0 44 0;
+#X connect 39 0 51 0;
+#X connect 40 0 37 0;
+#X connect 42 0 36 0;
+#X connect 43 0 35 0;
+#X connect 44 0 40 0;
+#X connect 47 1 49 0;
+#X connect 47 1 48 0;
+#X connect 47 1 52 0;
+#X connect 51 0 43 0;
+#X connect 51 1 42 0;

Modified: trunk/src/classes3.cxx
==============================================================================
--- trunk/src/classes3.cxx (original)
+++ trunk/src/classes3.cxx Wed Feb  9 13:10:37 2011
@@ -32,18 +32,22 @@
 
 //****************************************************************
 \class GridToTilde {
+	int capacity;
 	P<Grid> blah;
 	t_outlet **sigout;
 	int chans; /* number of channels */
 	int start;
 	int size;
 	t_sample **sam;
-	\constructor (int chans=1) {
+	\constructor (int chans=1, int capacity=16384) {
 		if (chans<0) RAISE("need nonnegative number of channels");
+		if (capacity<1) RAISE("capacity must be at least 1");
+		if ((capacity&-capacity)!=capacity) RAISE("capacity must be a power of two");
 		sigout = new t_outlet *[chans];
 		for (int i=0; i<chans; i++) sigout[i] = outlet_new((t_object *)bself,&s_signal);
 		this->chans = chans;
-		blah=new Grid(Dim(16384,chans),float32_e);
+		this->capacity = capacity;
+		blah=new Grid(Dim(capacity,chans),float32_e);
 		start=0; size=0; sam=0;
 	}
 	~GridToTilde () {delete[] sigout; if (sam) delete[] sam;}
@@ -52,7 +56,7 @@
 		for (int i=0; i<n; i++) {
 			if (size) {
 				for (int j=0; j<chans; j++) sam[j][i]=data[start*chans+j];
-				start=(start+1)&16383;
+				start=(start+1)&(capacity-1);
 				size--;
 			} else for (int j=0; j<chans; j++) sam[j][i]=0;
 		}
@@ -71,15 +75,15 @@
 	if (in.dim.n!=2) RAISE("expecting two dimensions: signal samples, signal channels");
 	if (in.dim[1]!=chans) RAISE("grid has %d channels, but this object has %d outlets",in.dim[1],chans);
 } GRID_FLOW {
-	if (size==16384) return;
-	while (n && size<16384) {
-		int i = ((start+size)&16383) * chans;
+	if (size==capacity) return;
+	while (n && size<capacity) {
+		int i = ((start+size)&(capacity-1)) * chans;
 		COPY((T *)*blah+i,data,chans);
 		data+=chans; n-=chans; size++;
 	}
-	if (n>0) post("[#to~] buffer full: dropped %ld samples",long(n/chans));
+	if (n>0) post("[#to~] buffer full: dropped %ld samples. will not report further till it's not full anymore.",long(n/chans));
 } GRID_FINISH {
-	//post("[#to~] buffer size : %d out of 16384",size);
+	//post("[#to~] buffer size : %d out of %d",size,capacity);
 } GRID_END
 \end class {
 	install("#to~",1,0); // actually it has outlets that are not registered with GF



More information about the Gridflow-cvs mailing list