.cc - week two.
Unfortunately I missed the class where GUI's were linked to Synths - here's my attempt nonetheless:
wk2.mp3 (282 kB) | wk2UI(2).rtf
(
SynthDef("fmStyle", {
// Arguments
arg cFreq = 440, // Carrier Frequency
cAmp = 0.1, // Carrier Amplitude
mFreq = 440, // Modulator Frequency
mAmp = 0.1; // Modulator Amplitude
// Variables
var car, // Oscillator
mod, // Modulator
env; // Envelope
// Unit generators
mod = SinOsc.ar(
freq: mFreq,
mul: mAmp
);
car = SinOsc.ar(
freq: cFreq + mod,
mul: cAmp
);
// Output
Out.ar(
bus: [0,1],
channelsArray: car
);
}).load(s);
)
(
~g = Synth("fmStyle");
)
(
// Variables
var window, sliderData, flowLayout, line, titleBox, colourMain = Color(0.0,0.714,0.96);
// Build Slider Data
sliderData = [
// Label Min Max InitMin Param
["Carrier Freq", [10.0, 5000.0], 200.0, \cFreq],
["Carrier Amp", [0.0, 1.0], 0.1, \cAmp],
["Mod Freq", [0.1, 200.0], 0.1, \mFreq],
["Mod Amp", [0.1, 100.0], 0.1, \mAmp]
];
// Window Setup
window = GUI.window.new(
name: "Simple Controller", //Name
bounds: Rect(20, 400, 420, 200)
).front;
flowLayout = FlowLayout(window.view.bounds);
flowLayout.gap_(Point(0, 0)); //Dave's gap code
window.view.background = colourMain; //BG Colours
window.view.decorator = flowLayout;
//Enter the interface title:
titleBox = SCStaticText(
parent: window,
bounds: Rect(20, 100, 410, 65)
);
titleBox.stringColor_(Color.white);
titleBox.background_(colourMain);
titleBox.string_("1234567890qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM".scramble);
titleBox.font_(Font("Arial Black", 35));
//Make a line:
line = SCStaticText(
parent: window,
bounds: Rect(2,2,440,2)
);
line.background_(colourMain);
// Build Control consisting of Label, Min NumBox, Range Slider, Max NumBox,
sliderData.do({
// Arguments
arg val, idx;
// Variables
var guiEZ, specGUI;
// Build Slider
guiEZ = EZSlider(
window, // window
400 @ 24, // dimensions
val[0], // label
ControlSpec(val[1][0], val[1][1], \lin), // control spec
{|ez| ~g.set(val[3], ez.value);}, // action
val[2] // initial Value
);
});
)
Thanks Dave.
.sources.
Dowling, Dave 11.08.08, " Creative Computing IIIB – Week 2 – Semester 2, 2008: “Graphical User Interfaces (2),” http://notesdontmatter.blogspot.com/
iieiwrmeieweeiimeemmwreiweremweireeemeimwieewwrwweereireeiimeewmiwwwemwiewimeeeremeiewmemweewieewerwemwiimiewmeiwireiiwrrewmwewree |
15.8.08
Simple SuperCollider GUI
copywrite 12:41 pm
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment