arduino-audio-tools
All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Modules Pages
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
OSCData Class Reference

A simple OSC Data composer and parser. A OSC data starts with an address string followed by a format string. This is followed by the data. You need to call the read and write methods in the sequence defined by the format string. There is no validation for this, so you need to be careful and test your code properly. To compose a message call: More...

#include <OSCData.h>

Classes

struct  Callback
 

Public Member Functions

 OSCData ()=default
 Data for receiving:
 
 OSCData (uint8_t *data, uint32_t maxlen)
 Data for sending.
 
bool addCallback (const char *address, bool(*callback)(OSCData &data, void *ref), OSCCompare compare=OSCCompare::Matches)
 register a parsing callback for a specific address matching string
 
void clear ()
 clears all data
 
uint8_t * data ()
 
const char * getAddress ()
 provides the address: after calling parse
 
const char * getFormat ()
 provides the format string: after calling parse
 
void logMsg (uint8_t *data, int len)
 
OSCBinaryDatamessageData ()
 
bool parse (uint8_t *data, size_t len)
 parse the data to start for reading
 
const OSCBinaryData readData ()
 reads the next attribute as binary data blob.
 
double readDouble ()
 reads the next attribute as double
 
float readFloat ()
 reads the next attributes as float
 
int32_t readInt32 ()
 reads the next attribute as int32
 
int64_t readInt64 ()
 reads the next attribute as long
 
const char * readString ()
 reads the next string
 
uint64_t readTime ()
 reads the next attribute as uint64_t
 
void setAddress (const char *address)
 Defines the address string (e.g. /test)
 
void setFormat (const char *format)
 Defines the format string (e.g. ,iif)
 
void setLogActive (bool active)
 Log the beginning of the received messages.
 
void setReference (void *ref)
 store a reference object (for callback)
 
int size ()
 returns the number of bytes written (or parsed)
 
bool write (const char *str)
 write a string (s)
 
bool write (const uint8_t *dataArg, int len)
 write a binary blob (b)
 
bool write (double fp64)
 write a 64bit double number (d)
 
bool write (int32_t number)
 write an int32_t number (i)
 
bool write (int64_t number)
 write an int64_t number
 
bool write (OSCBinaryData &data)
 write a binary blob (b)
 
bool write (uint64_t number)
 write a timetag (t) data type
 

Static Public Member Functions

static int oscFormatSize (const char *str)
 storage size (multiple of 4) for format string (w/o the leading ,)
 
static int oscFormatSize (int len)
 storage size (multiple of 4) for format string (w/o the leading ,)
 
static int oscSize (const char *str)
 storage size (multiple of 4) for string
 
static int oscSize (int len)
 storage size (multiple of 4)
 
static int oscSize (OSCBinaryData data)
 storage size (multiple of 4) for binary blob data
 

Protected Member Functions

bool compare (OSCCompare compare, const char *strRef, const char *strCompare)
 
uint8_t * getEnd ()
 

Protected Attributes

OSCBinaryData binary_content
 
Vector< Callbackcallbacks
 
bool is_log_active = false
 
uint8_t * read_data = nullptr
 
uint8_t * read_format_start = nullptr
 
void * reference = nullptr
 
int write_pos = 0
 

Detailed Description

A simple OSC Data composer and parser. A OSC data starts with an address string followed by a format string. This is followed by the data. You need to call the read and write methods in the sequence defined by the format string. There is no validation for this, so you need to be careful and test your code properly. To compose a message call:

To parse a message call:

OSC V1.0 Specification: https://opensoundcontrol.stanford.edu/spec-1_0.html

Author
Phil Schatzmann

Member Function Documentation

◆ addCallback()

bool addCallback ( const char *  address,
bool(*)(OSCData &data, void *ref)  callback,
OSCCompare  compare = OSCCompare::Matches 
)
inline

register a parsing callback for a specific address matching string

replace existing callback

◆ data()

uint8_t * data ( )
inline

provides access to the original binary message (defined in the constructor or via parse())

◆ messageData()

OSCBinaryData & messageData ( )
inline

provides access to the original binary message (defined in the constructor or via parse())

◆ parse()

bool parse ( uint8_t *  data,
size_t  len 
)
inline

parse the data to start for reading

call callback if there are any


The documentation for this class was generated from the following file: