CC3 Week 1 - Graphical User Interface I
My computer died this week which is pretty annoying since I actually did do this weeks SC patch. Hopefully I can get my data back and you'll see my attempt of a reverb plugin in Logic called AVerb.
.........Ok I have my patch. I say it's worth $650. That's what it cost to restore my data from my laptop. Typical Apple. . .
The biggest challenge at first was the positioning. Like Christian said, at first it doesn't make sense. Once I got my first slider working with the text and number box, it was a matter of copying the code and editing the positioning and the value of the slider. I also had to set the slider to start at 0. This was annoying at first because the SCRangeSlider starts where the user clicks, by default.
it's getting there. . .
(
var sbs;
//w.close;
// WHOLE WINDOW
w = SCWindow.new.front;
// Parameters
w.bounds = Rect(170,150,350,250); // Rectangular Window Bounds (Bottom Left Width Height)
w.name_("AVerb"); // Window Name
w.alpha_(0.9); // Transparency
// w.boxColor_(Color.black);
// BLUE PANEL
e = SCCompositeView(w,Rect(10,50,330,180));
e.background = Color.new255(0,100,150);
// Gradient(Color.red,Color.white);
// TEXT (PREDELAY)
d = SCStaticText(e, Rect(20, 50, 100, 20));
d.stringColor_(Color.white);
d.string = "Predelay";
d.font_(Font("Arial", 12));
// BYPASS BUTTON
f = SCButton(w, Rect(10,3,50,20))
.states_([
["Bypass", Color.white, Color.grey],
["Bypass", Color.white, Color.red],
])
.font_(Font("Arial", 10))
.action_({ arg butt;
butt.value.postln;
});
// SLIDER (PREDELAY)
a = SCRangeSlider(e, Rect(35, 75, 10, 130))
.lo_(0.0)
.hi_(1)
.range_(0.01)
.knobColor_(HiliteGradient(Color.blue, Color.white, Color.red))
.action_({ |slider|
slider.lo=0;
n.value=""++(slider.hi*200) ++"ms";
n.stringColor_(Color.white);
[\sliderLOW, slider.lo, \sliderHI, slider.hi].postln;
});
// NUMBER BOX (PREDELAY)
n = SCTextField(
parent: e,
bounds: Rect(20, 210, 45, 15) // Left Top Width Height
).boxColor_(Color.grey);
// SLIDER (MIX)
b = SCRangeSlider(e, Rect(305, 75, 10, 130))
.lo_(0.0)
.hi_(1)
.range_(0.01)
.knobColor_(HiliteGradient(Color.blue, Color.white, Color.red))
.action_({ |slider|
slider.lo=0;
m.value=""++(slider.hi*100) ++"%";
[\sliderLOW, slider.lo, \sliderHI, slider.hi].postln;
});
// NUMBER BOX (MIX)
m = SCTextField(
parent: e,
bounds: Rect(290, 210, 45, 15) // Left Top Width Height
).boxColor_(Color.grey);
// TEXT (MIX)
g = SCStaticText(e, Rect(300, 50, 100, 20));
g.stringColor_(Color.white);
g.string = "Mix";
g.font_(Font("Arial", 12));
// SLIDER (DENSITY/TIME)
c = SCRangeSlider(e, Rect(120, 200, 120, 10))
.lo_(0)
.range_(0.1)
// .range_(0.01)
.knobColor_(HiliteGradient(Color.blue, Color.white, Color.red))
.action_({ |slider|
slider.lo=0;
o.value=""++(slider.hi*100) ++"%";
[\sliderLOW, slider.lo, \sliderHI, slider.hi].postln;
});
// NUMBER BOX (DENSITY/TIME)
o = SCTextField(
parent: e,
bounds: Rect(200, 175, 45, 15) // Left Top Width Height
).boxColor_(Color.grey);
// TEXT (DENSITY/TIME)
p = SCStaticText(e, Rect(120, 170, 500, 20));
p.stringColor_(Color.white);
p.string = "Density/Time";
p.font_(Font("Arial", 12));
// TEXT (REFLECTIVITY)
q = SCStaticText(e, Rect(120, 50, 100, 20));
q.stringColor_(Color.white);
q.string = "Reflectivity";
q.font_(Font("Arial", 12));
// SLIDER (REFLECTIVITY)
q = SCRangeSlider(e, Rect(135, 75, 10, 50))
.lo_(0.0)
.hi_(1)
.range_(0.01)
.knobColor_(HiliteGradient(Color.blue, Color.white, Color.red))
.action_({ |slider|
slider.lo=0;
q.value=""++(slider.hi*100) ++"%";
q.stringColor_(Color.white);
[\sliderLOW, slider.lo, \sliderHI, slider.hi].postln;
});
// NUMBER BOX (REFLECTIVITY)
q = SCTextField(
parent: e,
bounds: Rect(120, 130, 45, 15) // Left Top Width Height
).boxColor_(Color.grey);
// TEXT (ROOM SIZE)
r = SCStaticText(e, Rect(200, 50, 100, 20));
r.stringColor_(Color.white);
r.string = "Room Size";
r.font_(Font("Arial", 12));
// SLIDER (ROOM SIZE)
r = SCRangeSlider(e, Rect(215, 75, 10, 50))
.lo_(0.0)
.hi_(1)
.range_(0.01)
.knobColor_(HiliteGradient(Color.blue, Color.white, Color.red))
.action_({ |slider|
slider.lo=0;
r.value=""++(slider.hi*200) ++"";
r.stringColor_(Color.white);
[\sliderLOW, slider.lo, \sliderHI, slider.hi].postln;
});
// NUMBER BOX (ROOM SIZE)
r = SCTextField(
parent: e,
bounds: Rect(200, 130, 45, 15) // Left Top Width Height
).boxColor_(Color.grey);
// DROP DOWN MENU (#DEFAULT)
l = [
"#default","-","Next Setting","(Previous Setting","Copy Setting",
"Paste Setting","Reset Setting"
];
sbs = SCPopUpMenu(w,Rect(240,3,100,20));
sbs.items = l;
sbs.background_(Color.grey);
sbs.action = { arg sbs;
};
)
[1] Christian Haines. "Creative Computing: Semester 2 - Week 1 - Graphical User Interface I". Lecture presented at the Electronic Music Unit, University of Adelaide, South Australia, 31st July 2008