Advertisement
SoundEngraver

Dynamic Expression (Part 3)

Feb 1st, 2024 (edited)
1,400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///////////////// Dynamic Amplitude, Part 3 /////////////////
  2.  
  3. // You can find a YouTube demonstration here: https://www.youtube.com/watch?v=dDwRqWm9Qss&t=630s&ab_channel=SoundEngraver
  4.  
  5. s.boot;
  6.  
  7. s.plotTree;
  8. s.meter;
  9. s.scope;
  10.  
  11. s.reboot;
  12. s.quit;
  13.  
  14.  
  15. // Add Sound File
  16.  
  17. ~ice = Buffer.read(s, "insertaudiohere");
  18.  
  19. // Note: ~ice is the name I gave my original sound file, for its icy atmosphere.
  20.  
  21. ~ice.play;
  22. ~ice.free;
  23.  
  24. ~ice.duration;
  25. ~ice.numChannels;
  26.  
  27. ~ice.sampleRate;
  28.  
  29. (
  30. Env.new(
  31.     {rrand(0.1, 1)}!5,
  32.     {rrand(4, 12)}!4,
  33.     {rrand(-8.0, 8.0)}!4
  34. ).plot
  35. )
  36.  
  37.  
  38. // Apply it to the ~icePulse Synth.
  39.  
  40. (
  41. ~iceSaw = SynthDef.new(\play, {
  42.     arg saw=1, minAmp=0.001, maxAmp=1,
  43.     buf=0, rate=1, spos=0, pan=0, amp=1, out=0;
  44.     var sig, env, modAmp;
  45.     env = Env(
  46.         {rrand(0.1, 1.0)}!10,
  47.         {rrand(1, 8)}!9,
  48.         {rrand(1, 8)}!9
  49.     ).kr(2);
  50.     modAmp = Saw.kr(saw).exprange(minAmp, maxAmp);
  51.     sig = PlayBuf.ar(
  52.         2,
  53.         buf,
  54.         BufRateScale.ir(buf) * rate,
  55.         spos
  56.     );
  57.     sig = sig * env * modAmp;
  58.     pan = Pan2.ar(sig, pan, amp);
  59.     Out.ar(out, sig);
  60. }).add;
  61. )
  62.  
  63. ~iceSaw = Synth(\play, [\buf, ~ice]);
  64.  
  65. ~iceSaw.set(\saw, 12);
  66. ~iceSaw.free;
  67.  
  68.  
  69. (
  70. {
  71.     EnvGen.kr(
  72.         Env(
  73.             levels: [0, 0.1, 0.2, 0.3],
  74.             times: [0.1, 0.1, 0.1],
  75.             curve: 8
  76.         ),
  77.         gate: Impulse.kr(3)
  78.     );
  79. }.plot(duration: 4);
  80. )
  81.  
  82. (
  83. ~iceSaw = SynthDef.new(\play, {
  84.     arg saw=1, minAmp=0.001, maxAmp=1,
  85.     buf=0, rate=1, spos=0, pan=0, amp=1, out=0;
  86.     var sig, env, modAmp;
  87.     env = EnvGen.kr(
  88.         Env(
  89.             levels: [0, 0.1, 0.2, 0.3],
  90.             times: [0.1, 0.1, 0.1],
  91.             curve: 12
  92.         ),
  93.         gate: Impulse.kr(3)
  94.     );
  95.     modAmp = Saw.kr(saw).exprange(minAmp, maxAmp);
  96.     sig = PlayBuf.ar(
  97.         2,
  98.         buf,
  99.         BufRateScale.ir(buf) * rate,
  100.         spos
  101.     );
  102.     sig = sig * env * modAmp;
  103.     pan = Pan2.ar(sig, pan, amp);
  104.     Out.ar(out, sig);
  105. }).add;
  106. )
  107.  
  108. ~iceSaw = Synth(\play, [\buf, ~ice]);
  109.  
  110. ~iceSaw.set(\saw, 4);
  111. ~iceSaw.free;
  112.  
  113.  
  114. (
  115. {
  116.     EnvGen.kr(
  117.         Env(
  118.             levels: [0, 0.5, 0.1, 1, 0.8, 0.3, 0.9, 0.1, 0],
  119.             times: [1, 1, 1, 1, 1, 1, 1, 1],
  120.             curve: [-3, 3, -2, -3, 1, -1, 3, -2]
  121.         )
  122.     );
  123. }.plot(duration: 8);
  124. )
  125.  
  126.  
  127. (
  128. ~iceSaw = SynthDef.new(\play, {
  129.     arg saw=1, minAmp=0.001, maxAmp=1,
  130.     buf=0, rate=1, spos=0, pan=0, amp=1, out=0;
  131.     var sig, env, modAmp;
  132.  
  133.     env = Env(
  134.         [0, 0.5, 0.01, 1, 0.8, 0.03, 0.9, 0.1, 0],
  135.         [4, 4, 4, 4, 4, 4, 4, 4],
  136.         [-3, 3, -2, -3, 1, -1, 3, -2],
  137.     ).kr(2);
  138.  
  139.     modAmp = Saw.kr(saw).exprange(minAmp, maxAmp);
  140.     sig = PlayBuf.ar(
  141.         2,
  142.         buf,
  143.         BufRateScale.ir(buf) * rate,
  144.         spos
  145.     );
  146.     sig = sig * env * modAmp;
  147.     pan = Pan2.ar(sig, pan, amp);
  148.     Out.ar(out, sig);
  149. }).add;
  150. )
  151.  
  152. ~iceSaw = Synth(\play, [\buf, ~ice]);
  153.  
  154. ~iceSaw.set(\saw, 8);
  155. ~iceSaw.free;
  156.  
  157.  
  158. // Remember, the synth will only last as long as the duration of the sound file. You might need to work with loopNode and releaseNode in the Env.
  159.  
  160. // See Help example for releaseNode (see Part 4)
  161.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement