JITuio

superclass: [TUIObject]

/*

Author:

2006

Till Bovermann

SonEnvir IEM

KUG Graz

Austria

*/

a JIT interface to TUIOs.

///////////////////////

(

/*

TUIOIDistance.distFunc = {|distance, isValid, parts| postf("%<->% : %\n", parts[0].id, parts[1].id, distance)};

*/

t = TUIOServer("_ixyzuvw", JITuio, TUIOIDistance);

t.start;

// inspect its behavior

//i = t.inspect;

g = t.gui;

)

t.stop;

t.start;

JITuio.action = {1.postln}

JITuio.action = nil

p = ProxySpace.push(s)

s.boot

~a.play;

~b.play;

(

~a = {|freqs = #[100,0], t_trig = 0|

EnvGen.kr(Env.perc, gate: t_trig) * SinOsc.ar(freqs.lag, 0, 3).softclip * 0.5

};

~b = {|freqs = #[100,0], t_trig = 0|

EnvGen.kr(Env.perc, gate: t_trig) * Saw.ar(freqs.lag).softclip * 0.5

}

)

(

var fSpecs = [[100, 500, \exp].asSpec,[100, 500, \exp].asSpec];

JITuio.action = {|tuio|

var freqs;

(tuio.id == 100).if{

freqs = fSpecs.collect{|spec, i| spec.map(tuio.pos[i])};

~a.group.setn(\freqs, freqs);

~a.group.set(\t_trig, 1);

};

(tuio.id == 101).if{

freqs = fSpecs.collect{|spec, i| spec.map(tuio.pos[i])};

~b.group.setn(\freqs, freqs);

~b.group.set(\t_trig, 1);

}

}

)

// now create two TUIOs with id 100 / 101 and move them around.

~a.unset(\freqs)

~a.free(3);

~b.free(3);

~a.play

p.clear;

//////////////////////////////////////////////////////

q = q ? ();

(

q.lastSymAxis = [0, 0, 1];

q.symAxis = [1, 0, 0];

q.ltime = SystemClock.seconds;

JITuio.action = {|tuio| (tuio.id == 1).if{

var time = SystemClock.seconds;

var flipAngleVel;

// symmetric axis is determined as z Axis;

q.symAxis = tuio.rotMat.flop.last;

flipAngleVel = acos((q.symAxis * q.lastSymAxis).sum) / (time - q.ltime).max(0.0001);

// flipAngleVel = acos((q.symAxis * q.lastSymAxis).sum);

q.lastSymAxis = q.symAxis;

q.ltime = time;

// flipAngleVel.postln;

~a.group.set(\freqs, (flipAngleVel*4).midicps )

}}

)