domingo, 10 de julio de 2011

hackpact mx

codigo por Eduardo H Obieta, reBlogeado de http://hackpact.laad.com.mx #hackPactMx jul 01 -- jul 31 2011
/////////////////////////////

Hackpact Day#4 LAAd from Eduardo H Obieta (LAAd)
/////////////////////////////
////escrito en supercollider sobre OSX
//estudiando un poco mas acerca de la comunicación OSC de SuperCollider y Fluxus
//código SuperCollider
s.boot;
f=Server("fluxus", NetAddr("127.0.0.1", 4444));
(
(SynthDef(\synth0,{|wmul=0.5, wsfreq=0.1, wsmul=2000, wsadd=2600, lmul=0.035, pan=0|
var son, son1, son2, paneo, freq1, mul1;
son=HPF.ar(WhiteNoise.ar(wmul,0),SinOsc.kr(wsfreq,0,wsmul,wsadd),lmul,0);
son=son+Dust.ar(15);
paneo=Pan2.ar(son,pan);
Out.ar(0,paneo);
}).send(s)
);
(SynthDef(\synth1, {|freq=120, mul=0.5, pan=0|
var env, paneo, son1, dem;
son1=SinOsc.ar(freq,0,mul)+SinOsc.ar(freq*2,0,0.1);
paneo=Pan2.ar(son1,pan);
env=EnvGen.kr(Env.perc(0.005, 0.2, 1, -4),doneAction:2);
Out.ar(0,paneo);
}).send(s)
);
(SynthDef(\synth2, {|freq=40, dur=0.2, mul=0.55, amp=1|
var sig, env;
sig=SinOsc.ar(freq,pi/2,mul)+Saw.ar(freq,0.121)!2;
env=EnvGen.kr(Env.perc(0.05,dur,1,-8),doneAction:2);
Out.ar(0,sig*env*1*amp);
}).send(s)
);
(SynthDef(\synth3, {|freq=80, dur=0.4, amp=1, factor=1.2, ampB=0.3, durB=0.05|
var sig, env;
sig=Pan2.ar(Mix(SinOsc.ar(XLine.kr(freq*factor,freq,dur)*[1,1.1,1.25],pi/2,amp/3)),0);
sig=sig+EnvGen.ar(Env([1,0],[0.05]));
sig=sig+(BrownNoise.ar(ampB)*EnvGen.kr(Env.perc(0.01,durB)));
env=EnvGen.kr(Env.perc(0.01,dur),doneAction:2);
Out.ar(0,sig*env)
}).send(s)
);
(SynthDef(\synth4, {|freq=12000, mul=0.5, pan=0, rel=0.2|
var sig, env;
sig=HPF.ar(WhiteNoise.ar,freq,mul,0);
sig=Pan2.ar(sig,pan);
env=EnvGen.kr(Env.perc(0.01,rel,0.7,-8),doneAction:2);
Out.ar(0,sig*env);
}).send(s);
);
(SynthDef(\synth5, {|freq=120, mul=0.5, pan=0|
var env, paneo, son1;
son1=Saw.ar(freq*0.25, mul, 0)*SinOsc.ar(60.midicps);
paneo=Pan2.ar(son1,pan);
env=EnvGen.kr(Env.perc(0.01, 1, 0.75, -10),doneAction:2);
Out.ar(0,paneo*env);
}).send(s)
);
)
//TDEF
(
(j=Pseq([Pseq([60,64,67,69],8),Pseq([63,68,72,75],8)],inf).asStream;
k=Pseq([0.2,0.2,0.4,0.2,0.4,0.2,0.2,0.2],inf).asStream;
a=Tdef(\fluxus, {
inf.do {
k.next.wait;
Synth(\synth1,[\freq, j.next]);
f.sendMsg("/uno", j.next);
}}));
(l=Pseq([60,65,69,72,60,65,69,75,60,65,69,72],inf).asStream;
m=Prand([0.4,0.2],inf).asStream;
b=Tdef(\fluxus2, {
inf.do {
m.next.wait;
Synth(\synth2, [\freq, l.next]);
f.sendMsg("/dos", l.next);
}}));
(n=Pseq([15,30,45,60],inf).asStream;
o=Pseq([0.1,0.2,0.1,0.4,0.2,0.2,0.2,0.1,0.2,0.4],inf).asStream;
c=Tdef(\fluxus3, {
inf.do {
o.next.wait;
Synth(\synth3,[\freq, 1.5*n.next]);
f.sendMsg("/tre", n.next);
}}));
(p=Pseq([12000,14000,17000],inf).asStream;
q=Pseq([0.1,0.1,0.1,0.1,0.05,0.05,0.1,0.1,0.05],inf).asStream;
d=Tdef(\fluxus4, {
inf.do {
q.next.wait;
Synth(\synth4,[\freq, p.next]);
f.sendMsg("/cua", p.next);
}}));
(
u=Pseq([0.1,0.1,0.2,0.2,0.1,0.1,0.2,0.1,0.5],inf).asStream;
e=Tdef(\fluxus5, {
inf.do {
u.next.wait;
t=([84,89,93,96,101,103,105]).choose;
Synth(\synth5,[\freq, t.midicps]);
f.sendMsg("/cin", t.next);
}}));
)
z=Synth(\synth0).play;
a.play
b.play
c.play
d.play
e.play

a.stop
b.stop
c.stop
d.stop
e.stop
z.free

s.quit;
//código "fluxus"
(clear)
(osc-source "4444")
(define rotx 0)
(define roty 0)
(define rotz 0)
(define esc1 0)
(define esc2 0)
(define (hackpact)
(clear-colour (* 0.25 (flxrnd)))
(with-state
(rotate (vector (+ (* 5 (time)) (* 0.2 esc1)) (* 45 (time)) 0))
(cond ((osc-msg "/tre")
(set! esc1 (osc 0))))
(scale (vector 1 (* 0.5 esc1) 0.01))
(push)
(translate (vector -21 0 -180))
(for ((n (in-range 20)))
(translate (vector 2 0 0))
(draw-cube))
(pop)
)
(with-state
(cond ((osc-msg "/cin")
(set! esc2 (* 0.5 (osc 0)))))
(scale (vector 1 0.2 0.2))
(push)
(hint-none)
(hint-wire)
(rotate (vector -70 0 0))
(translate (vector 0 -40 0))
(for ((n (in-range 60)))
(scale (vector (* 0.025 esc2) 1 0.2))
(translate (vector 0 2 0))
(draw-cube))
(pop))
(with-state
(push)
(hint-wire)
(cond ((osc-msg "/uno")
(set! rotx (osc 0))))
(cond ((osc-msg "/dos")
(set! roty (osc 0))))
(cond ((osc-msg "/tre")
(set! rotz (osc 0))))
(scale (vector 4 (* 0.03 rotx) 5))
(colour (vector (* (* 0.02 rotx) (sin (time)))
(* (* 0.02 roty) (cos (time)))
(* (* 0.02 rotz) (sin (time)))))
(rotate (vector (* 0.2 (* (sin (time)) rotx)) (* roty (* 0.5 (cos (time)))) rotz))
(draw-cube)
(pop)))
(every-frame (hackpact))

No hay comentarios:

Publicar un comentario