clicks using phasor~ and wave~

Jonathan Green's icon

Hello all.

I'm trying to build a live sampler using phasor~ connected to wave~ as the
playback engine. That works fine however....

I want to have random access to the buffer, but I always get clicks when I
jump to different regions. Is it possible to add some kind of interpolation
to remove these clicks?

THanks a lot.

Jonathan

justin's icon

the trick is to use a windowing system to fade the amplitude up / down at the beginning and end of each sample slice. this technique is also used in granular synthesis, and needs to be quite a short duration fades so that it doesn't alter the original material too much. altho it really depends what kind of sound file you use... drones, beats, etc...

j

Owen Green's icon

Hi Jonathan,

Shouldn't be that complex if you're already using phasor~ to read
segments from your buffer - just use the same phasor~ to drive a window
function that you multiply your buffer output by.

--
Owen

Jonathan Green wrote:
> Hi Justin,
>
> Good idea - I'll give it a try. Sounds a bit complex though. No one-object
> solution for this one...

Peter McCulloch's icon

You should use sah~ to make sure that you're only changing at the start
and end of a wave.

Max Patch
Copy patch and select New From Clipboard in Max.

On May 14, 2007, at 9:41 AM, Jonathan Green wrote:

> I can see what you mean. But.... Perhaps, I should have enclosed this
> patch in my first message, but here it is. I've eliminated clicks for
> the looping. However, whenever I change the start/end loop points I
> get clicks. It is these clicks I'm trying to remove... I could try and
> use a second-level windowing function for the scrubbing, but surely
> that would be a clunky solution?
>
> max v2;
> #N vpatcher 502 257 1409 962;
> #P origin -72 0;
> #P window setfont "Sans Serif" 9.;
> #P comment 305 484 29 196617 stop;
> #P message 335 482 14 196617 0;
> #P message 78 175 14 196617 1;
> #N vpreset 1;
> #X append 1 1 48 172 734 flonum float 0. ; 40 514 581 flonum float
> 0.28 ; 47 172 578 flonum float 2344.943359 ; 46 172 469 flonum float
> 0. ; 45 172 334 flonum float 0. ;;
> #P preset 78 197 47 27;
> #P newex 24 141 48 196617 loadbang;
> #N vpatcher 119 199 680 466;
> #P window setfont "Sans Serif" 9.;
> #P newex 185 151 27 196617 / 2.;
> #P newex 450 149 27 196617 / 2.;
> #P newex 294 118 105 196617 scale 0 127 0. 1000.;
> #P newex 50 118 105 196617 scale 0 127 0. 1000.;
> #P inlet 501 30 15 0;
> #P inlet 50 30 15 0;
> #P inlet 185 30 15 0;
> #P inlet 294 30 15 0;
> #P inlet 450 30 15 0;
> #P outlet 50 175 15 0;
> #P outlet 185 175 15 0;
> #P outlet 294 175 15 0;
> #P outlet 450 175 15 0;
> #P newex 185 130 30 196617 - 64;
> #P newex 450 128 30 196617 - 64;
> #P connect 9 0 11 0;
> #P connect 11 0 5 0;
> #P connect 10 0 11 4;
> #P connect 8 0 1 0;
> #P connect 1 0 14 0;
> #P connect 14 0 4 0;
> #P connect 7 0 12 0;
> #P connect 12 0 3 0;
> #P connect 10 0 12 4;
> #P connect 6 0 0 0;
> #P connect 0 0 13 0;
> #P connect 13 0 2 0;
> #P pop;
> #P newobj 424 124 242 196617 p convertfrommidi;
> #P comment 741 158 69 196617 end fine (ms);
> #P comment 588 158 49 196617 end (ms);
> #P comment 477 159 77 196617 start fine (ms);
> #P flonum 734 172 45 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 578 172 45 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 469 172 45 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 334 172 45 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #N vpatcher 10 59 347 527;
> #P window setfont "Sans Serif" 9.;
> #P message 151 336 37 196617 $1 50;
> #P newex 151 358 40 196617 line 0.;
> #P message 34 329 37 196617 $1 50;
> #P newex 34 351 40 196617 line 0.;
> #P flonum 34 153 56 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P comment 91 153 33 196617 start;
> #P newex 66 77 29 196617 t b f;
> #P newex 34 106 27 196617 f;
> #P newex 34 128 61 196617 + 0.;
> #P newex 243 241 29 196617 t b f;
> #P newex 151 291 27 196617 f;
> #P newex 151 313 43 196617 + 0.;
> #P newex 34 180 40 196617 t f b f;
> #P newex 151 236 27 196617 + 0.;
> #P flonum 151 257 56 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P inlet 34 50 15 0;
> #P inlet 66 50 15 0;
> #P inlet 151 50 15 0;
> #P inlet 243 50 15 0;
> #P outlet 34 393 15 0;
> #P outlet 151 386 15 0;
> #P connect 5 0 13 0;
> #P fasten 14 0 13 0 71 100 39 100;
> #P connect 13 0 12 0;
> #P connect 12 0 16 0;
> #P connect 16 0 8 0;
> #P connect 8 0 18 0;
> #P connect 18 0 17 0;
> #P connect 17 0 1 0;
> #P connect 4 0 14 0;
> #P connect 14 1 12 1;
> #P connect 3 0 7 0;
> #P lcolor 1;
> #P fasten 8 1 7 0 54 223 156 223;
> #P connect 7 0 6 0;
> #P fasten 11 0 10 0 248 281 156 281;
> #P connect 6 0 10 0;
> #P connect 10 0 9 0;
> #P connect 9 0 20 0;
> #P connect 20 0 19 0;
> #P connect 19 0 0 0;
> #P fasten 8 2 7 1 69 211 173 211;
> #P fasten 11 1 9 1 267 301 189 301;
> #P connect 2 0 11 0;
> #P pop;
> #P newobj 440 206 218 196617 p setlooppoints;
> #P newex 598 98 54 196617 ctlin 10 2;
> #N vpatcher 1129 121 1681 650;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 106 173 27 196617 f;
> #P newex 139 121 29 196617 t b f;
> #P newex 49 291 27 196617 *~;
> #P newex 132 205 30 196617 !- 0.;
> #P newex 49 318 50 196617 +~;
> #P window linecount 0;
> #P newex 323 116 30 196617 !- 1.;
> #P newex 266 189 70 196617 trapezoid~;
> #B color 5;
> #P newex 52 376 129 196617 *~;
> #P newex 52 354 63 196617 wave~ buf1;
> #P inlet 40 76 15 0;
> #P inlet 293 87 13 0;
> #P inlet 137 40 15 0;
> #P inlet 113 40 15 0;
> #P outlet 52 398 15 0;
> #P connect 4 0 11 0;
> #P connect 11 0 9 0;
> #P connect 9 0 5 0;
> #P connect 5 0 6 0;
> #P connect 6 0 0 0;
> #P connect 10 0 11 1;
> #P connect 13 0 9 1;
> #P connect 12 0 13 0;
> #P connect 1 0 13 0;
> #P connect 13 0 10 0;
> #P connect 2 0 12 0;
> #P connect 12 1 10 1;
> #P connect 7 0 6 1;
> #P connect 4 0 7 0;
> #P connect 3 0 7 1;
> #P fasten 3 0 8 0 298 108 328 108;
> #P connect 8 0 7 2;
> #P pop;
> #P newobj 482 587 109 196617 p playloopwithwindow;
> #N vpatcher 343 98 1022 660;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 0;
> #P newex 99 166 27 196617 f;
> #P newex 123 121 29 196617 t b f;
> #P flonum 440 377 48 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 1;
> #P newex 448 345 27 196617 + 0.;
> #P flonum 428 307 48 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 0;
> #P newex 425 276 29 196617 * 0.;
> #P flonum 401 64 48 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 507 205 48 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P window linecount 1;
> #P newex 501 179 30 196617 !- 0.;
> #P flonum 519 148 48 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 468 148 48 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 42 284 27 196617 *~;
> #P newex 125 198 30 196617 !- 0.;
> #P newex 42 311 50 196617 +~;
> #P newex 320 227 30 196617 !- 1.;
> #P newex 260 264 70 196617 trapezoid~;
> #B color 5;
> #P newex 42 389 127 196617 *~;
> #P newex 40 368 63 196617 wave~ buf1;
> #P inlet 40 76 15 0;
> #P inlet 290 79 13 0;
> #P inlet 141 75 15 0;
> #P inlet 98 75 15 0;
> #P outlet 40 412 15 0;
> #P connect 9 0 5 0;
> #P connect 6 0 0 0;
> #P connect 4 0 11 0;
> #P connect 11 0 9 0;
> #P connect 5 0 6 0;
> #P connect 10 0 11 1;
> #P connect 22 0 9 1;
> #P connect 1 0 22 0;
> #P connect 21 0 22 0;
> #P connect 2 0 21 0;
> #P connect 22 0 10 0;
> #P connect 21 1 10 1;
> #P connect 7 0 6 1;
> #P connect 4 0 7 0;
> #P connect 3 0 7 1;
> #P fasten 3 0 8 0 295 97 325 97;
> #P connect 8 0 7 2;
> #P connect 16 0 17 0;
> #P connect 17 0 18 0;
> #P connect 19 0 20 0;
> #P connect 15 0 17 1;
> #P connect 18 0 19 0;
> #P connect 12 0 19 1;
> #P connect 12 0 14 0;
> #P connect 14 0 15 0;
> #P connect 13 0 14 1;
> #P pop;
> #P newobj 358 588 109 196617 p playloopwithwindow;
> #P flonum 581 514 35 9 0. 0.5 3 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 358 619 134 196617 +~;
> #P newex 482 563 37 196617 %~ 1.;
> #P newex 482 540 40 196617 +~ 0.5;
> #P newex 656 98 63 196617 r bufsizems;
> #P newex 540 98 48 196617 ctlin 7 2;
> #P comment 553 473 23 196617 end;
> #P comment 455 473 33 196617 start;
> #P newex 424 98 48 196617 ctlin 7 1;
> #P comment 497 455 17 196617 %;
> #P comment 580 453 17 196617 %;
> #N vpatcher 20 74 412 391;
> #P outlet 34 235 15 0;
> #P window setfont "Sans Serif" 9.;
> #P window linecount 1;
> #P newex 34 155 49 196617 pak 0. 0.;
> #P newex 34 177 27 196617 - 0.;
> #P window linecount 0;
> #P newex 285 177 27 196617 / 0.;
> #P newex 134 122 63 196617 r bufsizems;
> #P newex 117 177 27 196617 / 0.;
> #P inlet 285 48 15 0;
> #P inlet 117 48 15 0;
> #P outlet 285 235 15 0;
> #P outlet 117 235 15 0;
> #P fasten 3 0 8 0 290 95 39 95;
> #P connect 8 0 7 0;
> #P connect 7 0 9 0;
> #P fasten 2 0 8 1 122 109 78 109;
> #P connect 2 0 4 0;
> #P lcolor 1;
> #P connect 4 0 0 0;
> #P connect 5 0 4 1;
> #P connect 3 0 6 0;
> #P lcolor 1;
> #P connect 6 0 1 0;
> #P fasten 5 0 6 1 139 158 307 158;
> #P pop;
> #P newobj 358 426 177 196617 p tomsforphasor;
> #P flonum 524 453 56 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P flonum 441 455 56 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 205 188 63 196617 s bufsizems;
> #P flonum 525 399 56 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P comment 583 399 92 196617 end;
> #P flonum 358 399 56 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P comment 416 399 92 196617 start;
> #P flonum 358 456 56 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P button 127 127 15 0;
> #P flonum 205 169 56 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
> #P message 24 210 47 196617 set buf1;
> #P user waveform~ 24 234 845 155 3 9;
> #W mode select;
> #W mouseoutput continuous;
> #W unit ms;
> #W grid 1000.;
> #W ticks 0;
> #W labels 0;
> #W vlabels 0;
> #W vticks 0;
> #W bpm 120. 4.;
> #W frgb 33 0 0;
> #W brgb 60 178 173;
> #W rgb2 0 95 255;
> #W rgb3 0 0 0;
> #W rgb4 0 0 0;
> #W rgb5 190 137 255;
> #W rgb6 100 100 100;
> #W rgb7 100 100 100;
> #P comment 201 208 92 196617 buffer length (ms);
> #P newex 127 147 105 196617 info~ buf1;
> #P newex 359 662 49 196617 dac~ 1 2;
> #P message 70 75 43 196617 replace;
> #P newex 70 104 67 196617 buffer~ buf1;
> #P newex 358 482 84 196617 expr 1000 / $f1;
> #P newex 358 508 46 196617 phasor~;
> #P comment 250 457 104 196617 selection length (ms);
> #P comment 617 514 129 196617 fade in/out % (up to 50%);
> #P comment 340 158 57 196617 start (ms);
> #P newex 482 98 54 196617 ctlin 10 1;
> #P user panel 575 506 178 31;
> #X brgb 162 253 109;
> #X frgb 0 0 0;
> #X border 0;
> #X rounded 0;
> #X shadow 0;
> #X done;
> #P user panel 319 155 501 39;
> #X brgb 162 253 109;
> #X frgb 0 0 0;
> #X border 0;
> #X rounded 0;
> #X shadow 0;
> #X done;
> #P user panel 63 68 68 28;
> #X brgb 162 253 109;
> #X frgb 0 0 0;
> #X border 0;
> #X rounded 0;
> #X shadow 0;
> #X done;
> #P window linecount 2;
> #P comment 223 44 170 196617 load a sound file , select loop points
> and play with midi faders;
> #P window linecount 1;
> #P comment 223 73 91 196617 jg , 10-May-2007;
> #P user panel 302 476 51 25;
> #X brgb 162 253 109;
> #X frgb 0 0 0;
> #X border 0;
> #X rounded 0;
> #X shadow 0;
> #X done;
> #P connect 53 0 18 0;
> #P connect 18 0 17 0;
> #P connect 13 0 12 0;
> #P fasten 53 0 55 0 29 163 83 163;
> #P connect 55 0 54 0;
> #P connect 12 1 20 0;
> #P connect 20 0 15 0;
> #P connect 15 6 19 0;
> #P connect 19 0 26 0;
> #P hidden connect 54 0 45 0;
> #P hidden connect 52 0 45 0;
> #P connect 17 2 23 0;
> #P connect 23 0 29 0;
> #P connect 29 0 21 0;
> #P connect 21 0 11 0;
> #P fasten 56 0 10 0 340 502 363 502;
> #P connect 11 0 10 0;
> #P connect 10 0 41 0;
> #P connect 41 0 39 0;
> #P connect 39 0 14 0;
> #P connect 27 0 41 1;
> #P lcolor 7;
> #P connect 39 0 14 1;
> #P connect 32 0 52 0;
> #P connect 28 0 41 2;
> #P lcolor 6;
> #P hidden connect 45 0 44 0;
> #P connect 44 0 17 2;
> #P connect 29 1 27 0;
> #P connect 40 0 41 3;
> #P lcolor 8;
> #P hidden connect 54 0 46 0;
> #P hidden connect 52 1 46 0;
> #P connect 6 0 52 1;
> #P fasten 10 0 37 0 363 531 487 531;
> #P connect 37 0 38 0;
> #P connect 38 0 42 0;
> #P connect 42 0 39 1;
> #P hidden connect 46 0 44 1;
> #P connect 27 0 42 1;
> #P lcolor 7;
> #P connect 29 2 28 0;
> #P connect 17 3 25 0;
> #P connect 25 0 29 1;
> #P connect 35 0 52 2;
> #P connect 28 0 42 2;
> #P lcolor 6;
> #P hidden connect 54 0 47 0;
> #P hidden connect 52 2 47 0;
> #P hidden connect 47 0 44 2;
> #P hidden connect 54 0 40 0;
> #P connect 40 0 42 3;
> #P lcolor 8;
> #P connect 43 0 52 3;
> #P hidden connect 48 0 44 3;
> #P connect 44 1 17 3;
> #P connect 36 0 52 4;
> #P hidden connect 54 0 48 0;
> #P hidden connect 52 3 48 0;
> #P pop;
>
>
>
>
>
>
>
> On 14/05/07, Owen Green wrote:
>>
>> Shouldn't be that complex if you're already using phasor~ to read
>> segments from your buffer - just use the same phasor~ to drive a
>> window
>> function that you multiply your buffer output by.
>>
>> --
>> Owen
>>
>> Jonathan Green wrote:
>> > Hi Justin,
>> >
>> > Good idea - I'll give it a try. Sounds a bit complex though. No
>> one-object
>> > solution for this one...
>>
>
>
>
> --
> Jonathan Green
> 0777 1680 497
>
www.petermcculloch.com

Peter McCulloch's icon

Here you go. One of the catches of using sah~ is that it is possible
for it to get stuck in a state where it can't poll. (this typically
happens with either freqs of 0 for the phasor or when you start and
stop audio. Here's ways around both of these problems, that also
solves the "double-down" problem that often happens when you're
changing polarity on the speed of the phasor~. There are faster ways,
but this is more accurate, plus it prevents you from reversing polarity
mid-cycle.

Peter McCulloch

Max Patch
Copy patch and select New From Clipboard in Max.

Rob Ramirez's icon

just got to say, that's a little nugget of gold of a patch.
i will be studying for some time.
many thanks peter.

-rob

redhexagonal's icon

you could also try a retrigger envelope and a short delay, like this

Max Patch
Copy patch and select New From Clipboard in Max.