Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s.boot;
- (
- //Samples
- ~jorSamples = Array.new;
- ~folder = PathName.new("/Users/Jorgalad/Library/Mobile Documents/com~apple~CloudDocs/SuperCollider/02 Sounds/Input/Vocal/Vox for SC/")
- )
- (
- ~folder.entries.do({
- arg path;
- ~jorSamples = ~jorSamples.add(Buffer.readChannel(s, path.fullPath,channels:[0]));
- });
- )
- (
- //Audio Bus
- ~audioBus1 = Bus.audio(s, 2);
- ~audioBus2 = Bus.audio(s, 2);
- ~audioBus3 = Bus.audio(s, 2);
- //Control Bus
- //SYNTH
- ~selSample = Bus.control(s); ~selSample.set(1); //Select Sample
- ~duration = Bus.control(s); ~duration.set(4); //Duration
- ~atVib = Bus.control(s); //Vibrato
- ~triggerRate = Bus.control(s); //Trigger Rate
- ~position = Bus.control(s); ~position.set(0.40); //Start Position
- //FFT FX
- ~fftWet = Bus.control(s); ~fftWet.set(0.0); //Select Sample
- ~fftStretch = Bus.control(s); ~fftStretch.set(1);
- ~fftShift = Bus.control(s); ~fftShift.set(0);
- )
- (
- //MIDI
- MIDIClient.init;
- MIDIIn.connectAll;
- //~sourceGrp = Group.new;
- //~fxGrp1 = Group.new(addAction: \addAfter);
- ~notes1 = Array.newClear(128);
- //Channel 1 Synth Note On
- MIDIdef.noteOn(\noteOn1, {
- arg vel, nn, chan, src;
- //THIS DOESNT WORK YET
- //~notes1[nn] = MixerChannel(\synth1, server: s, inChannels: 1, outChannels: 2, postSendReady:true);
- ~notes1[nn] = Synth.new(
- \synth1,
- [
- \amp, vel.linlin(1,127, 0.1, 1.5),
- \gate, 1,
- \nrate, [(nn.midiratio/12) ].postln,
- \sample, ~selSample.asMap,
- \duration, ~duration.asMap,
- \atVib, ~atVib.asMap,
- \trgRate, ~triggerRate.asMap,
- \position, ~position.asMap,
- //\fx1, ~fx1.asMap;
- //],~sourceGrp, \addToHead
- ]
- );
- }, chan: 0).permanent_(true);
- MIDIdef.noteOff(\noteOff1, {
- arg vel, nn;
- [vel, nn].postln;
- ~notes1[nn].set(\gate, 0);
- ~notes1[nn] = nil;
- }).permanent_(true);
- MIDIdef.cc(\at, {
- arg val, num, chan, src;
- [val, num, chan, src].postcs;
- // ~s1fc.set(\cutoff, val.linlin(0,127,50, 1000));
- ~atVib.set(val.linlin(0,127,0.1, 8.0));
- }, ccNum: 15, chan: 0).permanent_(true); //Channel 15
- )
- (
- //Source Synth, use outbus for the source
- SynthDef(\synth1, {
- arg amp=1, gate=1, nrate=4, t_trig=1, start=0, trgRate, sample=1, atVib = 0, duration=2, position=0.40, interp=4, outbus;
- var env, vibrato, sig, ptr;
- env = EnvGen.kr(Env.adsr(1.2, 0.4, 0.8, 2, 1), gate,doneAction:2);
- vibrato = SinOsc.kr(7, 0, atVib);
- //ptr = Line.ar(0, BufFrames.kr(rate)-1, BufDur.kr(rate), doneAction:2);
- //sig = PlayBuf.ar(2, bufnum, BufRateScale.kr(rate) * rate/2, t_trig, start, loop);
- //sig = GrainBuf.ar(1, Impulse.kr(1), 1, ~jorSamples[1], LFNoise1.kr.range(0.2, 1),LFNoise2.kr(0.1).range(0, 1), 2);
- //sig = GrainBuf.ar(1, Impulse.kr(3), 1, ~jorSamples[5], rate/4, LFNoise2.kr(0.1).range(0, 1), 2);
- sig = GrainBuf.ar(1, Impulse.kr(trgRate), duration, sample, nrate, position, interp);
- //Out.ar(~audioBus1, sig * 0.5 * env);
- //Out.ar([0,1], sig * 0.5 * env);
- //Out.ar([outbus, outbus + 1], sig * 0.5 * env);
- Out.ar(outbus, sig * 0.5 * env);
- }).send(s);
- //CHORUS EFFECT
- SynthDef.new(\chorusFX, {
- arg outbus, delay = 0.01, freq = 0.2, depth = 0.05, wet = 0.5;
- var in, out;
- in = In.ar(outbus, 1);
- out = DelayN.ar(in, 1, SinOsc.ar(freq, 0, depth, delay));
- ReplaceOut.ar(outbus, in*(1-wet).sqrt + out*wet.sqrt); // equal power
- }).send(s);
- //FFT Freeze
- SynthDef(\fx1_fft, {
- arg fx1out, stretch=1, shift=0, amp = 0.6, wet=0, outbus;
- var in, chain, out;
- //in = In.ar(~audioBus1);
- in = In.ar(outbus, 1);
- chain = in;
- chain = FFT(LocalBuf(2048, 1), in, hop: 0.25, wintype: 0, active: 1, winsize: 0);
- //chain = PV_MagShift(chain, MouseX.kr(0.25, 4, \exponential) );
- chain = PV_MagShift(chain,stretch, shift);
- //centroid = SpecCentroid.kr(chain);
- out = 0.5 * IFFT(chain);
- ReplaceOut.ar(outbus, in*(1-wet).sqrt + out*wet.sqrt); // equal power
- // ReplaceOut.ar(outbus, sig);
- }).send(s);
- //Master Channel
- ~master = MixerChannel(\master, s, 2, 2, level:1);
- //Source Channel
- ~chan = MixerChannel(\synth1, server: s, inChannels: 1, outChannels: 2, postSendReady:true);
- )
- (
- ~selSample.set(1);
- ~duration.set(4);
- ~position.set(0.40); //Start Position
- //FFT FX
- ~fftWet.set(1);
- ~fftStretch.set(1);
- ~fftShift.set(0);
- //Runs the Dry Synth
- r = Task({
- { ~chan.play(
- \synth1,
- [
- \nrate, 1,
- \gate, 1,
- \dur, rrand(0.5, 1.0),
- \amp, 1,
- \sample, ~selSample.asMap,
- \duration, ~duration.asMap,
- \atVib, ~atVib.asMap,
- \trgRate, ~triggerRate.asMap,
- \position, ~position.asMap,
- \atk, 0.01,
- \dec, 1,
- \sus, 2,
- \rel, 2,
- ]);
- (1).wait;
- }.loop;
- }).play;
- //ADD fft FX
- //Add FX
- //~chorus = ~chan.playfx(\chorusFX, [\wet, 0.5]);
- ~fft = ~chan.playfx(\fx1_fft, [
- \wet, ~fftWet.asMap,
- \stretch, ~fftStretch.asMap,
- \fftShift, ~fftShift.asMap
- ]);
- )
- r.play;
- r.stop;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement