aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cyclone/hammer/funbuff.c6
-rw-r--r--cyclone/sickle/cycle.c39
-rw-r--r--doc/help/cyclone/cycle~-help.pd264
3 files changed, 180 insertions, 129 deletions
diff --git a/cyclone/hammer/funbuff.c b/cyclone/hammer/funbuff.c
index b5a8dbd..f192896 100644
--- a/cyclone/hammer/funbuff.c
+++ b/cyclone/hammer/funbuff.c
@@ -339,7 +339,7 @@ static void funbuff_dump(t_funbuff *x)
}
/* CHECKME if pointer is updated */
-static void funbuff_dointerp(t_funbuff *x, t_floatarg f, int vsz, t_float *vec)
+static void funbuff_dointerp(t_funbuff *x, t_floatarg f, int vsz, t_word *vec)
{
t_hammernode *np1;
int trunc = (int)f;
@@ -372,7 +372,7 @@ static void funbuff_dointerp(t_funbuff *x, t_floatarg f, int vsz, t_float *vec)
return;
}
vec += vndx;
- frac = *vec + (vec[1] - *vec) * vfrac;
+ frac = vec[0].w_float + (vec[1].w_float - vec[0].w_float) * vfrac;
}
value +=
(HAMMERNODE_GETFLOAT(np2) - HAMMERNODE_GETFLOAT(np1)) * frac;
@@ -392,7 +392,7 @@ static void funbuff_interp(t_funbuff *x, t_floatarg f)
static void funbuff_interptab(t_funbuff *x, t_symbol *s, t_floatarg f)
{
int vsz;
- t_float *vec;
+ t_word *vec;
if (vec = vefl_get(s, &vsz, 0, (t_pd *)x))
{
if (vsz > 2)
diff --git a/cyclone/sickle/cycle.c b/cyclone/sickle/cycle.c
index b88c13e..8acb364 100644
--- a/cyclone/sickle/cycle.c
+++ b/cyclone/sickle/cycle.c
@@ -31,24 +31,37 @@ static void cycle_gettable(t_cycle *x)
if (x->x_name)
{
int tabsize = 0;
- t_float *table = vefl_get(x->x_name, &tabsize, 1, (t_pd *)x);
+ t_word *table = vefl_get(x->x_name, &tabsize, 1, (t_pd *)x);
/* CHECKED buffer is copied */
if (table)
{
- int indx = x->x_offset + CYCLE_TABSIZE;
- t_float *ptr = x->x_usertable + CYCLE_TABSIZE;
- if (indx == tabsize)
+ int tablePtr;
+ int samplesFromTable = tabsize - x->x_offset;
+ int samplesToCopy = samplesFromTable < CYCLE_TABSIZE ?
+ samplesFromTable : CYCLE_TABSIZE;
+
+// post("samplesFromTable: %d, samplesToCopy: %d, tabsize: %d",
+// samplesFromTable, samplesToCopy, tabsize);
+ // copy the internal table from the external one as far as
+ // its size permits and fill the rest with zeroes.
+ for (tablePtr = 0; tablePtr < CYCLE_TABSIZE; tablePtr++)
{
- *ptr-- = *table;
- indx--;
- }
- if (indx < tabsize)
- {
- table += indx;
- indx -= x->x_offset;
- while (indx--) *ptr-- = *table--;
- x->x_table = x->x_usertable;
+ if (samplesToCopy > 0)
+ {
+ x->x_usertable[tablePtr] =
+ table[tablePtr + x->x_offset].w_float;
+ samplesToCopy--;
+ }
+ else
+ {
+ x->x_usertable[tablePtr] = 0;
+ }
}
+ // the 513th sample
+ x->x_usertable[tablePtr] = (samplesFromTable > 0) ?
+ table[x->x_offset + CYCLE_TABSIZE].w_float : 0;
+
+ x->x_table = x->x_usertable;
/* CHECKED else no complaint */
}
}
diff --git a/doc/help/cyclone/cycle~-help.pd b/doc/help/cyclone/cycle~-help.pd
index 4f9d4b0..e98ba61 100644
--- a/doc/help/cyclone/cycle~-help.pd
+++ b/doc/help/cyclone/cycle~-help.pd
@@ -1,5 +1,5 @@
-#N canvas 617 83 567 530 10;
-#X obj 0 653 cnv 15 552 21 empty empty empty 20 12 0 14 -233017 -33289
+#N canvas 536 79 567 530 10;
+#X obj 0 706 cnv 15 552 21 empty empty empty 20 12 0 14 -233017 -33289
0;
#X obj 0 339 cnv 3 550 3 empty empty inlets 8 12 0 13 -228856 -1 0
;
@@ -22,139 +22,177 @@
Wilkes for Pd-extended 0.42 to conform to the PDDP template. Alex Cleveland
updated this patch for Pd-l2ork version 2013.05.28. Fred Jan Kraan
adapted the patch to pd-extended 2015-02-02;
-#X restore 500 655 pd META;
-#X obj 0 448 cnv 3 550 3 empty empty outlets 8 12 0 13 -228856 -1 0
+#X restore 500 708 pd META;
+#X obj 0 460 cnv 3 550 3 empty empty outlets 8 12 0 13 -228856 -1 0
;
-#X obj 0 485 cnv 3 550 3 empty empty arguments 8 12 0 13 -228856 -1
+#X obj 0 497 cnv 3 550 3 empty empty arguments 8 12 0 13 -228856 -1
0;
-#X obj 0 578 cnv 3 550 3 empty empty more_info 8 12 0 13 -228856 -1
+#X obj 0 577 cnv 3 550 3 empty empty more_info 8 12 0 13 -228856 -1
0;
#N canvas 302 575 428 109 Related_objects 0;
#X obj 0 0 cnv 15 425 20 empty empty empty 3 12 0 14 -204280 -1 0;
#X text 6 1 Related Objects;
-#X restore 207 655 pd Related_objects;
-#X obj 78 349 cnv 17 3 33 empty empty 0 5 9 0 16 -228856 -162280 0
+#X restore 207 708 pd Related_objects;
+#X obj 78 349 cnv 17 3 50 empty empty 0 5 9 0 16 -228856 -162280 0
;
-#X obj 78 401 cnv 17 3 33 empty empty 1 5 9 0 16 -228856 -162280 0
+#X obj 78 417 cnv 17 3 33 empty empty 1 5 9 0 16 -228856 -162280 0
;
#X obj 0 0 cnv 15 552 40 empty empty cycle~ 3 12 0 18 -204280 -1 0
;
#X text 12 23 Table-lookup oscillator or function generator;
-#X obj 380 173 phasor~ 660;
-#X text 27 145 frequency input (float or signal);
-#X text 296 146 phase input (float or signal);
-#X text 296 127 2 Driven by phase only (frequency is 0):;
-#X text 27 128 1 argument sets frequency (default 0);
#X text 110 350 float;
#X text 110 365 signal;
-#X text 165 356 - set frequnecy;
-#X obj 78 457 cnv 17 3 17 empty empty 0 5 9 0 16 -228856 -162280 0
+#X obj 78 469 cnv 17 3 17 empty empty 0 5 9 0 16 -228856 -162280 0
;
-#X text 110 399 float;
-#X text 110 414 signal;
-#X text 165 405 - drive by phase only (frequency is 0);
-#X text 110 456 signal;
-#X text 165 454 - the signal with given frequency or phase;
-#X text 109 522 buffer;
-#X text 165 522 - can give function stored in buffer object;
+#X text 110 415 float;
+#X text 110 430 signal;
+#X text 110 468 signal;
+#X text 165 466 - the signal with given frequency or phase;
+#X text 109 534 buffer;
#X obj 504 4 cycle~;
-#X text 28 52 cycle~ uses a stored table of 512 samples to generate
-functions. By default it uses a sine wave \, but you can give it a
-function stored in a buffer~ object.;
-#X text 97 595 Symbol argument sets name of table to play from. Additional
+#X text 97 598 Symbol argument sets name of table to play from. Additional
int argument after that sets sample offset into the table (default
0);
-#X obj 169 278 output~;
-#X obj 200 242 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+#X obj 174 290 output~;
+#X obj 205 254 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
-#X obj 168 242 *~ 0;
-#X obj 228 242 *~ 0;
-#X obj 260 242 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+#X obj 173 254 *~ 0;
+#X obj 233 254 *~ 0;
+#X obj 265 254 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
-#X obj 33 179 cyclone/cycle~ 440;
-#X obj 300 207 cyclone/cycle~;
-#N canvas 1132 443 431 349 more 0;
-#X obj 248 109 loadbang;
-#X msg 248 134 22.5;
-#X text 242 32 4 Using your function;
-#X msg 49 78 437;
-#X obj 49 53 loadbang;
-#X floatatom 49 103 0 0 0 0 - - -;
-#X msg 49 128 \$1 400;
-#X obj 49 153 line~;
-#N canvas 277 196 183 210 generate-buffer~ 0;
-#X obj 49 36 loadbang;
-#N canvas 48 107 152 247 sawtooth 0;
-#X obj 91 151 - 2;
-#X obj 91 126 * 2;
-#X obj 33 125 * 2;
-#X obj 33 101 split 0 0.5;
-#X obj 33 65 / 512;
-#X obj 33 39 inlet;
-#X obj 33 214 outlet;
-#X obj 2 1 cnv 15 425 20 empty empty empty 3 12 0 14 -204280 -1 0;
-#X connect 0 0 6 0;
-#X connect 1 0 0 0;
-#X connect 2 0 6 0;
-#X connect 3 0 2 0;
-#X connect 3 1 1 0;
-#X connect 4 0 3 0;
-#X connect 5 0 4 0;
-#X restore 94 126 pd sawtooth;
-#X obj 49 149 pack 0 0;
-#X obj 49 104 t f f;
-#X obj 49 82 line 0 1;
-#X msg 49 62 0 \, 512 512;
-#X obj 49 170 peek~ buffsky;
+#X obj 38 198 cyclone/cycle~ 440;
+#N canvas 697 319 444 567 more 0;
+#X msg 49 80 437;
+#X obj 49 55 loadbang;
+#X floatatom 49 105 0 0 0 0 - - -;
+#X msg 49 130 \$1 400;
+#X obj 49 155 line~;
+#N canvas 342 552 286 323 generate-buffer~ 0;
+#X obj 48 38 loadbang;
#X obj 2 0 cnv 15 425 20 empty empty empty 3 12 0 14 -204280 -1 0;
#X text 5 1 Buffer contents generator;
-#X connect 0 0 5 0;
-#X connect 1 0 2 1;
-#X connect 2 0 6 0;
-#X connect 3 0 2 0;
-#X connect 3 1 1 0;
-#X connect 4 0 3 0;
-#X connect 5 0 4 0;
-#X restore 247 54 pd generate-buffer~;
-#X obj 247 75 table buffsky 512;
-#X text 44 30 3 Using frequency input;
-#X obj 156 254 output~;
-#X obj 187 219 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
+#X msg 93 130 0;
+#X text 93 57 fill the table;
+#X obj 54 185 *~;
+#X obj 123 157 line~;
+#X obj 48 79 t b b b b;
+#X obj 54 129 line~;
+#X obj 54 157 osc~;
+#X obj 48 219 tabwrite~ \$0-buffsky;
+#X msg 54 103 880 0 \, 55 250;
+#X msg 123 130 0.1 0 \, 1 250;
+#X connect 0 0 7 0;
+#X connect 3 0 9 1;
+#X connect 5 0 10 0;
+#X connect 6 0 5 1;
+#X connect 7 0 10 0;
+#X connect 7 1 11 0;
+#X connect 7 2 3 0;
+#X connect 7 3 12 0;
+#X connect 8 0 9 0;
+#X connect 9 0 5 0;
+#X connect 11 0 8 0;
+#X connect 12 0 6 0;
+#X restore 284 289 pd generate-buffer~;
+#X obj 139 285 output~;
+#X obj 170 250 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
1;
-#X obj 155 218 *~ 0;
-#X obj 215 218 *~ 0;
-#X obj 247 219 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
+#X obj 138 249 *~ 0;
+#X obj 198 249 *~ 0;
+#X obj 230 250 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 1
1;
-#X obj 49 178 cyclone/cycle~;
+#X obj 49 191 cyclone/cycle~;
#X obj 2 3 cnv 15 425 20 empty empty empty 3 12 0 14 -204280 -1 0;
#X text 5 4 Frequency input and using a lookup table;
-#X obj 248 160 cyclone/cycle~ buffsky 100;
-#X connect 0 0 1 0;
-#X connect 1 0 19 0;
-#X connect 3 0 5 0;
-#X connect 4 0 3 0;
-#X connect 5 0 6 0;
-#X connect 6 0 7 0;
-#X connect 7 0 16 0;
-#X connect 12 0 13 1;
-#X connect 13 0 11 0;
-#X connect 13 0 11 1;
-#X connect 14 0 11 0;
-#X connect 14 0 11 1;
-#X connect 15 0 14 1;
-#X connect 16 0 13 0;
-#X connect 19 0 14 0;
-#X restore 321 289 pd more examples;
-#X text 108 504 float;
-#X text 108 541 float;
-#X text 165 541 - sample offset (optional);
-#X text 165 504 - default frequency (optional);
-#X connect 11 0 36 1;
-#X connect 31 0 32 1;
-#X connect 32 0 30 0;
-#X connect 32 0 30 1;
-#X connect 33 0 30 0;
-#X connect 33 0 30 1;
-#X connect 34 0 33 1;
-#X connect 35 0 32 0;
-#X connect 36 0 33 0;
+#X text 44 32 frequency input;
+#X text 240 33 scroll through buffer;
+#X obj 284 310 table \$0-buffsky 10240;
+#X obj 283 93 f \$0;
+#X obj 244 94 f \$0;
+#X obj 283 55 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
+-1;
+#X obj 244 55 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
+-1;
+#X obj 244 191 cyclone/cycle~ 110 \$0-buffsky;
+#N canvas 0 50 450 250 (subpatch) 0;
+#X array \$0-output 512 float 2;
+#X coords 0 1 512 -1 410 140 1 0 0;
+#X restore 9 416 graph;
+#X obj 261 249 tabwrite~ \$0-output;
+#X obj 283 73 t b b;
+#X obj 244 74 t b b;
+#X msg 283 116 set \$1-buffsky 0;
+#X msg 244 139 set \$1-buffsky 9150;
+#X connect 0 0 2 0;
+#X connect 1 0 0 0;
+#X connect 2 0 3 0;
+#X connect 3 0 4 0;
+#X connect 4 0 11 0;
+#X connect 7 0 8 1;
+#X connect 8 0 6 0;
+#X connect 8 0 6 1;
+#X connect 9 0 6 0;
+#X connect 9 0 6 1;
+#X connect 10 0 9 1;
+#X connect 11 0 8 0;
+#X connect 17 0 26 0;
+#X connect 18 0 27 0;
+#X connect 19 0 24 0;
+#X connect 20 0 25 0;
+#X connect 21 0 9 0;
+#X connect 21 0 23 0;
+#X connect 24 0 17 0;
+#X connect 24 1 23 0;
+#X connect 25 0 18 0;
+#X connect 25 1 23 0;
+#X connect 26 0 21 0;
+#X connect 27 0 21 0;
+#X restore 427 314 pd more examples;
+#X text 108 516 float;
+#X text 108 553 float;
+#X text 14 52 cycle~ uses a stored table of 512 samples to generate
+functions. By default it uses a sine wave \, but you can give it a
+wavetable stored in an array or table.;
+#X text 27 108 basic usage internal cos table;
+#X obj 305 197 cyclone/cycle~ 440;
+#X text 296 107 phase modulation;
+#X text 110 383 set s f;
+#X text 166 381 - set array and offset within array;
+#X text 166 355 - scan frequency;
+#X text 165 516 - default frequency;
+#X obj 404 73 cnv 15 120 95 empty empty empty 20 12 0 14 -166433 -66577
+0;
+#X obj 411 114 osc~;
+#X obj 411 136 *~;
+#X msg 474 117 \$1 10;
+#X obj 474 137 line~;
+#X obj 305 147 nbx 4 14 0 10000 0 1 empty frequency Frequency 0 -8
+0 10 -232576 -1 -1 369 256;
+#X obj 411 93 nbx 4 14 0 1000 0 1 empty moduladora Frequency 0 -8 0
+10 -204800 -1 -1 4 256;
+#X obj 474 94 nbx 4 14 0 10 0 1 empty indice Depth 0 -8 0 10 -204786
+-1 -1 5 256;
+#X text 404 55 Modulation;
+#X text 165 421 - phase input;
+#X text 97 643 When used with an external array or table \, the cycle~
+object attempts to read 512 samples. If not enough samples are available
+\, due to a too slall array or a to great offset \, the remainder is
+filled with zero.;
+#X text 165 534 - can give function stored in buffer object (array
+\, table);
+#X text 165 553 - set offset within the external array;
+#X connect 22 0 23 1;
+#X connect 23 0 21 0;
+#X connect 23 0 21 1;
+#X connect 24 0 21 0;
+#X connect 24 0 21 1;
+#X connect 25 0 24 1;
+#X connect 26 0 23 0;
+#X connect 32 0 24 0;
+#X connect 39 0 40 0;
+#X connect 40 0 32 1;
+#X connect 41 0 42 0;
+#X connect 42 0 40 1;
+#X connect 43 0 32 0;
+#X connect 44 0 39 0;
+#X connect 45 0 41 0;