Chris@4
|
1 /*
|
Chris@4
|
2 * Copyright (C) 2004 Steve Harris, Uwe Koloska
|
Chris@4
|
3 *
|
Chris@4
|
4 * This program is free software; you can redistribute it and/or modify
|
Chris@4
|
5 * it under the terms of the GNU Lesser General Public License as
|
Chris@4
|
6 * published by the Free Software Foundation; either version 2.1 of the
|
Chris@4
|
7 * License, or (at your option) any later version.
|
Chris@4
|
8 *
|
Chris@4
|
9 * This program is distributed in the hope that it will be useful,
|
Chris@4
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Chris@4
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Chris@4
|
12 * GNU Lesser General Public License for more details.
|
Chris@4
|
13 *
|
Chris@4
|
14 * $Id$
|
Chris@4
|
15 */
|
Chris@4
|
16
|
Chris@4
|
17 #include <stdio.h>
|
Chris@4
|
18 #include <stdlib.h>
|
Chris@4
|
19 #include <unistd.h>
|
Chris@4
|
20
|
Chris@4
|
21 #include "lo/lo.h"
|
Chris@4
|
22
|
Chris@4
|
23 const char testdata[5] = "ABCDE";
|
Chris@4
|
24
|
Chris@4
|
25 int main(int argc, char *argv[])
|
Chris@4
|
26 {
|
Chris@4
|
27 /* build a blob object from some data */
|
Chris@4
|
28 lo_blob btest = lo_blob_new(sizeof(testdata), testdata);
|
Chris@4
|
29
|
Chris@4
|
30 /* an address to send messages to. sometimes it is better to let the server
|
Chris@4
|
31 * pick a port number for you by passing NULL as the last argument */
|
Chris@4
|
32 // lo_address t = lo_address_new_from_url( "osc.unix://localhost/tmp/mysocket" );
|
Chris@4
|
33 lo_address t = lo_address_new(NULL, "7770");
|
Chris@4
|
34
|
Chris@4
|
35 if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'q') {
|
Chris@4
|
36 /* send a message with no arguments to the path /quit */
|
Chris@4
|
37 if (lo_send(t, "/quit", NULL) == -1) {
|
Chris@4
|
38 printf("OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));
|
Chris@4
|
39 }
|
Chris@4
|
40 } else {
|
Chris@4
|
41 /* send a message to /foo/bar with two float arguments, report any
|
Chris@4
|
42 * errors */
|
Chris@4
|
43 if (lo_send(t, "/foo/bar", "ff", 0.12345678f, 23.0f) == -1) {
|
Chris@4
|
44 printf("OSC error %d: %s\n", lo_address_errno(t), lo_address_errstr(t));
|
Chris@4
|
45 }
|
Chris@4
|
46
|
Chris@4
|
47 /* send a message to /a/b/c/d with a mixtrure of float and string
|
Chris@4
|
48 * arguments */
|
Chris@4
|
49 lo_send(t, "/a/b/c/d", "sfsff", "one", 0.12345678f, "three",
|
Chris@4
|
50 -0.00000023001f, 1.0);
|
Chris@4
|
51
|
Chris@4
|
52 /* send a 'blob' object to /a/b/c/d */
|
Chris@4
|
53 lo_send(t, "/a/b/c/d", "b", btest);
|
Chris@4
|
54
|
Chris@4
|
55 /* send a jamin scene change instruction with a 32bit integer argument */
|
Chris@4
|
56 lo_send(t, "/jamin/scene", "i", 2);
|
Chris@4
|
57 }
|
Chris@4
|
58
|
Chris@4
|
59 return 0;
|
Chris@4
|
60 }
|
Chris@4
|
61
|
Chris@4
|
62 /* vi:set ts=8 sts=4 sw=4: */
|