Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
|
OscSender provides functions for sending OSC messages from Bela. More...
#include <OscSender.h>
Public Member Functions | |
OscSender (int port, std::string ip_address=std::string("127.0.0.1")) | |
void | setup (int port, std::string ip_address=std::string("127.0.0.1")) |
Initialises OscSender. More... | |
OscSender & | newMessage (std::string address) |
Creates a new OSC message. More... | |
OscSender & | add (int payload) |
Adds an int argument to a message. More... | |
OscSender & | add (float payload) |
Adds a float argument to a message. More... | |
OscSender & | add (std::string payload) |
Adds a string argument to a message. More... | |
OscSender & | add (bool payload) |
Adds a boolean argument to a message. More... | |
OscSender & | add (void *ptr, size_t num_bytes) |
Adds a binary blob argument to a message. More... | |
void | send () |
Sends the message. More... | |
void | send (const oscpkt::Message &extMsg) |
Sends a message. More... | |
void | send_task_func (void *buf, int size) |
Public Attributes | |
std::unique_ptr< UdpClient > | socket |
std::unique_ptr< oscpkt::Message > | msg |
std::unique_ptr < oscpkt::PacketWriter > | pw |
std::unique_ptr< AuxTaskNonRT > | send_task |
OscSender provides functions for sending OSC messages from Bela.
Functionality is provided for sending messages with int, float, bool, std::string and binary blob arguments. Sending a stream of floats is also supported.
Uses oscpkt (http://gruntthepeon.free.fr/oscpkt/) underneath
void OscSender::setup | ( | int | port, |
std::string | ip_address = std::string("127.0.0.1") |
||
) |
Initialises OscSender.
Must be called once during setup()
If address is left blank it will default to localhost (127.0.0.1)
port | the UDP port number used to send OSC messages |
address | the IP address OSC messages are sent to (defaults to 127.0.0.1) |
OscSender & OscSender::newMessage | ( | std::string | address | ) |
Creates a new OSC message.
address | the address which the OSC message will be sent to |
OscSender & OscSender::add | ( | int | payload | ) |
Adds an int argument to a message.
Can optionally be chained with other calls to add(), newMessage() and send()
payload | the argument to be added to the message |
OscSender & OscSender::add | ( | float | payload | ) |
Adds a float argument to a message.
Can optionally be chained with other calls to add(), newMessage() and send()
payload | the argument to be added to the message |
OscSender & OscSender::add | ( | std::string | payload | ) |
Adds a string argument to a message.
Can optionally be chained with other calls to add(), newMessage() and send()
payload | the argument to be added to the message |
OscSender & OscSender::add | ( | bool | payload | ) |
Adds a boolean argument to a message.
Can optionally be chained with other calls to add(), newMessage() and send()
payload | the argument to be added to the message |
OscSender & OscSender::add | ( | void * | ptr, |
size_t | num_bytes | ||
) |
Adds a binary blob argument to a message.
Copies binary data into a buffer, which is sent as a binary blob. Can optionally be chained with other calls to add(), newMessage() and send()
ptr | pointer to the data to be sent |
num_bytes | the number of bytes to be sent |
void OscSender::send | ( | ) |
Sends the message.
After creating a message with newMessage() and adding arguments to it with add(), the message is sent with this function. It is safe to call from the audio thread.
void OscSender::send | ( | const oscpkt::Message & | extMsg | ) |
Sends a message.
Sends the message you pass in, which you will have created externally. It is safe to call from the audio thread.