CC3 Week 7 - GUI III
I have incorporated the IXI GUI code of a fancy spinning circle with a waveform oscillating. The GUI doesn't have any function in the patch I have just used it for visual feedback. The animation goes for as long as the duration of the note. I tried to change some of the parameters in the IXI code to change the way it behaves but for some reason SuperCollider kept crashing. So I have used the default code and have just changed the dimensions and colour.
Incase you forgot, you trigger the notes by clicking on the background and control the frequency and duration of the notes using the sliders. The drop down menu changes the timbre of the notes.
//PINK NOISE
(
// Delayed Noise Generator - Envelope > Noise Generator > Delay
SynthDef("plucked-pink", {
// Arguments
arg midiPitch = 80, duration = 10;
// Variables
var burstEnv, noise, delay, att = 0, dec = 0.001, out,
delayTime = midiPitch.midicps.reciprocal, trigRate = 1;
// Envelope
burstEnv = EnvGen.kr(
envelope: Env.perc(att, dec)
);
// Noise Generator
noise = PinkNoise.ar(
mul: burstEnv
);
// Delay
delay = CombL.ar(
in: noise,
maxdelaytime: delayTime,
delaytime: delayTime,
decaytime: duration,
add: noise
);
// Output
Out.ar(
bus: 0,
channelsArray: delay.dup
);
}).send(s);
//WHITE NOISE
// Delayed Noise Generator - Envelope > Noise Generator > Delay
SynthDef("plucked-white", {
// Arguments
arg midiPitch = 80, duration = 10;
// Variables
var burstEnv, noise, delay, att = 0, dec = 0.001, out,
delayTime = midiPitch.midicps.reciprocal, trigRate = 1;
// Envelope
burstEnv = EnvGen.kr(
envelope: Env.perc(att, dec)
);
// Noise Generator
noise = WhiteNoise.ar(
mul: burstEnv
);
// Delay
delay = CombL.ar(
in: noise,
maxdelaytime: delayTime,
delaytime: delayTime,
decaytime: duration,
add: noise
);
// Output
Out.ar(
bus: 0,
channelsArray: delay.dup
);
}).send(s);
//BROWN NOISE
// Delayed Noise Generator - Envelope > Noise Generator > Delay
SynthDef("plucked-brown", {
// Arguments
arg midiPitch = 80, duration = 10;
// Variables
var burstEnv, noise, delay, att = 0, dec = 0.001, out,
delayTime = midiPitch.midicps.reciprocal, trigRate = 1;
// Envelope
burstEnv = EnvGen.kr(
envelope: Env.perc(att, dec)
);
// Noise Generator
noise = BrownNoise.ar(
mul: burstEnv
);
// Delay
delay = CombL.ar(
in: noise,
maxdelaytime: delayTime,
delaytime: delayTime,
decaytime: duration,
add: noise
);
// Output
Out.ar(
bus: 0,
channelsArray: delay.dup
);
}).send(s);
//CLIP NOISE
// Delayed Noise Generator - Envelope > Noise Generator > Delay
SynthDef("plucked-clip", {
// Arguments
arg midiPitch = 80, duration = 10;
// Variables
var burstEnv, noise, delay, att = 0, dec = 0.001, out,
delayTime = midiPitch.midicps.reciprocal, trigRate = 1;
// Envelope
burstEnv = EnvGen.kr(
envelope: Env.perc(att, dec)
);
// Noise Generator
noise = ClipNoise.ar(
mul: burstEnv
);
// Delay
delay = CombL.ar(
in: noise,
maxdelaytime: delayTime,
delaytime: delayTime,
decaytime: duration,
add: noise
);
// Output
Out.ar(
bus: 0,
channelsArray: delay.dup
);
}).send(s);
//GREY NOISE
// Delayed Noise Generator - Envelope > Noise Generator > Delay
SynthDef("plucked-grey", {
// Arguments
arg midiPitch = 80, duration = 10;
// Variables
var burstEnv, noise, delay, att = 0, dec = 0.001, out,
delayTime = midiPitch.midicps.reciprocal, trigRate = 1;
// Envelope
burstEnv = EnvGen.kr(
envelope: Env.perc(att, dec)
);
// Noise Generator
noise = GrayNoise.ar(
mul: burstEnv
);
// Delay
delay = CombL.ar(
in: noise,
maxdelaytime: delayTime,
delaytime: delayTime,
decaytime: duration,
add: noise
);
// Output
Out.ar(
bus: 0,
channelsArray: delay.dup
);
}).send(s);
// w.close;
// WHOLE WINDOW
w = SCWindow.new.front;
w.bounds = Rect(170,150,450,280);
w.name_("Strings II");
w.alpha_(0.8);
p = ParaSpace.new(w, bounds: Rect(10,50,430,210));
p.setShape_("circle");
36.do({arg i;
p.createNode(3+(i*10), 130)
});
35.do({arg i;
p.createConnection(i, i+1);
});
p.setBackgrDrawFunc_({
10.do{
Color.blue(rrand(0.0, 1), rrand(0.0, 0.5)).set;
Pen.addWedge(200@150, rrand(10, 100), 2pi.rand, 2pi.rand);
Pen.perform([\stroke, \fill].choose);
}
});
t = Task({
inf.do({arg i;
36.do({arg j;
(3+((j%36)*10));
p.setNodeLoc_(j, 3+((j%36)*10), ((i*j/100).sin*120)+130);
});
0.01.wait;
})
}, AppClock);
//// PANEL
//e = SCCompositeView(w,Rect(10,50,430,210));
//e.background = Color.new255(100,0,50);
////Gradient(Color.blue,Color.black);
// TRIGGER BUTTON
f = SCButton(w, Rect(10,50,430,210))
.states_([
[" ", Color.white, Color.new255(10,0,100,0.1)]
])
.font_(Font("Arial", 10))
.action_({r.reset;
r.play;
~noisetype.switch(0,{Synth("plucked-pink", [\midiPitch, ~pitch, \duration, ~dur])},
1,{Synth("plucked-white", [\midiPitch, ~pitch, \duration, ~dur])},
2,{Synth("plucked-brown", [\midiPitch, ~pitch, \duration, ~dur])},
3,{Synth("plucked-clip", [\midiPitch, ~pitch, \duration, ~dur])},
4,{Synth("plucked-grey", [\midiPitch, ~pitch, \duration, ~dur])});
});
// DROP DOWN MENU
l = [
"Twang","Harsh","Warm","Tin","Nylon"];
m = SCPopUpMenu(w,Rect(10,10,150,20));
m.items = l;
m.background_(Color.new255(10,0,100));
m.stringColor_(Color.white);
m.action = { arg m;
~noisetype = m.value.postln};
//c.value=""++(slider.hi) ++"Hz";
//PITCH
c = SCTextField(w, Rect(350, 100, 50, 20));
a = SCSlider(w, Rect(40, 100, 300, 20))
.focusColor_(Color.red(alpha:0.2))
.action_({
c.value_(""++((a.value*70)+30).midicps.round(0.1)++"Hz");
~pitch = ((a.value*70)+30)
});
//DURATION
d = SCTextField(w, Rect(350, 200, 50, 20));
b = SCSlider(w, Rect(40, 200, 300, 20))
.focusColor_(Color.red(alpha:0.2))
.action_({
d.value_(""++((b.value*10)+0.1).round(0.1)++"s");
~dur = ((b.value*10)+0.1)
});
r = Routine({
t.resume;
~dur.wait;
t.pause;});
a.valueAction = 0.5;
b.valueAction = 0.5;)
[1] Christian Haines. "Creative Computing: Semester 2 - Week 7 -GUI III". Lecture presented at the Electronic Music Unit, University of Adelaide, South Australia, 11th September 2008