Debian Codegraph @

examples/osc/wildcards/r-wildcards.ck

raw
1 //----------------------------------------------------------------------------
2 // name: r-wildcards.ck
3 // desc: OSC receiver with wildcards address pattern
4 //
5 //.requires: chuck-1.5.2.2 or higher
6 //----------------------------------------------------------------------------
7
8 // the patch
9 SinOsc s => JCRev r => dac;
10 .5 => s.gain;
11 .1 => r.mix;
12
13 // create our OSC receiver
14 OscIn oin;
15 // create our OSC message
16 OscMsg msg;
17 // use port 6449 (or whatever)
18 6449 => oin.port;
19 // address with wildcard pattern
20 oin.addAddress( "/foo/*" );
21
22 // infinite event loop
23 while( true )
24 {
25 // wait for event to arrive
26 oin => now;
27
28 // grab the next message from the queue.
29 while( oin.recv(msg) )
30 {
31 // print stuff
32 cherr <= "received OSC message: \"" <= msg.address <= "\" "
33 <= "typetag: \"" <= msg.typetag <= "\" "
34 <= "arguments: " <= msg.numArgs() <= IO.newline();
35
36 // check typetag for specific types
37 if( msg.typetag == "if" )
38 {
39 // expected datatypes: int float
40 // (note: as indicated by "if")
41 int i;
42 float f;
43
44 // fetch the first data element as int
45 msg.getInt(0) => i => Std.mtof => s.freq;
46 // fetch the second data element as float
47 msg.getFloat(1) => f => s.gain;
48
49 // print
50 cherr <= i <= " " <= f <= IO.newline();
51 }
52 }
53 }