-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathosc_message.h
55 lines (46 loc) · 1.15 KB
/
osc_message.h
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
#pragma once
#include <string>
class osc_message
{
protected:
osc_message(char* address, char type);
inline static int quantize(int in, int multiple) {
if (in % multiple == 0) {
return in;
}
return in + multiple - (in % multiple);
}
inline static void swap_endianness(char* inBytes, int size) {
for (int i=0, j = size - 1; i < size/2; i++, j--) {
char temp = inBytes[i];
inBytes[i] = inBytes[j];
inBytes[j] = temp;
}
}
public:
osc_message(char* data, int size);
char* address;
char type;
int writerIndex;
char message[256];
};
class osc_float_message : public osc_message
{
public:
osc_float_message(char* address, float value);
float parse();
};
class osc_string_message : public osc_message
{
public:
osc_string_message(char* address, char* value);
};
class osc_int_message : public osc_message {
public:
osc_int_message(char* address, int value);
int parse();
};
class osc_bool_message : public osc_message {
public:
osc_bool_message(char* address, bool value) : osc_message(address, value ? 'T' : 'F') {}
};