Advertisement
Guest User

Untitled

a guest
May 27th, 2018
193
0
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.     var busss = Bus.audio(s,2);
  44.  
  45.     // Organise the synths in group with the sound generator
  46.     // first and then the effects at the tail
  47.     var testgroup = Group.new;
  48.    
  49.     Synth.head(testgroup, \soundgen, [\freq, ~freq, \bus, busss]);
  50.     Synth.tail(testgroup, \fold, [\lo, ~lo, \hi, ~hi, \bus, busss]);
  51.     Synth.tail(testgroup, \ar_env, [\dur, ~dur, \atk, ~atk, \rel, ~rel, \bus, busss]);
  52.     Synth.tail( testgroup, \out, [\bus, busss]);
  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, Pstutter(20, Pseq([1, 0.25, 0.125],inf)),
  66. ).play;
  67.  
  68. /*
  69. // UNCOMMENT THIS TO FUCK UP THE SOUND
  70. Pbind(\type, \testEvent,
  71.     \degree, Pwhite(-14,7,inf),
  72.     \octave, 5,
  73.     \scale, Scale.minor,
  74.     \lo, 0.1,
  75.     \hi, Pwhite(0.15,0.8,inf),
  76.     \atk, Pseq([0.05, 0.15, 0.75],inf),
  77.     \rel, 1 - Pkey(\atk),
  78.     \stretch, 0.5,
  79.     \dur, Pstutter(20, Pseq([1, 0.25, 0.125],inf)),
  80. ).play;
  81. */
  82. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement