Crossfading Buffers with Select.ar

Hello Everyone,

I am trying to randomly crossfade between two Buffers with synced recordings. When switching the Buffer, you can hear a click, because it’s an instant transition without a fade. Is there a possibilty to add an envelope everytime the buffer switches? This is what I’ve got so far:

~a = Buffer.read(s, path1);
~b = Buffer.read(s, path2);

(
SynthDef(\choose, {|out = 0|
	var a, sig;
	a = [PlayBuf.ar(2, ~a,loop: 1), PlayBuf.ar(2, ~b,loop: 1),];
    sig = Select.ar(LFNoise0.ar(5).range(0,1).round(1) * a.size, a) * 0.2;
	Out.ar(out, sig);
}).play;
)

would appreciate any help! thank you!

maybe SelectX already does the job. SelectX | SuperCollider 3.12.0 Help

1 Like

hey dietcv! thanks for your answer! SelectX.ar sounds exactly like the thing I am looking for, but somehow I don’t here any difference between using Select.ar, SelectX.ar, or LinSelectX.ar. There are still clicks when switching the buffer. do you have any idea why this is happening? thank you!

SelectX + .lag was the solution :slightly_smiling_face:

~a = Buffer.read(s, path1);
~b = Buffer.read(s, path2);

(
SynthDef(\choose, {|out = 0|
	var a, sig;
	a = [PlayBuf.ar(2, ~a,loop: 1), PlayBuf.ar(2, ~b,loop: 1),];
    sig = Select.ar(LFNoise0.ar(5).range(0,1).round(1).lag * a.size, a) * 0.2;
	Out.ar(out, sig);
}).play;
)

thank you!!

have you already tried XFade2?


sig = XFade2.ar(a[0], a[1], LFNoise0.kr(5).range(-1,1));
1 Like

Xfade2 also works very well, thank you! I also had to add .lag to avoid clicks, but then it works as well as using SelectX.ar + .lag :slightly_smiling_face:

im not at the computer right now. but using .lag seems like a hack to me. i think it should work without.

1 Like

Xfade2.ar is working now without lag! I had the wrong .range in my file. Thanks again! :slightly_smiling_face:

you also dont need 2 playbufs i think, look at the solution here:

thanks, i will have a look at it!

If you’re crossfading, you need two sources.

BTW the example you linked to does have two BufRd units.

hjh

Thanks for the correction, Next Time i try to be More Precise :slight_smile:

It’s easy to overlook – the example has:

BufRd.ar(1, firstbuf + [evenIndex, oddIndex], phase)

-->

BufRd.ar(1, [firstbuf + evenIndex, firstbuf + oddIndex], phase)

-->

[
	BufRd.ar(1, firstbuf + evenIndex, phase),
	BufRd.ar(1, firstbuf + oddIndex, phase)
]

Multichannel expansion is one of the really genius features in SC!

hjh

2 Likes