Debian Codegraph @

examples/osc/wildcards/s-multi.ck

raw
1 //----------------------------------------------------------------------------
2 // name: s-multi.ck
3 // desc: OSC sender with multiple addresses
4 //----------------------------------------------------------------------------
5
6 // destination host name
7 "localhost" => string hostname;
8 // destination port number
9 6449 => int port;
10
11 // check command line
12 if( me.args() ) me.arg(0) => hostname;
13 if( me.args() > 1 ) me.arg(1) => Std.atoi => port;
14
15 // one send loop
16 spork ~ sendloop( "/foo/notes" );
17 // wait a bit
18 .2::second => now;
19 // another send loop with different address
20 spork ~ sendloop( "/foo/bar" );
21
22 // wait
23 while( true ) 1::second => now;
24
25 // send loop with OSC address
26 fun void sendloop( string oscAddress )
27 {
28 // sender object
29 OscOut xmit;
30 // aim the transmitter at destination
31 xmit.dest( hostname, port );
32 // infinite time loop
33 while( true )
34 {
35 // start the message...
36 xmit.start( oscAddress );
37
38 // add int argument
39 Math.random2( 30, 80 ) => xmit.add;
40 // add float argument
41 Math.random2f( .1, .5 ) => xmit.add;
42
43 // send it
44 xmit.send();
45
46 // advance time
47 0.4::second => now;
48 }
49 }