Advertisement
Guest User

Untitled

a guest
Nov 7th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (
  2. //MIDI
  3. MIDIClient.init;
  4. MIDIIn.connectAll;
  5.  
  6. ~notes = Array.newClear(128); //Pad Synth Array
  7.  
  8. //Channel 1 pad Synth
  9. MIDIdef.noteOn(\noteOn, {
  10.     arg vel, nn, chan, src;
  11.     ~notes[nn] = Synth.new(
  12.         \jorKlank2,
  13.         [
  14.         \atk, 1.0,
  15.             \dec, 0.8,
  16.             \sus, 0.7,
  17.             \rel, 1.5,
  18.             \ffreq, nn.midicps,
  19.             \freqs, #[1500, 100, 1000, 300, 256, 123, 908, 1200, 157, 311, 677, 521, 743],
  20.             \amps, #[0.2, 0.3, 0.33, 2, 0.1, 0.9, 0.6, 0.45, 0.67, 0.3, 0.77, 0.88, 0.35].reverse,
  21.             \rings, #[0.2, 0.3, 0.33, 2, 0.1, 0.9, 0.6, 0.45, 0.67, 0.3, 0.77, 0.88, 0.35];
  22.         ]
  23.     );
  24. }, chan: 0).permanent_(true);
  25.  
  26. MIDIdef.noteOff(\noteOff, {
  27.     arg vel, nn;
  28.     [vel, nn].postln;
  29.     ~notes[nn].set(\gate, 0);
  30.     ~notes[nn] = nil;
  31. }).permanent_(true);
  32. )
  33.  
  34. //SYNTH
  35.  
  36. (
  37. SynthDef(\jorKlank2,{
  38.     arg
  39.     gate = 1, atk = 0.2, dec = 0.5, sus = 1, rel = 1, ffreq=440,
  40.     freqs = #[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  41.     amps = #[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  42.     rings = #[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
  43.  
  44.     var
  45.     temp,
  46.     envelope = EnvGen.kr(Env.adsr(atk, dec, sus, rel), gate, doneAction: 2),
  47.     exciter = SinOsc.ar([ffreq, ffreq+3]*2, mul:0.001),
  48.     klank = DynKlank.ar(`[freqs, amps, rings], exciter);
  49.  
  50.     Out.ar([10], klank*envelope);// Pan2.ar(klank*envelope, pan));
  51. }).add;
  52. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement