[sc-users] a script that rules the world

Fredrik Olofsson f at fredrikolofsson.com
Fri Feb 9 16:00:09 PST 2007


a quick hack with inspiration from code found on the processing forum.
needs cocoa collider and google earth.

i'm sure someone will make something much cooler than the a/v mapping  
below.  please share.  i blame my 4 year old computer - playback  
stutters too much.



//--init
(
s.waitForBoot{
	SynthDef(\redGoogleKick, {|out= 0, t_trig= 1, freq= 50, dur= 0.5,  
envFreq= 500, envAtk= 0.005, envRel= 0.1, amp= 1|
		var z, env, fenv, click;
		env= EnvGen.ar(Env.linen(0, 0, dur, amp), t_trig);
		fenv= EnvGen.kr(Env([envFreq, envFreq-freq*0.275+freq, freq],  
[envAtk, envRel]), t_trig);
		click= EnvGen.ar(Env.linen(0, 0, 0), t_trig);
		z= SinOsc.ar(fenv, 0, env, click);
		Out.ar(out, z);
	}).store;
	SynthDef(\redGoogleSynth, {|out= 0, t_trig= 1, freq= 200, atk=  
0.005, dec= 0.5, pm= 0.5, amp= 1|
		var z, env, pmod;
		env= EnvGen.kr(Env.perc(atk, dec, 1, -3), t_trig);
		pmod= LFSaw.ar(freq*2.pow(TIRand.kr(1, 3, t_trig)), 0, env*pm);
		z= SinOsc.ar(freq, pmod, env);
		Out.ar(out, z*amp);
	}).store;
	SynthDef(\redGoogleDelay, {|in= 0, out= 0, depth= 3, time= 0.45,  
amp= 1, dist= 2, pan= 0|
		var src, z;
		src= In.ar(in, 1);
		z= CombL.ar(src, 1.5, time.min(1.5), depth, amp, src);
		Out.ar(out, Pan2.ar(Clip.ar(z*dist, -1, 1), pan));
	}, #[\ir, \ir, 0, 0.5, 0, 0, 0]).store;
};
a= NSAppleScript.alloc;
f= {|cmd|
	{a.initWithSource_("tell application \"Google Earth\"\n"++cmd+ 
+"\nend tell").executeAndReturnError_(nil)}.defer;
};
f.("open");
)

//--run (wait until localhost and googlearth started, also disable  
all overlays in googleearth)
(
f.("SetViewInfo{latitude:0, longitude:0, distance:10000000, tilt:0,  
azimuth:0} speed 5");
d= Synth(\redGoogleDelay, [\out, 0, \in, 32]);
k= Synth(\redGoogleKick, [\t_trig, 0]);
e= Synth(\redGoogleSynth, [\out, 32, \t_trig, 0]);
Tdef(\redGoogle).play;
Tdef(\redGoogle, {
	var dist;
	300.do{|i|
		if(i%25==0, {
			if(i%100==0, {
				k.set(\t_trig, 1, \amp, 0.1, \out, 32, \freq, 2000, \dur, 1.5,  
\envAtk, 0.005, \envRel, 0.2);
			});
			e.set(\t_trig, 1, \freq, [500, 600, 700].wrapAt(i), \amp, 0.5,  
\dec, 0.5, \pm, 0.2);
			f.("MoveCamera{"++0.5.rand2++", "++0.5.rand2++"}");
		});
		(1/25).wait;
	};
	f.("SetViewInfo{latitude:0, longitude:0, distance:10000000} speed  
0.5");
	300.do{|i|
		if(i%25==0, {
			dist= [400, 600, 700, 800].wrapAt(i);
			k.set(\t_trig, 1, \amp, 1, \out, 32, \freq, 50, \dur, 0.5,  
\envAtk, 0.005, \envRel, 0.1);
			e.set(\t_trig, 1, \freq, dist, \amp, 0.5, \dec, 0.5, \pm, 1-(i/300));
			f.("SetViewInfo{latitude:0, longitude:0, distance:"++8000000++",  
tilt:"++45.rand++", azimuth:0} speed 5");
		}, {
			if(i%25==1, {
				f.("SetViewInfo{latitude:0, longitude:"++([100, -100].choose)++",  
distance:"++5000000++", tilt:0, azimuth:10} speed 0.5");
			});
		});
		(1/25).wait;
	};
	d.set(\dist, 4);
	f.("SetViewInfo{latitude:52.45, longitude:-1.93, distance:300, tilt: 
0, azimuth:0} speed 0.5");
	50.do{|i|
		if(i%25==0, {
			k.set(\t_trig, 1, \amp, 1, \out, 32, \freq, 50, \dur, 0.5,  
\envAtk, 0.005, \envRel, 0.1);
			e.set(\t_trig, 1, \freq, [100, 500, 600, 700].wrapAt(i), \amp,  
0.5, \dec, 1.1, \pm, 2);
		});
		(1/25).wait;
	};
	d.set(\dist, 5);
	500.do{|i|
		if(i%25==0, {
			k.set(\t_trig, 1, \amp, 1, \out, 32, \freq, 50, \dur, 0.5,  
\envAtk, 0.005, \envRel, 0.1);
			e.set(\t_trig, 1, \freq, [200, 500, 600, 700].wrapAt(i), \amp,  
0.5, \dec, 1.1, \pm, 2);
			f.("SetViewInfo{latitude:52.45, longitude:-1.93, distance:"+ 
+200.rrand(300)++", tilt:"++(i%45)++", azimuth:"++(i%180)++"} speed 1");
		}, {
			if(i%20==18, {
				k.set(\t_trig, 1, \amp, 0.3, \out, [0, 1].choose, \freq, [2100,  
100].wrapAt(i), \dur, 0.9, \envAtk, 0.1.linrand, \envRel, i%3);
			})
		});
		(1/25).wait;
	};
})
)

//--stop
(
[d, k, e].do{|x| x.free};
Tdef(\redGoogle).stop;
)


_f


   #|
      fredrikolofsson.com     klippav.org     musicalfieldsforever.com
   |#



More information about the sc-users mailing list