Wavetables, buffers, cycle, and the DSP chain

Jan 8, 2007 at 8:49am

Wavetables, buffers, cycle, and the DSP chain

Hello,
I created a simple wavetable-generator for sine functions with some parameters like power, amplitude, number of cycles, and cycle frequency and phase. It all works fine and there’s some interesting basic waveforms there. The problem is that when I peek~ a list of new values into the buffer~, the cycle~ won’t play those new values until I stop and restart the DSP. Is this unavoidable? Is there a workaround that avoids such a large discontinuity?

I thought about using multiple buffers, and maybe that’s the ticket, but I wanted to put it out there first.

Thanks–

–CJ

———————————

max v2;
#N vpatcher 11 43 778 533;
#P origin -19 3;
#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 472 25 144 9109513 Cycle frequency and phase;
#P window linecount 2;
#P comment 279 29 120 9109513 Number of cycles of sine function;
#P window linecount 1;
#P comment 283 355 154 9109513 Rotate display values;
#P window linecount 2;
#P comment 76 297 154 9109513 Set power of sine function ; set amplitude of function;
#P toggle 13 22 45 0;
#P window linecount 1;
#P newex 68 93 73 9109513 gate;
#P window setfont “Sans Serif” 14.;
#P flonum 632 25 58 14 0 0 0 139 0 0 0 108 117 255 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 627 48 73 9109513 cycle~;
#B color 2;
#P newex 245 448 49 9109513 t b b l;
#P newex 578 396 49 9109513 t i i;
#P newex 658 396 49 9109513 pack 1 1.;
#P message 578 423 50 9109513 fetch $1;
#P newex 579 366 43 9109513 uzi 256;
#P button 579 341 15 0;
#P button 14 72 46 0;
#P newex 668 71 73 9109513 t 1 0;
#P newex 266 61 43 9109513 t b i;
#P window setfont “Sans Serif” 14.;
#P flonum 470 43 58 14 0 0 0 139 0 0 0 108 117 255 222 222 222 0 0 0;
#P user gain~ 421 26 39 68 158 1 1.071519 7.94321 10.;
#P window setfont “Sans Serif” 9.;
#P newex 666 123 73 9109513 sel 32;
#P newex 667 96 73 9109513 key;
#P toggle 596 99 42 0;
#P newex 494 98 73 9109513 dac~;
#B color 2;
#P newex 322 84 58 9109513 % 512;
#P window setfont “Sans Serif” 14.;
#P flonum 258 85 58 14 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 323 62 59 14 1 0 1 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 420 428 132 9109513 peek~ wavetable_1;
#B color 2;
#P newex 420 396 132 9109513 buffer~ wavetable_1 5.8;
#B color 2;
#P newex 470 71 132 9109513 cycle~ wavetable_1;
#B color 2;
#P number 313 431 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 299 407 58 9109513 % 256;
#P window setfont “Sans Serif” 14.;
#P number 72 224 45 14 1 0 1 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 72 247 43 9109513 t b b i;
#P button 240 392 19 0;
#P window setfont “Sans Serif” 14.;
#P number 266 381 50 14 0 0 1 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 129 404 58 9109513 zl group 255;
#P newex 245 428 58 9109513 zl rot 0;
#P newex 146 250 43 9109513 t b b f;
#P window setfont “Sans Serif” 14.;
#P flonum 147 225 48 14 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont “Sans Serif” 9.;
#P newex 28 373 43 9109513 t i i;
#P newex 20 339 43 9109513 uzi 256;
#P button 21 265 15 0;
#P user multiSlider 244 152 476 184 -1. 1. 255 2937 15 1 0 2 0 0 0;
#M frgb 0 0 0;
#M brgb 255 255 255;
#M rgb2 127 127 127;
#M rgb3 0 0 0;
#M rgb4 37 52 91;
#M rgb5 74 105 182;
#M rgb6 112 158 18;
#M rgb7 149 211 110;
#M rgb8 187 9 201;
#M rgb9 224 62 37;
#M rgb10 7 114 128;
#P flonum 211 132 81 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 207 85 15 0;
#P newex 101 175 114 9109513 zmap 0 255 0. 6.283186;
#P newex 207 109 129 9109513 expr $f1 * 3.141593;
#P message 173 353 50 9109513 clear;
#P newex 102 344 49 9109513 pack 1 1.;
#P newex 55 275 137 9109513 expr pow(sin($f1) \, $i2) * $f3;
#N coll ;
#P newobj 129 375 92 9109513 coll;
#P newex 127 123 43 9109513 uzi 256;
#N counter 0 255;
#X flags 0 0;
#P newobj 127 148 72 9109513 counter 0 255;
#P button 94 118 28 0;
#P window linecount 4;
#P comment 66 25 190 9109513 If open — automatically turns dac off then on to reset cycle~ ; otherwise , graph is smoother , but need to turn off / on dac to hear new waveform;
#P connect 49 0 40 0;
#P connect 13 0 14 0;
#P connect 30 0 13 0;
#P connect 22 0 13 0;
#P connect 17 0 13 0;
#P connect 14 2 15 0;
#P connect 9 0 5 0;
#P connect 50 0 49 0;
#P connect 23 0 22 0;
#P connect 30 0 1 0;
#P connect 17 1 1 0;
#P connect 22 1 1 0;
#P connect 2 0 9 0;
#P connect 2 0 6 0;
#P connect 22 2 5 1;
#P connect 1 0 3 0;
#P connect 3 0 2 0;
#P connect 6 0 4 0;
#P connect 15 1 4 0;
#P connect 7 0 4 0;
#P connect 4 0 19 0;
#P connect 22 0 49 1;
#P connect 17 0 49 1;
#P connect 46 0 49 1;
#P connect 38 0 49 1;
#P connect 5 0 6 1;
#P connect 16 0 17 0;
#P connect 17 2 5 2;
#P connect 11 0 9 4;
#P connect 30 0 8 0;
#P connect 10 0 8 0;
#P connect 8 0 11 0;
#P connect 20 0 21 0;
#P connect 46 2 12 0;
#P connect 43 0 12 0;
#P connect 21 0 18 0;
#P connect 19 0 18 0;
#P connect 18 0 46 0;
#P connect 31 0 30 0;
#P connect 29 0 38 0;
#P connect 24 0 18 1;
#P connect 20 0 24 0;
#P connect 24 0 25 0;
#P connect 38 1 31 0;
#P connect 6 0 28 0;
#P connect 44 0 28 0;
#P connect 26 0 36 0;
#P connect 37 0 26 0;
#P connect 36 0 32 0;
#P connect 33 0 32 0;
#P connect 36 0 32 1;
#P connect 42 2 45 0;
#P connect 45 1 43 0;
#P connect 46 1 41 0;
#P connect 41 0 42 0;
#P connect 47 0 26 1;
#P connect 35 0 33 0;
#P connect 39 1 33 0;
#P connect 39 0 33 0;
#P connect 48 0 47 0;
#P connect 45 0 44 0;
#P connect 34 0 35 0;
#P connect 40 0 39 0;
#P connect 12 1 44 1;
#P pop;

#29549
Jan 8, 2007 at 8:55am

not sure, but try using the “set buffer” message to the cycle each time the waveform has changed…

there’s a similar problem with groove~, and doing this fixes it, i’d try,- but i’m a long way from my Max computer at the time..

#92595
Jan 8, 2007 at 9:45am

Fantastic — that’s way better than turning the DSP off and on. Much smoother.

I shoulda tried that… doh!

Thanks–

–CJ

#92596

You must be logged in to reply to this topic.