Debian Codegraph @

examples/osc/one2many/s-sender.ck

raw
1 //----------------------------------------------------------------------------
2 // name: s-sender.ck
3 // desc: OSC example: one (sender) to many (receivers);
4 // note: launch with one r.ck running per receiver machine
5 //
6 // author: Ge Wang (https://ccrma.stanford.edu/~ge/)
7 // date: spring 2022
8 //----------------------------------------------------------------------------
9
10 // destination port number
11 6449 => int port;
12
13 // array of destination hostnames
14 string hostnames[0];
15
16 //----------------------------------------------------------------------------
17 // appending names of destinations
18 //----------------------------------------------------------------------------
19
20 // localhost == this machine
21 hostnames << "localhost";
22
23 // external hosts (add as many as needed)
24 // hostnames << "albacore.local";
25 // hostnames << "192.168.0.10";
26 // hostnames << "host.domain.edu";
27 // ...
28
29 // sender object
30 OscOut xmit[hostnames.size()];
31 // iterate over the OSC transmitters
32 for( int i; i < xmit.size(); i++ )
33 {
34 // aim the transmitter at destination
35 xmit[i].dest( hostnames[i], port );
36 }
37
38 // infinite time loop
39 while( true )
40 {
41 // for each xmit
42 for( int i; i < xmit.size(); i++ )
43 {
44 // start the message...
45 xmit[i].start( "/foo/notes" );
46
47 // add int argument
48 Math.random2( 30, 80 ) => xmit[i].add;
49 // add float argument
50 Math.random2f( .1, .5 ) => xmit[i].add;
51
52 // send it
53 xmit[i].send();
54 }
55
56 // advance time
57 250::ms => now;
58 }