[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[sc-users] Compander
// This is a Compander with a GUI for experimenting. Have fun.
(
/* here: control = input, but you could use a modified version
of input or something different for ducking etc.
*/
var w;
var threshSlider, threshNum;
var slopeBelowSlider, slopeBelowNum;
var slopeAboveSlider, slopeAboveNum;
var clampSlider, clampNum;
var relaxSlider, relaxNum;
var mulSlider, mulNum;
var on, bypass;
w = GUIWindow.new("Compander", Rect.newBy(8, 60, 587, 170));
threshSlider = SliderView.new( w, Rect.newBy(16, 15, 361, 16), "SliderView",
0.5, 0, 1, 0, 'linear');
slopeBelowSlider = SliderView.new( w, Rect.newBy(16, 35, 361, 16),
"SliderView", 1, 0.00001, 20, 0, 'exponential');
slopeAboveSlider = SliderView.new( w, Rect.newBy(16, 55, 361, 16),
"SliderView", 1, 0.00001, 20, 0, 'exponential');
clampSlider = SliderView.new( w, Rect.newBy(16, 75, 361, 16), "SliderView",
0, 0, 5, 0, 'linear');
relaxSlider = SliderView.new( w, Rect.newBy(16, 95, 361, 16), "SliderView",
0, 0, 5, 0, 'linear');
mulSlider = SliderView.new( w, Rect.newBy(16, 115, 361, 16), "SliderView",
1, 0, 10, 0, 'linear');
StringView.new( w, Rect.newBy(387, 15, 96, 20), "threshold");
StringView.new( w, Rect.newBy(387, 35, 96, 20), "slopeBelow");
StringView.new( w, Rect.newBy(387, 55, 96, 20), "slopeAbove");
StringView.new( w, Rect.newBy(387, 75, 96, 20), "clampTime");
StringView.new( w, Rect.newBy(387, 95, 96, 20), "relaxTime");
StringView.new( w, Rect.newBy(387, 115, 96, 20), "mul");
threshNum = StringView.new( w, Rect.newBy(485, 15, 64, 20), "0.5", 0.5,
-1e+10, 1e+10, 0, 'linear');
slopeBelowNum = StringView.new( w, Rect.newBy(485, 35, 64, 20), "1", 1,
-1e+10, 1e+10, 0, 'linear');
slopeAboveNum = StringView.new( w, Rect.newBy(485, 55, 64, 20), "1", 1,
-1e+10, 1e+10, 0, 'linear');
clampNum = StringView.new( w, Rect.newBy(485, 75, 64, 20), "0", 0, -1e+10,
1e+10, 0, 'linear');
relaxNum = StringView.new( w, Rect.newBy(485, 95, 64, 20), "0", 0, -1e+10,
1e+10, 0, 'linear');
mulNum = StringView.new( w, Rect.newBy(485, 115, 64, 20), "1", 1, -1e+10,
1e+10, 0, 'linear');
on = RadioButtonView.new( w, Rect.newBy(199, 145, 80, 20), "on", 1, 0, 1, 0,
'linear');
bypass = RadioButtonView.new( w, Rect.newBy(293, 145, 80, 20), "bypass", 0,
0, 1, 0, 'linear');
threshSlider.action = { threshNum.label = threshSlider.value };
slopeBelowSlider.action = { slopeBelowNum.label = slopeBelowSlider.value };
slopeAboveSlider.action = { slopeAboveNum.label = slopeAboveSlider.value };
clampSlider.action = { clampNum.label = clampSlider.value };
relaxSlider.action = { relaxNum.label = relaxSlider.value };
mulSlider.action = { mulNum.label = mulSlider.value };
Synth.play({
var input, control, bufsize;
input = SinOsc.ar(
LFNoise0.kr(0.5, 1000, 1040),
0,
0.05 +
Decay.ar(
ImpulseSequencer.ar(
`[0.1, 0.7, 0.3, 0.025, 0.95],
LFPulse.ar(5)),
0.03
)
);
control = input;
bufsize = Synth.sampleRate * 1;
thisSynth.sched(0, { w.toFront });
Scope.window("input", bufsize, Rect.newBy(8, 258, 587, 150), input);
Scope.window("control", bufsize, Rect.newBy(8, 435, 587, 150), control);
Scope.window("output", bufsize, Rect.newBy(8, 613, 587, 150),
Pause.ar({
Compander.ar(input, control, threshSlider.kr,
slopeBelowSlider.kr, slopeAboveSlider.kr, clampSlider.kr, relaxSlider.kr,
mulSlider.kr)},
on.kr)
+ Pause.ar({input}, bypass.kr)
);
});
GUIWindow.closeAll
)
/*
http://wittwer.mu/
*/