RedInfoLmu read data from ambient light sensors



Only works on newer portable Mac models running OS X (10.4 or newer).


see also: RedInfoBat RedInfoSms


*kr(trig)

returns 2 channels.  left and right sensor data.

zeros if no sensors installed.

trig asks for a new reading.

note: there is only one reading function internally.  a trigger will cause global reading for all ugens.

it makes little sense to have this ugen running in multiple synths.  use busses.



//--

s.boot;

{RedInfoLmu.kr(Impulse.kr(10)).poll}.play; //update 10 times per second


{SinOsc.ar(RedInfoLmu.kr(Impulse.kr(10))+100, 0, 0.5)}.play;



//--gui test

(

s.waitForBoot{

var w= Window("RedInfoLmu test", Rect(100, 200, 300, 120));

var c= [0, 2000, 'lin', 0, 0].asSpec;

var l= EZSlider(w, Rect(0, 10, 280, 20), "left", c);

var r= EZSlider(w, Rect(0, 40, 280, 20), "right", c);

w.view.background= Color.red(0.75);

w.front;

SynthDef(\ambientlightsensor, {|rate= 5| //update rate

var trig= Impulse.kr(rate);

SendReply.kr(trig, 'lr', RedInfoLmu.kr(trig));

}).play(s);

OSCresponder(s.addr, 'lr', {|t, resp, m|

{

l.value= m[3];

r.value= m[4];

}.defer;

}).add;

}

)