Real Time Open Sound Control librtosc
 All Classes Namespaces Files Functions Variables Typedefs Macros Pages
Classes | Functions
rtosc.h File Reference
#include <stdarg.h>
#include <stdint.h>
#include <stddef.h>

Go to the source code of this file.

Classes

struct  rtosc_blob_t
 
union  rtosc_arg_t
 
struct  ring_t
 

Functions

size_t rtosc_message (char *buffer, size_t len, const char *address, const char *arguments,...)
 
size_t rtosc_vmessage (char *buffer, size_t len, const char *address, const char *arguments, va_list va)
 
size_t rtosc_amessage (char *buffer, size_t len, const char *address, const char *arguments, const rtosc_arg_t *args)
 
unsigned rtosc_narguments (const char *msg)
 
char rtosc_type (const char *msg, unsigned i)
 
rtosc_arg_t rtosc_argument (const char *msg, unsigned i)
 
size_t rtosc_message_length (const char *msg, size_t len)
 
size_t rtosc_message_ring_length (ring_t *ring)
 
const char * rtosc_argument_string (const char *msg)
 
size_t rtosc_bundle (char *buffer, size_t len, uint64_t tt, int elms,...)
 
size_t rtosc_bundle_elements (const char *msg, size_t len)
 
const char * rtosc_bundle_fetch (const char *msg, unsigned i)
 
int rtosc_bundle_p (const char *msg)
 
uint64_t rtosc_bundle_timetag (const char *msg)
 

Function Documentation

size_t rtosc_amessage ( char *  buffer,
size_t  len,
const char *  address,
const char *  arguments,
const rtosc_arg_t args 
)
See Also
rtosc_message()
rtosc_arg_t rtosc_argument ( const char *  msg,
unsigned  i 
)

Gets an argument of a well formed message, with writable blob data member

char buffer[128];
rtosc_message(buffer,128,"/path","si", "rtosc", 3);
rtosc_argument(buffer,0).s;// -> "rtosc"
rtosc_argument(buffer,1).i;// -> 3
Parameters
msga well formed OSC message
iindex of argument
Returns
an argument by value via the rtosc_arg_t union
const char* rtosc_argument_string ( const char *  msg)

Gets the argument string of a well formed message.

char buffer[128];
rtosc_message(buffer,128,"/path","TFI");
rtosc_argument_string(buffer)// -> "TFI"
Parameters
msga well formed OSC message
Returns
the argument string of a given message
size_t rtosc_bundle ( char *  buffer,
size_t  len,
uint64_t  tt,
int  elms,
  ... 
)

Generate a bundle from sub-messages

char a[128], b[128], c[128];
rtosc_message(a,128,"/patha","T");
rtosc_message(b,128,"/pathb","I");
rtosc_bundle(c,128,0,2,a,b);
Parameters
bufferDestination buffer
lenLength of buffer
ttOSC time tag
elmsNumber of sub messages
...Messages
Returns
legnth of generated bundle or zero on failure
size_t rtosc_bundle_elements ( const char *  msg,
size_t  len 
)

Find the elements in a bundle

Parameters
msgOSC bundle
lenUpper bound on the length of the bundle
Returns
The number of messages contained within the bundle
const char* rtosc_bundle_fetch ( const char *  msg,
unsigned  i 
)

Fetch a message within the bundle

Parameters
msgOSC bundle
iindex of sub message
Returns
The ith message within the bundle
int rtosc_bundle_p ( const char *  msg)

Test if the buffer contains a bundle

Parameters
msgOSC message
Returns
true if message is a bundle
uint64_t rtosc_bundle_timetag ( const char *  msg)
Parameters
msgA well formed OSC bundle
Returns
Time Tag for a bundle
size_t rtosc_message ( char *  buffer,
size_t  len,
const char *  address,
const char *  arguments,
  ... 
)

Write OSC message to fixed length buffer

On error, buffer will be zeroed. When buffer is NULL, the function returns the size of the buffer required to store the message

//Example messages
char buffer[128];
rtosc_message(buffer,128,"/path","TFI");
rtosc_message(buffer,128,"/path","s","foobar");
rtosc_message(buffer,128,"/path","i",128);
rtosc_message(buffer,128,"/path","f",128.0);
const char blob[4] = {'a','b','c','d'};
rtosc_message(buffer,128,"/path","b",4,blob);
Parameters
bufferMemory to write to
lenLength of buffer
addressOSC pattern to send message to
argumentsString consisting of the types of the following arguments
...OSC arguments to pass forward
Returns
length of resulting message or zero if bounds exceeded
size_t rtosc_message_length ( const char *  msg,
size_t  len 
)
char buffer[128];
size_t len = rtosc_message(buffer,128,"/path","TFI");
rtosc_message_length(buffer);// -> len
Parameters
msgOSC message or null padded blob
lenMessage length upper bound
Returns
the size of a message given a chunk of memory.
size_t rtosc_message_ring_length ( ring_t ring)

Finds the length of the next message inside a ringbuffer structure.

Deprecated:
If the ring contains a bundle, it is not possible to identify its length while conforming to the seriaization strictly specified in the OSC 1.0 spec
Parameters
ringThe addresses and lengths of the split buffer, in a compatible format to jack's ringbuffer
Returns
size of message stored in ring datastructure
unsigned rtosc_narguments ( const char *  msg)

Returns the number of arguments found in a given message.

char buffer[128];
rtosc_message(buffer,128,"/path","si", "rtosc", 3);
rtosc_narguments(buffer); // -> 2
rtosc_message(buffer,128,"/path","[si]", "rtosc", 3);
rtosc_narguments(buffer); // -> 2
Parameters
msgwell formed OSC message
Returns
number of arguments in message
char rtosc_type ( const char *  msg,
unsigned  i 
)
char buffer[128];
rtosc_message(buffer,128,"/path","si", "rtosc", 3);
rtosc_type(buffer,0);// -> 's'
rtosc_type(buffer,1);// -> 'i'
Parameters
msgwell formed OSC message
iindex of argument
Returns
the type of the ith argument in msg
size_t rtosc_vmessage ( char *  buffer,
size_t  len,
const char *  address,
const char *  arguments,
va_list  va 
)
See Also
rtosc_message()