SHARE
TWEET

supercollider midi/velocity to ratio

a guest Feb 12th, 2018 126 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. s.quit
  2. s.boot
  3.  
  4. s.options.numInputBusChannels   = 32;
  5. s.options.numOutputBusChannels = 32;
  6.  
  7. Server.local.boot
  8.  
  9.  
  10. (
  11.  
  12.   ~root_note = 60 - 7; // F
  13.  
  14.   ~funk = {
  15.     arg note_num, velocity;
  16.     {
  17.       var freq = ~root_note.midicps;
  18.       var env  = Env([ 0, 1, 0.5, 1, 0 ], [ 0.01, 0.5, 0.02, 0.5 ]);
  19.  
  20.       /*   "--".postln;
  21.         note_num.postln;
  22.         velocity.postln;
  23.         "--".postln;*/
  24.  
  25.       freq = freq * note_num / velocity;
  26.    
  27.       SinOsc.ar( freq, 0, 0.05 ) * EnvGen.kr( env, doneAction: 2 ) !2
  28.     }.play
  29.   };
  30.  
  31.   // ~ Cirklon on the hood!
  32.  
  33.   MIDIIn.connectAll;
  34.   //MIDIIn.disconnectAll
  35.  
  36.   n = MIDIFunc.noteOn({
  37.     arg velocity, note_num, channel;
  38.    
  39.     ~funk.value(note_num,velocity)
  40.   });
  41.   //n.free;
  42.  
  43.   c = MIDIFunc.cc({
  44.     arg value, cc;
  45.  
  46.     ~root_note = value;
  47.    
  48.   });
  49.   //c.free;
  50.  
  51. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top