SHARE
TWEET

Untitled

a guest May 27th, 2018 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (
  2. /*
  3.  
  4. MODULAR DESIGN PATTERN INSPIRED BY SUPERDIRT
  5.  
  6. Note:
  7. - They all share the same audio bus (reading from it and then replacing its content)
  8. - Using ReplaceOut for the effects is necessary
  9. - The envelope frees the group
  10.  
  11. */
  12.  
  13. // Synths
  14. SynthDef(\soundgen, {|bus, freq=444|
  15.     Out.ar(bus, SinOsc.ar(freq).dup )
  16. }).add;
  17.  
  18. SynthDef(\fold, {|bus, lo=0.01, hi=0.6|
  19.     ReplaceOut.ar(bus, In.ar(bus, 2).fold(lo,hi))
  20. }).add;
  21.  
  22. SynthDef(\ar_env, {|bus, atk=1, rel=1, dur|
  23.     ReplaceOut.ar(bus, In.ar(bus, 2)
  24.     * EnvGen.kr(Env.perc(atk,rel), timeScale:dur, doneAction: 14)
  25.     )
  26. }).add;
  27.  
  28. SynthDef(\out, {|bus|
  29.     ReplaceOut.ar(0, In.ar(bus,2))
  30. }).add;
  31.  
  32. /*
  33.  
  34. Events, groups and patterns
  35.  
  36. */
  37.  
  38. // Create a new eventtype, this is called every time a pattern plays a "note"
  39. // The "environment variables" with the tildes as prefix become arguments in the
  40. // Event (see Pbind below)
  41.  
  42. Event.addEventType(\testEvent, {
  43.     // Organise the synths in group with the sound generator
  44.     // first and then the effects at the tail
  45.     var testgroup = Group.new;
  46.     var testbus = Bus.audio(s,2);
  47.  
  48.     Synth.head(testgroup, \soundgen, [\freq, ~freq, \bus, testbus]);
  49.     Synth.tail(testgroup, \fold, [\lo, ~lo, \hi, ~hi, \bus, testbus]);
  50.     Synth.tail(testgroup, \ar_env, [\dur, ~dur, \atk, ~atk, \rel, ~rel, \bus,
  51.         testbus]);
  52.     Synth.tail(testgroup, \out, [\bus, testbus]);
  53.  
  54. });
  55.  
  56. // Play a pattern
  57. Pbind(\type, \testEvent,
  58.     \degree, Pwhite(-14,7,inf),
  59.     \octave, 4,
  60.     \scale, Scale.minor,
  61.     \lo, 0.1,
  62.     \hi, Pwhite(0.15,0.8,inf),
  63.     \atk, Pseq([0.05, 0.15, 0.75],inf),
  64.     \rel, 1 - Pkey(\atk),
  65.     \dur, 0.25+Pstutter(20, Pseq([1, 0.25, 0.125],inf)),
  66. ).trace(prefix: 'pat1').play;
  67.  
  68. // UNCOMMENT THIS TO FUCK UP THE SOUND
  69. Pbind(\type, \testEvent,
  70.     \degree, Pwhite(-14,7,inf),
  71.     \octave, 5,
  72.     \scale, Scale.minor,
  73.     \lo, 0.1,
  74.     \hi, Pwhite(0.15,0.8,inf),
  75.     \atk, Pseq([0.05, 0.15, 0.75],inf),
  76.     \rel, 1 - Pkey(\atk),
  77.     \stretch, 0.5,
  78.     \dur, 0.25 + Pstutter(20, Pseq([1, 0.25, 0.125],inf)),
  79. ).trace(prefix: 'pat2').play;
  80. )
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
 
Top