You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1 KiB
Plaintext

~structBus = Bus.audio(s, 5); // Bus with 5 channels
(
SynthDef(\layer0_struct0, { |in, out, fftSize=2048|
var sig = PlayBuf.ar(1, in, loop: 1);
var chain = FFT(LocalBuf(fftSize), sig);
chain = PV_RandComb(chain, 0.5, Impulse.kr(2));
chain = PV_BrickWall(chain);
Out.ar(out, IFFT(chain));
}).add;
)
(
~structSynths = Array.fill(5, { |i|
var synthName = ("layer0_struct" ++ i).asSymbol;
Synth(synthName, [
\in, b.bufnum, // your sample buffer
\out, ~structBus.index + i
]);
});
)
(
SynthDef(\structMixer, { |out=0, mixIndex=2.0, amp=0.3|
var ins, mix;
// Read 5 mono inputs
ins = Array.fill(5, { |i| In.ar(~structBus.index + i, 1) });
// Use SelectX to interpolate between adjacent channels
mix = SelectX.ar(mixIndex.clip(0, 4), ins);
Out.ar(out, mix * amp ! 2); // stereo
}).add;
)
// Start the mixer
~mixer = Synth(\structMixer);
(
// MIDI CC Volume
MIDIdef.cc(\structVol, { |val, num, chan|
~mixer.set(\amp, val.linlin(0, 127, 0.0, 1.0));
}, ccNum: 0, chan: 2);
// MIDI CC Blend
MIDIdef.cc(\structMix, { |val, num, chan|
~mixer.set(\mixIndex, val.linlin(0, 127, 0.0, 4.0));
}, ccNum: 1, chan: 2);
)
MIDIClient.init;
MIDIIn.connectAll;