s.boot;
s.waitForBoot {
// Initialize parameters
a = 0; // mix
b = 0; // roomsize
c = 0; // damping
d = 0; // amp
s.defualt.synch;
};
// Load the sound
~sound = Buffer.read(s,"ABDW_Fyre_Gut_Kick.wav" );
// Change Mix
~changeMix = { |temp1|
// Assign the parameter value to the global variable Amp
a = temp1;
"RoomSize value changed to:".post;
a.postln; // Print the new value
};
// Change RoomSize
~changeRoomSize = { |temp2|
// Assign the parameter value to the global variable Amp
b = temp2;
"RoomSize value changed to:".post;
b.postln; // Print the new value
};
// Change Damp
~changeDamping = { |temp3|
// Assign the parameter value to the global variable Amp
c = temp3;
"Damp value changed to:".post;
c.postln; // Print the new value
};
// Change Amp
~changeAmp = { |temp4|
// Assign the parameter value to the global variable Amp
d = temp4;
"Amp value changed to:".post;
d.postln; // Print the new value
};
// Define SynthDefs for dry sound and reverb
(
SynthDef(\drySound, {
arg out = 0, amp = 1;
var sound = PlayBuf.ar(2, ~sound.bufnum, doneAction: 2);
Out.ar(out, sound * amp);
}).add;
SynthDef(\reverbSound, {
arg in, out, mix = a, roomSize = b, damping = c, amp = d;
//arg in, out, mix = 0.5, roomSize = 0.5, damping = 0.5, amp = 0.5;
var sound = PlayBuf.ar(2, ~sound.bufnum, doneAction: 2);
// Process the input signal with FreeVerb
var input = In.ar(in, 2);
/*var reverb = FreeVerb.ar(input, a, b, c); */
var reverb = FreeVerb.ar(input, roomSize, damping, mix);
// Mix the dry and wet signals
var output = (input * (1 - mix)) + (reverb * mix);
// Output the signal
Out.ar(out, output * amp);
}).add;
)
// GUI
(
// Boot the GUI
//s.waitForBoot {
// Create a window
w = Window("Reverb Controls", Rect(100, 100, 400, 200));
// Mix slider
Slider(w, Rect(10, 10, 200, 20))
.value_(1)
.action_({|obj|
var temp1;
temp1 = obj.value;
~changeMix.(temp1);
/* var mx = obj.value.linexp(0, 1, 0, 1);
// Set the mix parameter
x.set(\mix, mx);*/
});
// Room size slider
Slider(w, Rect(10, 40, 200, 20))
.value_(1)
.action_({|obj|
var temp2;
temp2 = obj.value;
~changeRoomSize.(temp2);
/* var roomSize = obj.value.linexp(0, 1, 0, 1);
// Set the roomSize parameter
x.set(\roomSize, roomSize);*/
});
// Damping slider
Slider(w, Rect(10, 70, 200, 20))
.value_(1)
.action_({|obj|
var temp3;
temp3 = obj.value;
~changeDamping.(temp3);
/* var damping = obj.value.linexp(0, 1, 0, 1);
// Set the damping parameter
x.set(\damping, damping);*/
});
// Amplitude slider
Slider(w, Rect(10, 100, 200, 20))
.value_(1)
.action_({|obj|
var temp4;
temp4 = obj.value;
~changeAmp.(temp4);
/* var amp = obj.value.linexp(0, 1, 0, 1);
// Set the amp parameter
x.set(\amp, amp);*/
});
// Play Dry button
Button(w, Rect(220, 130, 150, 20))
.states_([["Play Dry", Color.black, Color.white]])
.action_({
// Start the dry sound Synth
Synth(\drySound);
});
// Play with Reverb button
Button(w, Rect(220, 160, 150, 20))
.states_([["Play with Reverb", Color.black, Color.white]])
.action_({
// Start the reverb Synth with specified parameters
Synth(\reverbSound, [
\in, 1, // Input bus
\out, 1, // Output bus
\mix, a,
\roomSize, b,
\damping, c,
\amp, d
/* \mix, x.get(\mix), // Reverb mix (0-1)
\roomSize, x.get(\roomSize),// Room size (0-1)
\damping, x.get(\damping), // Damping (0-1)
\amp, x.get(\amp) // Amplitude*/
]);
});
// StaticText for labels
StaticText(w, Rect(220, 10, 100, 20)).string_("Mix");
StaticText(w, Rect(220, 40, 100, 20)).string_("Room Size");
StaticText(w, Rect(220, 70, 100, 20)).string_("Damping");
StaticText(w, Rect(220, 100, 100, 20)).string_("Amplitude");
// Show the window
w.front;
//};
)
//s.quit;