Advertisement
j0h

scProj

j0h
May 16th, 2024
571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. s.boot;
  2.  
  3. s.waitForBoot {
  4.     // Initialize parameters
  5.     a = 0; // mix
  6.     b = 0; // roomsize
  7.     c = 0; // damping
  8.     d = 0; // amp
  9.     s.defualt.synch;
  10. };
  11.  
  12. // Load the sound
  13. ~sound = Buffer.read(s,"ABDW_Fyre_Gut_Kick.wav" );
  14.  
  15. // Change Mix
  16. ~changeMix = { |temp1|
  17.     // Assign the parameter value to the global variable Amp
  18.     a = temp1;
  19.     "RoomSize value changed to:".post;
  20.     a.postln; // Print the new value
  21. };
  22.  
  23. // Change RoomSize
  24. ~changeRoomSize = { |temp2|
  25.     // Assign the parameter value to the global variable Amp
  26.     b = temp2;
  27.     "RoomSize value changed to:".post;
  28.     b.postln; // Print the new value
  29. };
  30.  
  31. // Change Damp
  32. ~changeDamping = { |temp3|
  33.     // Assign the parameter value to the global variable Amp
  34.     c = temp3;
  35.     "Damp value changed to:".post;
  36.     c.postln; // Print the new value
  37. };
  38.  
  39. // Change Amp
  40. ~changeAmp = { |temp4|
  41.     // Assign the parameter value to the global variable Amp
  42.     d = temp4;
  43.     "Amp value changed to:".post;
  44.     d.postln; // Print the new value
  45. };
  46.  
  47.  
  48.  
  49. // Define SynthDefs for dry sound and reverb
  50. (
  51. SynthDef(\drySound, {
  52.     arg out = 0, amp = 1;
  53.  
  54.     var sound = PlayBuf.ar(2, ~sound.bufnum, doneAction: 2);
  55.     Out.ar(out, sound * amp);
  56. }).add;
  57.  
  58. SynthDef(\reverbSound, {
  59.     arg in, out, mix = a, roomSize = b, damping = c, amp = d;
  60.     //arg in, out, mix = 0.5, roomSize = 0.5, damping = 0.5, amp = 0.5;
  61.     var sound = PlayBuf.ar(2, ~sound.bufnum, doneAction: 2);
  62.  
  63.     // Process the input signal with FreeVerb
  64.     var input = In.ar(in, 2);
  65.     /*var reverb = FreeVerb.ar(input, a, b, c); */
  66.     var reverb = FreeVerb.ar(input, roomSize, damping, mix);
  67.  
  68.     // Mix the dry and wet signals
  69.     var output = (input * (1 - mix)) + (reverb * mix);
  70.  
  71.     // Output the signal
  72.     Out.ar(out, output * amp);
  73.  
  74. }).add;
  75. )
  76.  
  77. // GUI
  78. (
  79. // Boot the GUI
  80. //s.waitForBoot {
  81.     // Create a window
  82.     w = Window("Reverb Controls", Rect(100, 100, 400, 200));
  83.  
  84.     // Mix slider
  85.     Slider(w, Rect(10, 10, 200, 20))
  86.         .value_(1)
  87.         .action_({|obj|
  88.             var temp1;
  89.             temp1 = obj.value;
  90.             ~changeMix.(temp1);
  91. /*            var mx = obj.value.linexp(0, 1, 0, 1);
  92.             // Set the mix parameter
  93.             x.set(\mix, mx);*/
  94.     });
  95.  
  96.     // Room size slider
  97.     Slider(w, Rect(10, 40, 200, 20))
  98.         .value_(1)
  99.         .action_({|obj|
  100.             var temp2;
  101.             temp2 = obj.value;
  102.             ~changeRoomSize.(temp2);
  103. /*            var roomSize = obj.value.linexp(0, 1, 0, 1);
  104.             // Set the roomSize parameter
  105.             x.set(\roomSize, roomSize);*/
  106.     });
  107.  
  108.     // Damping slider
  109.     Slider(w, Rect(10, 70, 200, 20))
  110.         .value_(1)
  111.         .action_({|obj|
  112.             var temp3;
  113.             temp3 = obj.value;
  114.             ~changeDamping.(temp3);
  115. /*            var damping = obj.value.linexp(0, 1, 0, 1);
  116.             // Set the damping parameter
  117.             x.set(\damping, damping);*/
  118.     });
  119.  
  120.     // Amplitude slider
  121.     Slider(w, Rect(10, 100, 200, 20))
  122.         .value_(1)
  123.         .action_({|obj|
  124.             var temp4;
  125.             temp4 = obj.value;
  126.             ~changeAmp.(temp4);
  127. /*            var amp = obj.value.linexp(0, 1, 0, 1);
  128.             // Set the amp parameter
  129.             x.set(\amp, amp);*/
  130.     });
  131.  
  132.     // Play Dry button
  133.     Button(w, Rect(220, 130, 150, 20))
  134.         .states_([["Play Dry", Color.black, Color.white]])
  135.         .action_({
  136.             // Start the dry sound Synth
  137.             Synth(\drySound);
  138.     });
  139.  
  140.     // Play with Reverb button
  141.     Button(w, Rect(220, 160, 150, 20))
  142.         .states_([["Play with Reverb", Color.black, Color.white]])
  143.         .action_({
  144.             // Start the reverb Synth with specified parameters
  145.             Synth(\reverbSound, [
  146.                 \in, 1,                     // Input bus
  147.                 \out, 1,                    // Output bus
  148.                 \mix, a,
  149.                 \roomSize, b,
  150.                 \damping, c,
  151.                 \amp, d
  152.  
  153. /*                \mix, x.get(\mix),          // Reverb mix (0-1)
  154.                 \roomSize, x.get(\roomSize),// Room size (0-1)
  155.                 \damping, x.get(\damping),  // Damping (0-1)
  156.                 \amp, x.get(\amp)           // Amplitude*/
  157.             ]);
  158.     });
  159.  
  160.     // StaticText for labels
  161.     StaticText(w, Rect(220, 10, 100, 20)).string_("Mix");
  162.     StaticText(w, Rect(220, 40, 100, 20)).string_("Room Size");
  163.     StaticText(w, Rect(220, 70, 100, 20)).string_("Damping");
  164.     StaticText(w, Rect(220, 100, 100, 20)).string_("Amplitude");
  165.  
  166.     // Show the window
  167.     w.front;
  168. //};
  169. )
  170.  
  171. //s.quit;
  172.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement