aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/osc.h
blob: 4e9dec55253ceadd528f906adbff1e111977a098 (plain)
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
66
#include "midimonster.h"
#include <sys/types.h>
#include <sys/socket.h>

#define OSC_RECV_BUF 8192
#define OSC_XMIT_BUF 8192

int init();
static int osc_configure(char* option, char* value);
static int osc_configure_instance(instance* inst, char* option, char* value);
static instance* osc_instance();
static channel* osc_map_channel(instance* inst, char* spec);
static int osc_set(instance* inst, size_t num, channel** c, channel_value* v);
static int osc_handle(size_t num, managed_fd* fds);
static int osc_start();
static int osc_shutdown();

typedef enum {
	not_set = 0,
	int32 = 'i',
	float32 = 'f',
	/*s, b*/ //ignored
	int64 = 'h',
	double64 = 'd',
} osc_parameter_type;

typedef union {
	int32_t i32;
	float f;
	int64_t i64;
	double d;
} osc_parameter_value;

typedef struct /*_osc_channel*/ {
	char* path;
	size_t params;
	uint8_t mark;

	osc_parameter_type* type;
	osc_parameter_value* max;
	osc_parameter_value* min;
	osc_parameter_value* in;
	osc_parameter_value* out;
} osc_channel;

typedef struct /*_osc_instance_data*/ {
	//pre-configured channel patterns
	size_t patterns;
	osc_channel* pattern;

	//actual channel registry
	size_t channels;
	osc_channel* channel;

	//instance config
	char* root;
	uint8_t learn;

	//peer addressing
	socklen_t dest_len;
	struct sockaddr_storage dest;
	uint16_t forced_rport;

	//peer fd
	int fd;
} osc_instance_data;