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.
61 lines
1.3 KiB
Plaintext
61 lines
1.3 KiB
Plaintext
(
|
|
SynthDef(\layer0_struct0, {
|
|
arg bufnum, fftSize = 1024, amp = 0.3,
|
|
wipeFreq = 0.1, wipeDepth = 0.4,
|
|
trigFreq = 2.0, threshold = 0.3, smoothAmt = 0.2,
|
|
mix = 1.0;
|
|
|
|
var in, dry, sig, chain;
|
|
var wipe, trig;
|
|
|
|
in = PlayBuf.ar(1, bufnum, BufRateScale.kr(bufnum), loop: 1);
|
|
dry = in;
|
|
|
|
// FFT
|
|
chain = FFT(LocalBuf(fftSize), in);
|
|
|
|
// Modulated parameters
|
|
wipe = SinOsc.kr(wipeFreq).range(wipeDepth, 0.9);
|
|
trig = Impulse.kr(trigFreq);
|
|
|
|
// Processing chain
|
|
chain = PV_RandComb(chain, wipe, trig);
|
|
chain = PV_MagAbove(chain, threshold);
|
|
chain = PV_MagSmooth(chain, smoothAmt);
|
|
chain = PV_BrickWall(chain);
|
|
|
|
sig = IFFT(chain);
|
|
|
|
// Mix dry/wet
|
|
sig = XFade2.ar(dry, sig, mix.linlin(0, 1, -1, 1));
|
|
|
|
Out.ar(0, sig.dup * amp);
|
|
}).add;
|
|
)
|
|
|
|
|
|
(
|
|
~midiControlMap = (
|
|
16: \wipeFreq, // CC16
|
|
17: \wipeDepth, // CC17
|
|
18: \trigFreq, // CC18
|
|
19: \threshold, // CC19
|
|
20: \smoothAmt, // CC20
|
|
21: \mix // CC21
|
|
);
|
|
|
|
// Replace this with your actual Synth instance
|
|
~layer0 = Synth(\layer0_struct0, [\bufnum, b]);
|
|
|
|
// Connect MIDI CCs on channel 2
|
|
~midiControlMap.keysValuesDo { |cc, param|
|
|
MIDIFunc.cc({ |val, num, chan, src|
|
|
if (chan == 2) { // Channel 2 (zero-indexed)
|
|
var mappedVal = val.linlin(0, 127, 0.0, 1.0);
|
|
~layer0.set(param, mappedVal);
|
|
("CC" ++ cc ++ " (" ++ param ++ ") → " ++ mappedVal).postln;
|
|
}
|
|
}, cc);
|
|
};
|
|
)
|