Advertisement
Guest User

Untitled

a guest
Jun 1st, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. s.boot;
  2. (
  3. //Samples
  4. ~jorSamples = Array.new;
  5. ~folder = PathName.new("/Users/Jorgalad/Library/Mobile Documents/com~apple~CloudDocs/SuperCollider/02 Sounds/Input/Vocal/Vox for SC/")
  6. )
  7.  
  8. (
  9. ~folder.entries.do({
  10.     arg path;
  11.     ~jorSamples = ~jorSamples.add(Buffer.readChannel(s, path.fullPath,channels:[0]));
  12. });
  13. )
  14.  
  15. (
  16. //Audio Bus
  17. ~audioBus1 = Bus.audio(s, 2);
  18. ~audioBus2 = Bus.audio(s, 2);
  19. ~audioBus3 = Bus.audio(s, 2);
  20.  
  21. //Control Bus
  22. //SYNTH
  23. ~selSample = Bus.control(s);  ~selSample.set(1);      //Select Sample
  24. ~duration = Bus.control(s);  ~duration.set(4);          //Duration
  25. ~atVib = Bus.control(s);                                          //Vibrato
  26. ~triggerRate = Bus.control(s);                                //Trigger Rate
  27. ~position = Bus.control(s); ~position.set(0.40);         //Start Position
  28.  
  29. //FFT FX
  30. ~fftWet = Bus.control(s);  ~fftWet.set(0.0);      //Select Sample
  31. ~fftStretch = Bus.control(s);  ~fftStretch.set(1);
  32. ~fftShift = Bus.control(s);  ~fftShift.set(0);
  33. )
  34.  
  35. (
  36. //MIDI
  37. MIDIClient.init;
  38. MIDIIn.connectAll;
  39.  
  40. //~sourceGrp = Group.new;
  41. //~fxGrp1 = Group.new(addAction: \addAfter);
  42.  
  43. ~notes1 = Array.newClear(128);
  44. //Channel 1 Synth Note On
  45. MIDIdef.noteOn(\noteOn1, {
  46.     arg vel, nn, chan, src;
  47.     //THIS DOESNT WORK YET
  48.     //~notes1[nn] = MixerChannel(\synth1, server: s, inChannels: 1, outChannels: 2, postSendReady:true);
  49.     ~notes1[nn] = Synth.new(
  50.         \synth1,
  51.         [
  52.             \amp, vel.linlin(1,127, 0.1, 1.5),
  53.             \gate, 1,
  54.             \nrate, [(nn.midiratio/12) ].postln,
  55.             \sample, ~selSample.asMap,
  56.             \duration, ~duration.asMap,
  57.             \atVib, ~atVib.asMap,
  58.             \trgRate, ~triggerRate.asMap,
  59.             \position, ~position.asMap,
  60.             //\fx1, ~fx1.asMap;
  61.         //],~sourceGrp, \addToHead
  62.         ]
  63.     );
  64. }, chan: 0).permanent_(true);
  65.  
  66. MIDIdef.noteOff(\noteOff1, {
  67.     arg vel, nn;
  68.     [vel, nn].postln;
  69.     ~notes1[nn].set(\gate, 0);
  70.     ~notes1[nn] = nil;
  71. }).permanent_(true);
  72.  
  73. MIDIdef.cc(\at, {
  74.     arg val, num, chan, src;
  75.     [val, num, chan, src].postcs;
  76. //  ~s1fc.set(\cutoff, val.linlin(0,127,50, 1000));
  77.     ~atVib.set(val.linlin(0,127,0.1, 8.0));
  78. }, ccNum: 15, chan: 0).permanent_(true); //Channel 15
  79. )
  80.  
  81. (
  82. //Source Synth, use outbus for the source
  83. SynthDef(\synth1, {
  84.     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;
  85.     var env, vibrato, sig, ptr;
  86.     env = EnvGen.kr(Env.adsr(1.2, 0.4, 0.8, 2, 1), gate,doneAction:2);
  87.     vibrato = SinOsc.kr(7, 0, atVib);
  88.     //ptr = Line.ar(0, BufFrames.kr(rate)-1, BufDur.kr(rate), doneAction:2);
  89.     //sig = PlayBuf.ar(2, bufnum, BufRateScale.kr(rate) * rate/2, t_trig, start, loop);
  90.  
  91.     //sig = GrainBuf.ar(1, Impulse.kr(1), 1, ~jorSamples[1], LFNoise1.kr.range(0.2, 1),LFNoise2.kr(0.1).range(0, 1), 2);
  92.     //sig = GrainBuf.ar(1, Impulse.kr(3), 1, ~jorSamples[5], rate/4, LFNoise2.kr(0.1).range(0, 1), 2);
  93.  
  94.     sig = GrainBuf.ar(1, Impulse.kr(trgRate), duration, sample, nrate, position, interp);
  95.  
  96.     //Out.ar(~audioBus1, sig  * 0.5 * env);
  97.     //Out.ar([0,1], sig  * 0.5 * env);
  98.     //Out.ar([outbus, outbus + 1], sig  * 0.5 * env);
  99.     Out.ar(outbus, sig  * 0.5 * env);
  100. }).send(s);
  101.  
  102. //CHORUS EFFECT
  103. SynthDef.new(\chorusFX, {
  104.     arg outbus, delay = 0.01, freq = 0.2, depth = 0.05, wet = 0.5;
  105.     var in, out;
  106.     in = In.ar(outbus, 1);
  107.     out = DelayN.ar(in, 1, SinOsc.ar(freq, 0, depth, delay));
  108.     ReplaceOut.ar(outbus, in*(1-wet).sqrt + out*wet.sqrt);  // equal power
  109. }).send(s);
  110.  
  111. //FFT Freeze
  112. SynthDef(\fx1_fft, {
  113.     arg fx1out, stretch=1, shift=0, amp = 0.6, wet=0, outbus;
  114.     var in, chain, out;
  115.     //in = In.ar(~audioBus1);
  116.     in = In.ar(outbus, 1);
  117.     chain = in;
  118.     chain = FFT(LocalBuf(2048, 1), in, hop: 0.25, wintype: 0, active: 1, winsize: 0);
  119.     //chain = PV_MagShift(chain, MouseX.kr(0.25, 4, \exponential) );
  120.     chain = PV_MagShift(chain,stretch, shift);
  121.     //centroid = SpecCentroid.kr(chain);
  122.     out = 0.5 * IFFT(chain);
  123.     ReplaceOut.ar(outbus, in*(1-wet).sqrt + out*wet.sqrt);  // equal power
  124. //  ReplaceOut.ar(outbus, sig);
  125. }).send(s);
  126.  
  127. //Master Channel
  128. ~master = MixerChannel(\master, s, 2, 2, level:1);
  129. //Source Channel
  130. ~chan = MixerChannel(\synth1, server: s, inChannels: 1, outChannels: 2, postSendReady:true);
  131. )
  132.  
  133.  
  134.  
  135. (
  136. ~selSample.set(1);      
  137. ~duration.set(4);          
  138. ~position.set(0.40);         //Start Position
  139.  
  140. //FFT FX
  141. ~fftWet.set(1);      
  142. ~fftStretch.set(1);
  143. ~fftShift.set(0);
  144.  
  145. //Runs the Dry Synth
  146. r = Task({
  147.    {   ~chan.play(
  148.         \synth1,
  149.         [
  150.         \nrate, 1,
  151.         \gate, 1,
  152.         \dur, rrand(0.5, 1.0),
  153.         \amp,                  1,
  154.         \sample,             ~selSample.asMap,
  155.         \duration, ~duration.asMap,
  156.         \atVib, ~atVib.asMap,
  157.         \trgRate, ~triggerRate.asMap,
  158.         \position, ~position.asMap,
  159.         \atk,                    0.01,
  160.         \dec,                   1,
  161.         \sus,                   2,
  162.         \rel,                    2,
  163.     ]);
  164.     (1).wait;
  165.    }.loop;
  166. }).play;
  167.  
  168. //ADD fft FX
  169. //Add FX
  170.  
  171. //~chorus = ~chan.playfx(\chorusFX, [\wet, 0.5]);
  172. ~fft = ~chan.playfx(\fx1_fft, [
  173.     \wet, ~fftWet.asMap,
  174.     \stretch, ~fftStretch.asMap,
  175.     \fftShift, ~fftShift.asMap
  176. ]);
  177. )
  178.  
  179. r.play;
  180. r.stop;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement