Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 117 lines (94 sloc) 2.887 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"
8
9 void error(int num, const char *m, const char *path);
10
11 int trigger_handler(const char *path, const char *types, lo_arg **argv,
12 int argc, void *data, void *user_data);
13
14 int generic_handler(const char *path, const char *types, lo_arg **argv,
15 int argc, void *data, void *user_data);
16
17 /**/
18
19 extern int server_init(void) {
20 lo_server_thread st = lo_server_thread_new("7771", error);
21
22 #ifdef DEBUG
23 lo_server_thread_add_method(st, NULL, NULL, generic_handler, NULL);
24 #endif
25
26 lo_server_thread_add_method(st, "/trigger", "sfffffsfffssffffff",
27 trigger_handler,
28 NULL
29 );
30 lo_server_thread_start(st);
31
32 return(1);
33 }
34
35 /**/
36
37 void error(int num, const char *msg, const char *path) {
38 printf("liblo server error %d in path %s: %s\n", num, path, msg);
39 }
40
41 /**/
42
43 int generic_handler(const char *path, const char *types, lo_arg **argv,
44 int argc, void *data, void *user_data)
45 {
46 int i;
47
48 printf("path: <%s>\n", path);
49 for (i=0; i<argc; i++) {
50 printf("arg %d '%c' ", i, types[i]);
51 lo_arg_pp(types[i], argv[i]);
52 printf("\n");
53 }
54 printf("\n");
55
56 return 1;
57 }
58
59 /**/
60
61 int trigger_handler(const char *path, const char *types, lo_arg **argv,
62 int argc, void *data, void *user_data) {
63
64 lo_timetag ts = lo_message_get_timestamp(data);
65
66 char *sample_name = strdup((char *) argv[0]);
67 float speed = argv[1]->f;
68 float shape = argv[2]->f;
69 float pan = argv[3]->f;
70 float pan_to = argv[4]->f;
71 float volume = argv[5]->f;
72 char *envelope_name = strdup((char *) argv[6]);
73 float anafeel_strength = argv[7]->f;
74 float anafeel_frequency = argv[8]->f;
75 float accellerate = argv[9]->f;
76 char *vowel_s = (char *) argv[10];
77 char *scale_name = strdup((char *) argv[11]);
78 float loops = argv[12]->f;
79 float duration = argv[13]->f;
80 float delay = argv[14]->f;
81 float delay2 = argv[15]->f;
82 float cutoff = argv[16]->f;
83 float resonance = argv[17]->f;
84
85 int vowel = -1;
86 switch(vowel_s[0]) {
87 case 'a': case 'A': vowel = 0; break;
88 case 'e': case 'E': vowel = 1; break;
89 case 'i': case 'I': vowel = 2; break;
90 case 'o': case 'O': vowel = 3; break;
91 case 'u': case 'U': vowel = 4; break;
92 }
93
94 audio_trigger(ts,
95 sample_name,
96 speed,
97 shape,
98 pan,
99 pan_to,
100 volume,
101 envelope_name,
102 anafeel_strength,
103 anafeel_frequency,
104 accellerate,
105 vowel,
106 scale_name,
107 loops,
108 duration,
109 delay,
110 delay2,
111 cutoff,
112 resonance
113 );
114 return 0;
115 }
116
Something went wrong with that request. Please try again.