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

svn-gridflow at artengine.ca svn-gridflow at artengine.ca
Wed Feb 9 15:06:58 EST 2011


Author: matju
Date: Wed Feb  9 15:06:56 2011
New Revision: 6592

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

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

Modified: trunk/doc/flow_classes/#from~-help.pd
==============================================================================
--- trunk/doc/flow_classes/#from~-help.pd (original)
+++ trunk/doc/flow_classes/#from~-help.pd Wed Feb  9 15:06:56 2011
@@ -1,94 +1,114 @@
-#N canvas 541 81 632 642 10;
+#N canvas 625 74 632 642 10;
 #X obj 0 0 doc_h;
-#X obj 3 600 doc_also;
-#X obj 0 620 doc_f;
-#X obj 3 375 doc_c 1;
-#X obj 14 405 doc_cc 0;
-#X obj 97 405 doc_m c0 float;
-#X text 232 405 number of channels (default: 1);
-#X obj 3 437 doc_i 1..;
-#X obj 14 467 doc_ii any;
-#X obj 97 467 doc_m iany <signal>;
-#X text 232 467 signal in inlet number N will be column number N in
+#X obj 3 818 doc_also;
+#X obj 0 838 doc_f;
+#X obj 14 505 doc_cc 0;
+#X obj 97 505 doc_m c0 float;
+#X text 232 505 number of channels (default: 1);
+#X obj 3 655 doc_i 1..;
+#X obj 14 685 doc_ii any;
+#X obj 97 685 doc_m iany <signal>;
+#X text 232 685 signal in inlet number N will be column number N in
 the output grid.;
-#X obj 3 512 doc_o 1;
-#X obj 14 542 doc_oo 0;
-#X obj 97 542 doc_m o0 grid;
-#X text 232 542 a grid of size (blocksize \, channels) where blocksize
+#X obj 3 730 doc_o 1;
+#X obj 14 760 doc_oo 0;
+#X obj 97 760 doc_m o0 grid;
+#X text 232 760 a grid of size (blocksize \, channels) where blocksize
 is the current blocksize as defined by the [block~] currently active
 in this context. (default blocksize is 64);
-#X obj 28 161 #from~ 4;
-#X obj 103 600 #to~;
-#X obj 139 600 #tabread;
-#X obj 246 160 #see;
-#X obj 28 81 osc~ 1;
-#X obj 151 101 #for -64 64;
-#X obj 151 121 #cast f;
-#X obj 151 141 # / (f 64);
-#X obj 151 81 loadbang;
-#X obj 28 241 #transpose 1 2;
-#X obj 28 221 #outer <;
-#X obj 28 281 #cast;
-#X obj 28 261 #transpose;
-#X obj 28 201 #scale_to (128 4);
-#X obj 42 101 osc~ 0.5;
-#X obj 58 121 osc~ 0.25;
-#X obj 28 181 #import (5125 4) \, cast f;
-#X obj 28 321 #inner (4 3 # 170 0 0 0 170 0 0 0 170 85 85 85);
-#X obj 72 141 osc~ 0.1;
-#X obj 28 301 #convolve (2 1 # 1 -1);
-#X msg 512 55 \; pd dsp \$1;
-#X obj 512 37 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
-1;
-#X obj 413 207 #from~ 6;
-#X obj 422 100 osc~ 200;
-#X obj 432 120 osc~ 300;
-#X obj 413 227 # * (f 1 0.9 0.8 0.7 0.6 0.5);
-#X obj 413 247 #to~ 6 \, \, \, \, \, \,;
-#X obj 412 80 osc~ 100;
-#X obj 441 141 osc~ 400;
-#X obj 450 161 osc~ 500;
-#X obj 459 181 osc~ 600;
-#X obj 439 285 *~ 0.05;
-#X obj 439 315 dac~;
+#X obj 103 818 #to~;
+#X obj 139 818 #tabread;
+#X obj 433 177 #from~ 6;
+#X obj 433 197 # * (f 1 0.9 0.8 0.7 0.6 0.5);
+#X obj 433 217 #to~ 6 \, \, \, \, \, \,;
+#X obj 432 50 osc~ 100;
+#X obj 459 255 *~ 0.05;
+#X obj 459 285 dac~;
 #X text 15 38 Turn several signals into a sequence of multichannel
 grids.;
-#X connect 1 1 16 0;
-#X connect 1 1 17 0;
-#X connect 5 1 6 0;
-#X connect 9 1 10 0;
-#X connect 13 1 14 0;
-#X connect 15 0 31 0;
-#X connect 19 0 15 0;
+#X obj 18 61 osc~ 43;
+#X obj 442 70 osc~ 250;
+#X obj 452 90 osc~ 350;
+#X obj 461 111 osc~ 450;
+#X obj 470 131 osc~ 550;
+#X obj 479 151 osc~ 650;
+#X obj 3 475 doc_c 2;
+#X obj 14 527 doc_cc 1;
+#X obj 97 527 doc_m c1 float;
+#X text 232 527 capacity of the buffer. this either 0 or a power of
+two. (default: 0);
+#X text 232 562 when it's zero \, the number of samples per grid (for
+each channel) is the current blocksize of the canvas.;
+#X obj 18 388 #see;
+#X obj 155 121 #cast f;
+#X obj 155 83 loadbang;
+#X obj 18 233 #transpose 1 2;
+#X obj 18 157 #outer <;
+#X obj 18 252 #transpose;
+#X obj 18 331 #inner (4 3 # 170 0 0 0 170 0 0 0 170 85 85 85);
+#X obj 42 80 osc~ 85;
+#X obj 68 99 osc~ 170;
+#X obj 93 118 osc~ 128;
+#X obj 18 195 #cast;
+#X obj 18 369 # >> 8;
+#X obj 18 176 # * (f 256);
+#X obj 155 102 #for -32 32;
+#X obj 18 214 #downscale_by (8 1) smoothly;
+#X obj 18 138 #from~ 4 2048;
+#X obj 18 271 shunt;
+#X obj 54 272 tgl 15 0 empty empty empty 17 7 0 10 -261682 -1 -1 0
+1;
+#X obj 45 309 # max;
+#X obj 45 290 #convolve (8 1 # -1 0 0 0 0 0 0 1);
+#X obj 155 140 # / (f 24);
+#X obj 18 350 #fade 3;
+#X text 232 597 when it's nonzero \, the number of samples can be higher
+(a power of two multiple). but don't make this number less than the
+canvas' blocksize !);
+#X connect 1 1 14 0;
+#X connect 1 1 15 0;
+#X connect 4 1 5 0;
+#X connect 8 1 9 0;
+#X connect 12 1 13 0;
+#X connect 16 0 17 0;
+#X connect 17 0 18 0;
+#X connect 18 0 20 0;
+#X connect 18 1 20 0;
+#X connect 18 2 20 0;
+#X connect 18 3 20 0;
+#X connect 18 4 20 0;
+#X connect 18 5 20 0;
+#X connect 19 0 16 0;
+#X connect 20 0 21 1;
 #X connect 20 0 21 0;
-#X connect 21 0 22 0;
-#X connect 22 0 25 1;
-#X connect 23 0 20 0;
-#X connect 24 0 27 0;
-#X connect 25 0 24 0;
-#X connect 26 0 34 0;
-#X connect 27 0 26 0;
-#X connect 28 0 25 0;
-#X connect 29 0 15 1;
-#X connect 30 0 15 2;
-#X connect 31 0 28 0;
-#X connect 32 0 18 0;
-#X connect 33 0 15 3;
-#X connect 34 0 32 0;
-#X connect 36 0 35 0;
-#X connect 37 0 40 0;
-#X connect 38 0 37 1;
-#X connect 39 0 37 2;
-#X connect 40 0 41 0;
-#X connect 41 0 46 0;
-#X connect 41 1 46 0;
-#X connect 41 2 46 0;
-#X connect 41 3 46 0;
-#X connect 41 4 46 0;
-#X connect 41 5 46 0;
-#X connect 42 0 37 0;
-#X connect 43 0 37 3;
-#X connect 44 0 37 4;
-#X connect 45 0 37 5;
-#X connect 46 0 47 1;
-#X connect 46 0 47 0;
+#X connect 23 0 49 0;
+#X connect 24 0 16 1;
+#X connect 25 0 16 2;
+#X connect 26 0 16 3;
+#X connect 27 0 16 4;
+#X connect 28 0 16 5;
+#X connect 31 1 32 0;
+#X connect 31 1 33 0;
+#X connect 31 1 56 0;
+#X connect 35 0 54 0;
+#X connect 36 0 47 0;
+#X connect 37 0 39 0;
+#X connect 38 0 46 0;
+#X connect 39 0 50 0;
+#X connect 40 0 55 0;
+#X connect 41 0 49 1;
+#X connect 42 0 49 2;
+#X connect 43 0 49 3;
+#X connect 44 0 48 0;
+#X connect 45 0 34 0;
+#X connect 46 0 44 0;
+#X connect 47 0 35 0;
+#X connect 48 0 37 0;
+#X connect 49 0 38 0;
+#X connect 50 0 40 0;
+#X connect 50 1 53 0;
+#X connect 51 0 50 1;
+#X connect 52 0 40 0;
+#X connect 53 0 52 0;
+#X connect 54 0 38 1;
+#X connect 55 0 45 0;

Modified: trunk/src/classes3.cxx
==============================================================================
--- trunk/src/classes3.cxx (original)
+++ trunk/src/classes3.cxx Wed Feb  9 15:06:56 2011
@@ -94,12 +94,20 @@
 	int chans; /* number of channels */
 	t_sample **sam;
 	t_clock *clock;
-	\constructor (int chans=1) {
+	int size;
+	bool custom;
+	\constructor (int chans=1, int capacity=0) {
 		sigin = new t_inlet *[chans];
 		for (int i=0; i<chans; i++) sigin[i] = inlet_new((t_object *)bself,(t_pd *)bself,&s_signal,&s_signal);
 		this->chans = chans;
 		sam=0;
+		size=0;
 		clock = clock_new(bself,(void(*)())clock_bang_);
+		custom = !!capacity;
+		if (custom) {
+			if ((capacity&-capacity) != capacity) RAISE("capacity must be a power of two (or zero for auto)");
+			blah=new Grid(Dim(capacity,chans),float32_e);
+		}
 	}
 	void clock_bang () {
 		GridOut go(this,0,blah->dim,blah->nt);
@@ -109,8 +117,9 @@
 	~GridFromTilde () {clock_free(clock); delete[] sigin; if (sam) delete[] sam;}
 	void perform (int n) {
 		float32 *data = (float32 *)*blah;
-		for (int i=0; i<n; i++) for (int j=0; j<chans; j++) data[i*chans+j]=sam[j][i];
-		clock_delay(clock,0);
+		for (int i=0; i<n; i++, size=(size+1)&(blah->dim[0]-1))
+			for (int j=0; j<chans; j++) data[size*chans+j]=sam[j][i];
+		if (!size) clock_delay(clock,0);
 	}
 	static t_int *perform_ (t_int *w) {((GridFromTilde *)w[1])->perform(int(w[2])); return w+3;}
 	void dsp (t_signal **sp) {
@@ -118,7 +127,7 @@
 		sam = new t_sample *[chans];
 		for (int i=0; i<chans; i++) sam[i] = sp[i]->s_vec;
 		dsp_add(perform_,2,this,sp[0]->s_n);
-		blah=new Grid(Dim(sp[0]->s_n,chans),float32_e);
+		if (!custom) blah=new Grid(Dim(sp[0]->s_n,chans),float32_e);
 	}
 	static void dsp_ (BFObject *bself, t_signal **sp) {((GridFromTilde *)bself->self)->dsp(sp);}
 };



More information about the Gridflow-cvs mailing list