Forums > MaxMSP

Yet another time-stretch thread

March 25, 2008 | 8:39 pm

I was hoping if anyone could shed any light on a specific problem I’m having with a (sort-of) granular time-stretcher currently under construction.

The idea was to build something similar to Nathan Wolek’s gran.groove.file~ but without externals or the pitch-shifting option his has. The patch below features one ‘voice’ and a sampling offset calculator.

Things go awry when I have more than one voice. Remembering to offset the phase on the lower phasor~s, I still get flanging ‘artifacts’ at higher playback speeds, and buzzes at lower ones. I’m sure it has something to do with the signal rate snapshot~/ edge~ combo, but can’t figure out why that would be.

Any help at solving this would be much appreciated!

____________________

max v2;
#N vpatcher 11 61 593 553;
#P window setfont "Sans Serif" 9.;
#N vpatcher 10 59 493 399;
#P origin 0 -7;
#P window setfont "Sans Serif" 9.;
#P window linecount 0;
#P newex 13 41 44 196617 del 100;
#P window linecount 1;
#P newex 60 239 87 196617 loadmess 0.3133;
#P newex 387 171 69 196617 loadmess 0.5;
#P newex 215 172 81 196617 loadmess 0.125;
#P newex 135 83 69 196617 loadmess 0.5;
#P newex 13 21 48 196617 loadbang;
#P newex 43 193 65 196617 minimum 0.5;
#N counter 2 0 256;
#X flags 0 0;
#P newobj 43 127 81 196617 counter 2 0 256;
#P newex 43 149 33 196617 * 1.1;
#P newex 43 171 38 196617 / 512.;
#P flonum 135 105 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 135 127 95 196617 expr 1.0/(1.0-$f1);
#P flonum 387 193 35 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 215 194 40 9 0. 1. 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 43 215 355 196617 expr exp((-1*($f1-$f3)*($f1-$f3))/(2*$f2*$f2))/($f2*sqrt(2*3.1416));
#P comment 422 193 28 196617 peak;
#P flonum 60 260 49 9 0. 0 1 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 43 279 27 196617 * 0.;
#P newex 13 105 40 196617 t i i b;
#P newex 13 61 43 196617 Uzi 512;
#N counter 0 0 511;
#X flags 0 0;
#P newobj 13 83 81 196617 counter 0 0 511;
#P newex 13 301 55 196617 peek~ env;
#P window linecount 2;
#P comment 269 108 118 196617 thieved from Nathan Wolek’s granular toolkit;
#P connect 17 0 22 0;
#P connect 22 0 3 0;
#P connect 3 0 2 0;
#P connect 2 0 4 0;
#P connect 4 0 1 0;
#P fasten 5 0 1 1 48 298 40 298;
#P connect 4 2 15 0;
#P connect 15 0 14 0;
#P connect 14 0 13 0;
#P connect 13 0 16 0;
#P connect 16 0 8 0;
#P connect 8 0 5 0;
#P connect 21 0 6 0;
#P connect 6 0 5 1;
#P fasten 11 0 14 1 140 146 71 146;
#P connect 18 0 12 0;
#P connect 12 0 11 0;
#P connect 19 0 9 0;
#P connect 9 0 8 1;
#P connect 20 0 10 0;
#P connect 10 0 8 2;
#P pop;
#P newobj 79 43 62 196617 p envmaker;
#P newex 330 309 29 196617 sig~;
#P newex 74 123 60 196617 loadmess 1;
#P newex 140 145 29 196617 t b f;
#P flonum 74 145 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 121 173 29 196617 * 0.;
#P newex 187 194 29 196617 sig~;
#P newex 140 123 49 196617 !/ 1000.;
#P newex 121 246 64 196617 snapshot~ 1;
#P newex 121 219 76 196617 *~ 0.;
#P newex 121 195 46 196617 phasor~;
#P newex 330 285 27 196617 f;
#P newex 330 254 36 196617 edge~;
#P newex 330 232 51 196617 >=~ 0.95;
#P newex 330 335 62 196617 +~;
#P newex 382 178 66 196617 loadmess 10;
#P newex 382 395 72 196617 *~ 0.;
#P newex 444 371 59 196617 cycle~ env;
#P newex 382 232 47 196617 *~ 100.;
#P newex 382 203 46 196617 phasor~;
#P newex 382 371 59 196617 play~ click;
#P toggle 368 432 15 0;
#P newex 382 454 31 196617 dac~;
#P newex 4 42 67 196617 append 0 0 1;
#P message 4 22 43 196617 replace;
#P newex 62 86 103 196617 info~ click;
#P newex 78 63 105 196617 buffer~ env 11.6099;
#P newex 4 63 68 196617 buffer~ click;
#P window linecount 3;
#P comment 451 184 77 196617 phasor~ playing ten ‘grains’ per sec;
#P window linecount 2;
#P comment 505 367 59 196617 quasi-gauss window;
#P window linecount 6;
#P comment 286 253 44 196617 ensures grain offset added at end of grain;
#P window linecount 2;
#P comment 197 120 51 196617 period to freq.;
#P window linecount 1;
#P comment 42 147 31 196617 speed;
#P window linecount 2;
#P comment 10 176 109 196617 phasor~ ramps over sample length*speed…;
#P comment 29 216 90 196617 …* by sample length gives offset;
#P window linecount 1;
#P comment 51 23 116 196617 load your favourite sf!;
#P user panel 282 167 285 249;
#X brgb 255 245 207;
#X frgb 255 255 255;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P user panel 9 112 241 160;
#X brgb 192 218 255;
#X frgb 255 255 255;
#X border 1;
#X rounded 0;
#X shadow 0;
#X done;
#P connect 13 0 14 0;
#P connect 14 0 10 0;
#P connect 10 1 12 0;
#P connect 35 0 33 0;
#P connect 33 0 32 0;
#P connect 34 0 32 0;
#P connect 32 0 27 0;
#P connect 27 0 28 0;
#P connect 28 0 29 0;
#P connect 12 6 30 0;
#P connect 30 0 34 0;
#P connect 34 1 32 1;
#P fasten 12 6 31 0 145 115 192 115;
#P connect 31 0 28 1;
#P fasten 18 0 24 0 387 226 335 226;
#P connect 24 0 25 0;
#P connect 25 0 26 0;
#P connect 26 0 36 0;
#P connect 36 0 23 0;
#P fasten 29 0 26 1 126 277 352 277;
#P connect 22 0 18 0;
#P connect 18 0 19 0;
#P connect 19 0 23 1;
#P fasten 23 0 17 0 335 359 387 359;
#P connect 17 0 21 0;
#P connect 16 0 15 0;
#P connect 21 0 15 0;
#P connect 21 0 15 1;
#P connect 20 0 21 1;
#P fasten 18 0 20 1 387 225 498 225;
#P pop;


March 26, 2008 | 9:47 am

On 25 Mar 2008, at 20:39, George Dennis wrote:
> … The patch below features one ‘voice’ and a sampling offset
> calculator.
>
> Things go awry when I have more than one voice.

well, hard to tell what’s wrong if you don’t provide how you set up
the other voices.

> Remembering to offset the phase on the lower phasor~s, I still get
> flanging ‘artifacts’ at higher playback speeds, and buzzes at lower
> ones. I’m sure it has something to do with the signal rate
> snapshot~/ edge~ combo, but can’t figure out why that would be.

in your case it’s pretty easy to avoid going into max-event-land.
simply use a [sah~] object to sample the playback position everytime
the grainphasor snaps back to zero.
there are already tons of examples showing how to do it in the archives.

vb


March 26, 2008 | 10:33 am


Viewing 3 posts - 1 through 3 (of 3 total)