hey, I would like to crossfade between several buffers filled with One Cycle Waveforms within a BufRd. The reason for not using Vosc is 1.) wavetable format and 2.) to have the abilitly to maybe combine the setup with BufWr
later on. I managed to crossfade between two BufRds
with two Phasors
using SelectX
and was trying out some of the DX Ugens
as well. In the end i would like to use the Signals in the Buffers also as LFO Sources to drive the Crossfade between them. Im not sure which DX Ugen is right for this specific task and how to implement the Signals in the Buffers as curve arguments. thanks a lot
(
b = Buffer.loadCollection(s, Signal.sineFill(512, [1]), 1);
c = Buffer.alloc(s, 512, 1, { |buf| buf.chebyMsg([1,0,1,1,0,1])});
)
(
SynthDef(\crossFade, {
arg out=0, pan=0, amp=0.25, sndBuf1=0, sndBuf2=1, freq=150;
var bufFrames1 = BufFrames.ir(sndBuf1);
var bufFrames2 = BufFrames.ir(sndBuf2);
var sampleDur = SampleDur.ir;
var sig, playbuf1, playbuf2, pos1, pos2;
var crossFade = MouseX.kr(0, 1);
pos1 = Phasor.ar(0, freq * bufFrames1 * sampleDur, 0, bufFrames1);
pos2 = Phasor.ar(0, freq * bufFrames2 * sampleDur, 0, bufFrames2);
playbuf1 = BufRd.ar(1, sndBuf1, pos1, interpolation:4);
playbuf2 = BufRd.ar(1, sndBuf2, pos2, interpolation:4);
sig = SelectX.ar(crossFade, [playbuf1, playbuf2]);
/*
sig = DXMix.ar(
Dseq([0, 1], inf),
`[
BufRd.ar(1, sndBuf1, pos1, interpolation:4),
BufRd.ar(1, sndBuf2, pos2, interpolation:4)
],
fadeTime: 0.5,
//sine: 0,
equalPower: 0, //set to zero to use curve argument
//power: 0,
curve: curve,
allowTypeSeq: 1, //set to 1 to enable sequencing of sine, equalPower, power and curve
);
*/
/*
sig = DXFan.ar(
Dseq([0, 1], inf),
`[
BufRd.ar(1, sndBuf1, pos1, interpolation:4),
BufRd.ar(1, sndBuf2, pos2, interpolation:4)
],
//size: 2,
fadeTime: 3,
//maxWidth: 4,
//width: 3
);
sig = Mix(sig);
*/
sig = Pan2.ar(sig, pan, amp);
Out.ar(out, sig);
}).add;
)
Synth(\crossFade, [\sndBuf1, b, \sndBuf2, c, \amp, 0.25]);
I was also trying to just use one Phasor
and one BufRd
with an Array of two Buffers bufArray
which crashes the server (i think probably because of BufFrames.ir(bufArray), i dont know):
(
b = Buffer.loadCollection(s, Signal.sineFill(512, [1]), 1);
c = Buffer.alloc(s, 512, 1, { |buf| buf.chebyMsg([1,0,1,1,0,1])});
)
(
SynthDef(\crossFade, {
arg out=0, pan=0, amp=0.25, sndBuf1=0, sndBuf2=1, freq=150;
/*
var bufArray = Mix(DXFan.ar(
Dseq([0, 1], inf),
`[
sndBuf1,
sndBuf2
],
fadeTime: 3,
));
*/
var crossFade = MouseX.kr(0, 1);
var bufArray = SelectX.kr(crossFade, [sndBuf1, sndBuf2]);
var bufFrames = BufFrames.ir(bufArray);
var sampleDur = SampleDur.ir;
var sig, pos;
pos = Phasor.ar(0, freq * bufFrames * sampleDur, 0, bufFrames);
sig = BufRd.ar(1, bufArray, pos, interpolation:4);
sig = Pan2.ar(sig, pan, amp);
Out.ar(out, sig);
}).add;
)
Synth(\crossFade, [\sndBuf1, b, \sndBuf2, c, \amp, 0.25]);