RedInfoSms2 read scaled raw data from sudden motion sensor
superclass: RedInfoSms
Only works on newer portable Mac models running OS X (10.4 or newer).
Using UniMotion 0.4.1 (http://unimotion.sourceforge.net/) by Lincoln Ramsay
Version 2 notes:
This version reverses the backwards polarity of x and increases the range of the older machines to match the MacBook [Pro] sensor.
see also: RedInfoSms RedInfoSms3 RedInfoBat RedInfoLmu
*kr(trig)
returns 3 channels. x, y and z sensor data (integers).
zeros if no sensors installed.
trig asks for a new reading. the faster you ask, the more cpu it will require.
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;
{RedInfoSms2.kr(Impulse.kr(2)).poll; DC.ar(0)}.play; //update twice a second
//very sensitive but will require a bit extra of the cpu
{Mix(SinOsc.ar(RedInfoSms2.kr(Impulse.kr(50))+500, 0, 0.4))}.play;
//less cpu with lower trig rate and using ramp to smooth data
{Mix(SinOsc.ar(Ramp.kr(RedInfoSms2.kr(Impulse.kr(10)))+500, 0, 0.4))}.play;
//--gui test
(
var w= Window("RedInfoSms2 scaled data", Rect(100, 200, 300, 120));
var c= [-999, 999, 'lin', 0, 0].asSpec;
var x= EZSlider(w, Rect(0, 10, 280, 20), "x", c);
var y= EZSlider(w, Rect(0, 40, 280, 20), "y", c);
var z= EZSlider(w, Rect(0, 70, 280, 20), "z", c);
w.view.background= Color.red(0.75);
w.front;
SynthDef(\suddenmotionsensor, {|rate= 15| //update rate
var trig= Impulse.kr(rate);
SendReply.kr(trig, 'xyz', RedInfoSms2.kr(trig));
}).play(s);
OSCresponder(s.addr, 'xyz', {|t, resp, m|
{
x.value= m[3];
y.value= m[4];
z.value= m[5];
}.defer;
}).add;
)