// title: Receiving NIMate generated OSC messages // author: rev // description: // Simple Theremin receiving OSC messages generated by NIMate via a MS Kinect. // The code is raw and contains arbitrary mapping. Works with "Full Skeleton" mode. Can be adapted to "OSC control" mode by changing "/Right_hand" and "Left_Hand" in the OSCDefs with the correct joint names. In that case You'd also need sigle channel buses. // OSCDef and Bus definition and mapping could be of interest to whoever wants to map NIMate OSC to the SuperCollider. // code: //NIMate "Full Skeleton" Kinect Theremin //Start server s.boot; //Start buses and OSC receivers b=Bus.control(s,3); c=Bus.control(s,3); OSCdef.new( \rh_xyz, { |msg, time, addr, recvPort| postln(msg); b.setnSynchronous([msg[1],(msg[2]+1)/2,msg[3]+0.3]); }, "/Right_Hand", nil, 7000 ); OSCdef.new( \lh_xyz, { |msg, time, addr, recvPort| postln(msg); c.setnSynchronous([msg[1]+0.9,(msg[2]+1)/2,msg[3]+0.3]); }, "/Left_Hand", nil, 7000 ); OSCdef(\lh_xyz).enable; OSCdef(\rh_xyz).enable; //Synth definition and bus mapping SynthDef(\theremin, { |ctrl=#[0,0,0], ctrr=#[0,0,0]| var f, a, vibrate, tremrate; f = LinExp.kr(ctrr[0],0,1,100,1000); vibrate = LinExp.kr(ctrl[0],0,1,1,500); tremrate = 100*ctrl[1]; a = SinOsc.ar(f + (f * SinOsc.ar(vibrate,0,0.1)),0, mul: ctrr[1])* SinOsc.kr(tremrate); Out.ar([0,1], a) }).add; x=Synth.new(\theremin); x.map(\ctrr,b); x.map(\ctrl,c); //Clean up x.free; b.free; c.free; s.stop; s.quit;