Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 99 lines (74 sloc) 2.381 kB
ab0fe60 @yaxu there
yaxu authored
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <string.h>
5 #include <lo/lo.h>
6
7 #include "server.h"
f4296e1 @yaxu foo
yaxu authored
8 #include "audio.h"
ab0fe60 @yaxu there
yaxu authored
9
10 void error(int num, const char *m, const char *path);
11
12 int trigger_handler(const char *path, const char *types, lo_arg **argv,
13 int argc, void *data, void *user_data);
14
15 int generic_handler(const char *path, const char *types, lo_arg **argv,
16 int argc, void *data, void *user_data);
17
18 /**/
19
20 void error(int num, const char *msg, const char *path) {
21 printf("liblo server error %d in path %s: %s\n", num, path, msg);
22 }
23
24 /**/
25
26 int generic_handler(const char *path, const char *types, lo_arg **argv,
f4296e1 @yaxu foo
yaxu authored
27 int argc, void *data, void *user_data) {
ab0fe60 @yaxu there
yaxu authored
28 int i;
29
30 printf("path: <%s>\n", path);
31 for (i=0; i<argc; i++) {
32 printf("arg %d '%c' ", i, types[i]);
33 lo_arg_pp(types[i], argv[i]);
34 printf("\n");
35 }
36 printf("\n");
37
38 return 1;
39 }
40
41 /**/
42
f4296e1 @yaxu foo
yaxu authored
43 int play_handler(const char *path, const char *types, lo_arg **argv,
6356ffd @yaxu more
yaxu authored
44 int argc, void *data, void *user_data) {
ab0fe60 @yaxu there
yaxu authored
45
f4296e1 @yaxu foo
yaxu authored
46 /* lo_timetag ts = lo_message_get_timestamp(data); */
ab0fe60 @yaxu there
yaxu authored
47
fb689a4 @yaxu panning and sample interpellation
yaxu authored
48 double when = (double) argv[0]->i + ((double) argv[1]->i / 1000000.0);
82f4f04 @yaxu works better
yaxu authored
49
cf3bb79 @yaxu working and broken again
yaxu authored
50 char *sample_name = strdup((char *) argv[2]);
82f4f04 @yaxu works better
yaxu authored
51
52 float offset = argv[3]->f;
749ecaa @yaxu foo
yaxu authored
53 float start = argv[4]->f;
54 float end = argv[5]->f;
55 float speed = argv[6]->f;
56 float pan = argv[7]->f;
57 float velocity = argv[8]->f;
58 char *vowel_s = (char *) argv[9];
4441b0f @yaxu aha
yaxu authored
59
60 int vowelnum = -1;
61
62 switch(vowel_s[0]) {
63 case 'a': case 'A': vowelnum = 0; break;
64 case 'e': case 'E': vowelnum = 1; break;
65 case 'i': case 'I': vowelnum = 2; break;
66 case 'o': case 'O': vowelnum = 3; break;
67 case 'u': case 'U': vowelnum = 4; break;
68 }
749ecaa @yaxu foo
yaxu authored
69 //printf("vowel: %s num: %d\n", vowel_s, vowelnum);
82f4f04 @yaxu works better
yaxu authored
70
cf3bb79 @yaxu working and broken again
yaxu authored
71 audio_play(when,
82f4f04 @yaxu works better
yaxu authored
72 sample_name,
73 offset,
749ecaa @yaxu foo
yaxu authored
74 start,
75 end,
fb689a4 @yaxu panning and sample interpellation
yaxu authored
76 speed,
77 pan,
4441b0f @yaxu aha
yaxu authored
78 velocity,
749ecaa @yaxu foo
yaxu authored
79 vowelnum
f4296e1 @yaxu foo
yaxu authored
80 );
ab0fe60 @yaxu there
yaxu authored
81 return 0;
82 }
83
f4296e1 @yaxu foo
yaxu authored
84 /**/
85
86 extern int server_init(void) {
87 lo_server_thread st = lo_server_thread_new("7771", error);
88
cf3bb79 @yaxu working and broken again
yaxu authored
89 //lo_server_thread_add_method(st, NULL, NULL, generic_handler, NULL);
f4296e1 @yaxu foo
yaxu authored
90
749ecaa @yaxu foo
yaxu authored
91 lo_server_thread_add_method(st, "/play", "iisffffffs",
f4296e1 @yaxu foo
yaxu authored
92 play_handler,
93 NULL
94 );
95 lo_server_thread_start(st);
96
97 return(1);
98 }
Something went wrong with that request. Please try again.