An Open Sound Control library for the mbed, created to be compatible with Recotana's OSCClass library (http://recotana.com) for the Arduino with Ethernet shield. It also uses parts of the OSC Transceiver(Sender/Receiver) code by xshige written by: Alvaro Cassinelli, October 2011 tweaked by: Toby Harris / *spark audio-visual, March 2012

Dependents:   SPK-DVIMXR

Embed: (wiki syntax)

« Back to documentation index

OSCMessage Class Reference

OSCMessage Class Reference

Container class for OSC messages (receiving or sending) More...

#include <mbedOSC.h>

Public Member Functions

 OSCMessage ()
 Create a container for an OSC message to be received or sent.
const IpAddr & getIp ()
 Return the IpAddr object.
const int & getPort ()
 Return the port.
char * getAddress (uint8_t _index)
 Gets the address string of the OSC message.
char * getTopAddress ()
 Gets the TopAddress string of the OSC message (this is just the address with index 0)
char * getSubAddress ()
 Gets the "SubAddress" string of the OSC message (this is just the address with index 1)
uint8_t getAddressNum ()
 Gets the number of the OSC message address.
char getTypeTag (uint8_t _index)
 Gets the TypeTag string (with index) of the OSC message.
uint8_t getArgNum ()
 Gets the number of the OSC message args.
int32_t getArgInt (uint8_t _index)
 Get the args of the OSC message with an integer value.
double getArgFloat (uint8_t _index)
 Get the args of the OSC message with a float value.
void setTopAddress (char *_address)
 Set TopAddress string of OSC Message.
void setSubAddress (char *_address)
 Set SubAddress string of the OSC Message.
void setAddress (char *_topAddress, char *_subAddress)
 Set the complete Address string of the OSC Message (top and sub addresses)
void setAddress (uint8_t _index, char *_address)
 Set address string using index (here 0 or 1) Example: "/ard/test", char adr[]="/ard", setAddress(0,adr), char adr2[]="/test", setAddress(1,adr)
void setIp (uint8_t *_ip)
 Set IP Address of the OSC Message (for SENDING messages - for receiving this will be done when receiving something )
void setIp (uint8_t _ip1, uint8_t _ip2, uint8_t _ip3, uint8_t _ip4)
 Set IP Address to the OSC Message container (not through pointer) Example: IP=192.168.0.99 => setIp(192,168,0,99)
void setArgs (char *types,...)
 Set TypeTag and args to the OSC Message container.

Friends

class OSCClass

Detailed Description

Container class for OSC messages (receiving or sending)

Note:
mbedOSC version 0.1 Specification (similar to Recotana's OSCClass library) Example of an OSC message: "/mbed/test1, if 50 32.4" ie. "Address TypeTag Args" Address : max 2 "/ard" "/ard/output" --address[0]="/ard" :max 15character --address[1]="/output" :max 15character TypeTag : max 2 "i" - long or unsigned long "f" - double arg : max 2 (Note: The byte string as seen here is not sent as UDP packet directly - there are no spaces, and arguments are in binary, BIG ENDIAN)

Definition at line 51 of file mbedOSC.h.


Constructor & Destructor Documentation

OSCMessage (  )

Create a container for an OSC message to be received or sent.

Definition at line 9 of file mbedOSC.cpp.


Member Function Documentation

char * getAddress ( uint8_t  _index )

Gets the address string of the OSC message.

Parameters:
[in]_indexThe index of the address string (byte)
Returns:
pointer of the address string (char *)
Note:
ex. "/ard/test"
getAddress(0) = "/ard"
getAddress(1) = "/test"
Attention:
It is maximum number of the addresses is 2
In this case "/ard/test1/test2"
ignore it after "/test2"

Definition at line 57 of file mbedOSC.cpp.

uint8_t getAddressNum (  )

Gets the number of the OSC message address.

Returns:
number of the OSC message address (byte) Examples: "/ard" --> the number of the addresses is 1 "/ard/test" --> the number of the addresses is 2 Attention: the maximum number of addresses is 2 (MAX_ADDRESS)

Definition at line 44 of file mbedOSC.cpp.

double getArgFloat ( uint8_t  _index )

Get the args of the OSC message with a float value.

Parameters:
[in]_indexThe index of the args
Returns:
: float value (double) note: In this case "if" 123 54.24, getArgFloat(1) = 54.24 attention: arg declared as float, but return value cast as "double" attention: When index is bigger than the number of the args, it is set to the number of the args

Definition at line 93 of file mbedOSC.cpp.

int32_t getArgInt ( uint8_t  _index )

Get the args of the OSC message with an integer value.

Parameters:
[in]_indexAn int or uint8_t corresponding to the index of the args (byte)
Returns:
: integer value (long, or int32_t) Example: in the case "if" 123 54.24, getArgInt(0) = 123 Noe: "i" is integer, but the return type is "long" Note: When a index is bigger than the number of the args, it is set to the number of the args

Definition at line 85 of file mbedOSC.cpp.

uint8_t getArgNum (  )

Gets the number of the OSC message args.

Returns:
number of the args (byte) Example: "i" 123 --> number of the OSC message args is 1 "if" 123 54.24 --> number of the OSC message args is 2 Attention: the maximum number of args is 2 (MAX_ARG)

Definition at line 50 of file mbedOSC.cpp.

const IpAddr & getIp (  )

Return the IpAddr object.

Definition at line 33 of file mbedOSC.cpp.

const int & getPort (  )

Return the port.

Definition at line 38 of file mbedOSC.cpp.

char * getSubAddress (  )

Gets the "SubAddress" string of the OSC message (this is just the address with index 1)

Returns:
pointer of the SubAddress string (char *), i.e. address[1] Example: in the case "/ard/test", getSubAddress() = "/test" (WITH the slash "/")

Definition at line 72 of file mbedOSC.cpp.

char * getTopAddress (  )

Gets the TopAddress string of the OSC message (this is just the address with index 0)

Returns:
pointer of the TopAddress string (char *), i.e. address[0] Example: In the case "/ard/test", getTopAddress() = "/ard" (WITH the slash "/")

Definition at line 65 of file mbedOSC.cpp.

char getTypeTag ( uint8_t  _index )

Gets the TypeTag string (with index) of the OSC message.

Parameters:
[in]_indexThe index of the TypeTag string (byte)
Returns:
: TypeTag char (char) Example: in the case of a total typetag string equal to "if", getTypeTag(0) = 'i' and getTypeTag(1) = 'f' Attention: MAX_ARG is maximum number of the args, if the index argument is larger, it will be constrained to this max.

Definition at line 79 of file mbedOSC.cpp.

void setAddress ( char *  _topAddress,
char *  _subAddress 
)

Set the complete Address string of the OSC Message (top and sub addresses)

Parameters:
[in]_topAddress,_subAddressThe string pointers to top and sub addresses (char *) Example: in the case "/ard/test", we need to do: char top[]="/ard", char sub[]="/test", and then setAddress(top,sub) Reminder: in this implementation, the maximum number of addresses is MAX_ADDRESS=2

Definition at line 115 of file mbedOSC.cpp.

void setAddress ( uint8_t  _index,
char *  _address 
)

Set address string using index (here 0 or 1) Example: "/ard/test", char adr[]="/ard", setAddress(0,adr), char adr2[]="/test", setAddress(1,adr)

Definition at line 122 of file mbedOSC.cpp.

void setArgs ( char *  types,
  ... 
)

Set TypeTag and args to the OSC Message container.

Parameters:
[in]typesTypeTag string "i"(integer) or"f"(float) (char *)
[in]...Pointer of the Args(variable argument) .. : (1) integer 123: (NOTE: integers are LONG) long v1=123; sendMes.setArgs("i",&v1) (2)integer:123 and float:52.14 long v1=123; double v2=52.14; sendMes.setArgs("if",&v1,&v2) Attention: in this implementation, the maximum number of the args is 2 (if setArgs("iff",&v1,&v2,&v3), data is ignored after &v3)

Definition at line 130 of file mbedOSC.cpp.

void setIp ( uint8_t *  _ip )

Set IP Address of the OSC Message (for SENDING messages - for receiving this will be done when receiving something )

Parameters:
[in]_ipPointer of IP Address array (byte *) Example: IP=192.168.0.99, then we have to do: ip[]={192,168,0,1}, then setIp(ip)

Definition at line 19 of file mbedOSC.cpp.

void setIp ( uint8_t  _ip1,
uint8_t  _ip2,
uint8_t  _ip3,
uint8_t  _ip4 
)

Set IP Address to the OSC Message container (not through pointer) Example: IP=192.168.0.99 => setIp(192,168,0,99)

Definition at line 25 of file mbedOSC.cpp.

void setSubAddress ( char *  _address )

Set SubAddress string of the OSC Message.

Parameters:
[in]_addressA string pointer for the SubAddress String (char *) Example: if the complete address string is "/ard/test", we set the subaddress as follows: char sub[]="/test" (allocation done here!), then setSubAddress(sub) Attention: we should call first setTopAddress, and then setSubAddress. The order is important. This does not seems like a good idea...

Definition at line 108 of file mbedOSC.cpp.

void setTopAddress ( char *  _address )

Set TopAddress string of OSC Message.

Parameters:
[in]_addressA string pointer for the TopAddress String (char *). NOTE: is this a good idea? why not pass as const, and do allocation here? Example: if the complete address string is "/ard/test", we set the topaddress as follows: char top[]="/ard" (allocation done here!), then setTopAddress(top)

Definition at line 101 of file mbedOSC.cpp.