Advertisement
Guest User

Untitled

a guest
Jun 27th, 2018
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. s.quit;
  2. (
  3. var name, a, server;
  4. w = Window("ROLI Vox I ", Rect(1400, 0, 520, 240))
  5. .front
  6. .alwaysOnTop_(true)
  7. .background = Color.new255(76,76,76);
  8. c = Stethoscope.new(s, view:w.view);
  9. s.reboot;
  10. )
  11.  
  12. (
  13. MIDIIn.connectAll;
  14.  
  15. SynthDef(\jorRoli, {
  16.     arg freq, mod=0, touch=0,amp=0.01, gate=1, out;
  17.     var env, sig;
  18.     env = EnvGen.kr(Env.adsr(0.5, 0.5, 1.0, 0.8), gate, doneAction: 2);
  19.     sig = VarSaw.ar(
  20.         freq.lag(0.01)* {Rand(0.99, 1.01)} !2,
  21.         width: 1.0 - touch
  22.     );
  23.     sig = LPF.ar(sig, 18000 * mod);
  24.     Out.ar(out, sig * env * amp * 0.2);
  25. }).add;
  26. )
  27.  
  28. (
  29. var notes, synths, on, off, mod, bend, touch;
  30. ~num_channels = 16;
  31. ~bend_range = 24;
  32.  
  33. notes = Array.newClear(~num_channels);
  34. synths = Array.newClear(~num_channels);
  35. //NoteOn&Vel
  36. on = MIDIFunc.noteOn({ | vel, num, chan, src |
  37.     // ("on" + chan + num + vel).postln;
  38.     notes[chan] = num;
  39.     synths[chan] = Synth(\jorRoli, [
  40.         \freq, num.midicps,
  41.         \amp, vel * (1.0/127.0)]);
  42. });
  43. //NoteOff&Vel
  44. off = MIDIFunc.noteOff({ | vel, num, chan, src |
  45.     synths[chan].release;
  46.     notes[chan] = nil;
  47.     synths[chan] = nil;
  48. });
  49.  
  50.  
  51. //Slide
  52. mod = MIDIFunc.cc({ | val, num, chan, src |
  53.     if (synths[chan] != nil) {
  54.         synths[chan].set(\mod, val.linexp(0, 127, 0.001, 1.0))};
  55. }, 74);
  56.  
  57.  
  58. //Glide
  59. bend = MIDIFunc.bend({ | val, chan, src |
  60.     var bend = ~bend_range * ((val - 8192)/8192);
  61.     if (synths[chan] != nil) {
  62.         synths[chan].set(\freq, (notes[chan] + bend).midicps);
  63.     };
  64. });
  65. //Pressure
  66. touch = MIDIFunc.touch({ | val, chan, src |
  67.     // ("touch" + chan + val).postln;
  68.     if (synths[chan] != nil) {
  69.         synths[chan].set(\touch, val * (1.0/127.0));
  70.     };
  71. });
  72.  
  73. q = {
  74.     on.free;
  75.     off.free;
  76.     mod.free;
  77.     bend.free;
  78.     touch.free;
  79. }
  80. )
  81. q.value;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement