«Receiving NIMate generated OSC messages» by rev

on 13 Jun'14 12:47 in thereminkinectnimateosc receiver

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//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;
raw 1052 chars (focus & ctrl+a+c to copy)
reception
comments