Repository navigation
Expand file tree
/
Copy pathosc.c
More file actions
executable file
·65 lines (48 loc) · 2.26 KB
/
Copy pathosc.c
File metadata and controls
executable file
·65 lines (48 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* osc.c
This file is a part of 'cyperus'
This program is free software: you can redistribute it and/or modify
hit under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
'jackdiff' is a JACK client for learning about software synthesis
Copyright 2015 murray foster */
#include <stdio.h> //printf
#include <string.h> //memset
#include <stdlib.h> //exit(0);
#include "osc_handlers.h"
volatile char *send_host_out;
volatile char *send_port_out;
lo_server_thread lo_thread;
int osc_change_address(char *new_host_out, char *new_port_out) {
free(send_host_out);
free(send_port_out);
send_host_out = malloc(sizeof(char) * strlen(new_host_out) + 1);
strcpy(send_host_out, new_host_out);
send_port_out = malloc(sizeof(char) * strlen(new_port_out) + 1);
strcpy(send_port_out, new_port_out);
lo_address lo_addr_send = lo_address_new((const char*)new_host_out, (const char*)new_port_out);
lo_send(lo_addr_send,"/cyperus/address", "ss", new_host_out, new_port_out);
free(lo_addr_send);
printf("changed osc server and port to: %s:%s\n", new_host_out, new_port_out);
return 0;
}
int osc_setup(char *osc_port_in, char *osc_port_out) {
send_host_out = "127.0.0.1";
send_port_out = osc_port_out;
send_host_out = malloc(sizeof(char) * 10);
strcpy(send_host_out, "127.0.0.1");
send_port_out = malloc(sizeof(char) * 6);
strcpy(send_port_out, osc_port_out);
lo_thread = lo_server_thread_new(osc_port_in, osc_error);
/* below is for debug, add method that will match any path and args */
/* lo_server_thread_add_method(st, NULL, NULL, generic_handler, NULL); */
lo_server_thread_add_method(lo_thread, "/jackdiff/address", "ss", osc_address_handler, NULL);
lo_server_thread_add_method(lo_thread, "/jackdiff/isready", "i", osc_is_ready_handler, NULL);
lo_server_thread_start(lo_thread);
}