( s.waitForBoot { ~buf1 = Buffer.read(s, "/home/lcoogan/snd/samples/freesound/vocals/ymaaela/333264__ymaaela__female-vocal-cut-ups-collage.mono.wav"); ~buf2 = Buffer.read(s, "/home/lcoogan/snd/samples/freesound/vocals/ymaaela/attribution/330909__ymaaela__discordant-clip.mono.wav"); SynthDef(\crossfadeBuf, { |out=0, buf1, buf2, crossfade=0, rate=1| var sig1 = PlayBuf.ar(1, buf1, rate * BufRateScale.kr(buf1), loop: 1); var sig2 = PlayBuf.ar(1, buf2, rate * BufRateScale.kr(buf2), loop: 1); var mix = XFade2.ar(sig1, sig2, (crossfade * 2) - 1); Out.ar(out, mix ! 2); }).add; s.sync; ~synth = Synth(\crossfadeBuf, [\buf1, ~buf1.bufnum, \buf2, ~buf2.bufnum]); // Create a routine to update crossfade randomly every ~1 second with smooth transitions Routine({ loop { var target = rrand(0.0, 1.0); // random target crossfade between 0 and 1 // Smoothly glide to the new target over 1 second ~synth.set(\crossfade, target, \lag, 1); 1.wait; // wait 1 second before choosing a new target } }).play; }; )