Debian Codegraph @

examples/osc/r2.ck

raw
1 //----------------------------------------------------------------------------
2 // name: r-if.ck ('r' is for "receiver")
3 // desc: OpenSoundControl (OSC) receiver example; expects int and float data
4 // note: launch with s.ck (that's the sender)
5 //----------------------------------------------------------------------------
6
7 // the patch
8 SinOsc s => JCRev r => dac;
9 .5 => s.gain;
10 .1 => r.mix;
11
12 // create our OSC receiver
13 OscIn oin;
14 // create our OSC message
15 OscMsg msg;
16 // use port 6449 (or whatever)
17 6449 => oin.port;
18 // create an address in the receiver, expect an int and a float
19 oin.addAddress( "/foo/notes, if" );
20
21 // infinite event loop
22 while( true )
23 {
24 // wait for event to arrive
25 oin => now;
26
27 // grab the next message from the queue.
28 while( oin.recv(msg) )
29 {
30 // expected datatypes
31 // (note: as indicated by "if" in the address string above)
32 int i;
33 float f;
34
35 // fetch the first data element as int
36 msg.getInt(0) => i => Std.mtof => s.freq;
37 // fetch the second data element as float
38 msg.getFloat(1) => f => s.gain;
39
40 // print
41 <<< "got (via OSC):", i, f >>>;
42 }
43 }