O2 2.0
A communication protocol for interactive music and media applications.
|
Functions | |
O2err | o2_osc_port_new (const char *service_name, int port_num, int tcp_flag) |
Create a port to receive OSC messages. More... | |
O2err | o2_osc_port_free (int port_num) |
Remove a port receiving OSC messages. More... | |
O2err | o2_osc_delegate (const char *service_name, const char *ip, int port_num, int tcp_flag) |
Create a service that forwards O2 messages to an OSC server. More... | |
uint64_t | o2_osc_time_offset (uint64_t offset) |
Set the OSC time offset. More... | |
O2err o2_osc_delegate | ( | const char * | service_name, |
const char * | ip, | ||
int | port_num, | ||
int | tcp_flag | ||
) |
Create a service that forwards O2 messages to an OSC server.
service_name | The o2 service name without a '/' prefix. |
ip | The ip address of the osc server. |
port_num | The port number of the osc server. |
tcp_flag | Send OSC message via TCP protocol, in which case port_num is the TCP server port, not a connection. |
If tcp_flag
is set, a TCP connection will be established with the OSC server. When the created service receives any O2 messages, it will send the message to the OSC server. If the incoming message has a timestamp for some future time, the message will be held until that time, then sent to the OSC server. (Ideally, O2 could convert the message to an OSC timestamped bundle and send it immediately to achieve precise forward-synchronous timing, but this requires clock synchronization with the OSC server, which is normally unimplemented.)
If this is a tcp connection, close it by calling o2_service_free.
O2err o2_osc_port_free | ( | int | port_num | ) |
Remove a port receiving OSC messages.
This removes a port created by o2_osc_port_new. If you want to remove the corresponding service, you must also call o2_service_free with the service name. The port should be the same port passed to o2_osc_port_new. In the case of TCP, this will close all connections that were accepted from this server port as well as the server port.
port_num | The port number that receives OSC messages or that receives connect requests for TCP connections. |
O2err o2_osc_port_new | ( | const char * | service_name, |
int | port_num, | ||
int | tcp_flag | ||
) |
Create a port to receive OSC messages.
OSC messages are converted to O2 messages and directed to the service. E.g. if the service is "maxmsp" and the message address is /foo/x
, then the message is directed to and handled by /maxmsp/foo/x
. If the #service_name does not exist at any time after calling o2_osc_port_new, incoming OSC messages will be dropped until the service is available again. Note that this function does not automatically create a service named service_name
.
service_name | The name of the service to which messages are delivered |
port_num | Port number. |
tcp_flag | Be a TCP server for remote clients. Otherwise, use UDP |
uint64_t o2_osc_time_offset | ( | uint64_t | offset | ) |
Set the OSC time offset.
offset | the offset between (global) O2 time and OSC time |
O2 global time should start from 0.0 when the clock is started, whereas OSC time starts at 1 Jan 1900. The offset is the OSC time corresponding to O2 time 0.0. Equivalently, OSC_time = O2_time + offset.