Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
Loading...
Searching...
No Matches
OscSender Class Reference

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.
OscSendernewMessage (std::string address)
 Creates a new OSC message.
OscSenderadd (int payload)
 Adds an int argument to a message.
OscSenderadd (float payload)
 Adds a float argument to a message.
OscSenderadd (std::string payload)
 Adds a string argument to a message.
OscSenderadd (bool payload)
 Adds a boolean argument to a message.
OscSenderadd (void *ptr, size_t num_bytes)
 Adds a binary blob argument to a message.
void send ()
 Sends the message.
void send (const oscpkt::Message &extMsg)
 Sends a message.
void send_task_func (void *buf, int size)

Public Attributes

std::unique_ptr< UdpClientsocket
std::unique_ptr< oscpkt::Message > msg
std::unique_ptr< oscpkt::PacketWriter > pw
std::unique_ptr< AuxTaskNonRTsend_task

Detailed Description

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

Examples
Communication/OSC/render.cpp.

Member Function Documentation

◆ setup()

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)

Parameters
portthe UDP port number used to send OSC messages
addressthe IP address OSC messages are sent to (defaults to 127.0.0.1)

◆ newMessage()

OscSender & OscSender::newMessage ( std::string address)

Creates a new OSC message.

Parameters
addressthe address which the OSC message will be sent to

◆ add() [1/5]

OscSender & OscSender::add ( int payload)

Adds an int argument to a message.

Can optionally be chained with other calls to add(), newMessage() and send()

Parameters
payloadthe argument to be added to the message

◆ add() [2/5]

OscSender & OscSender::add ( float payload)

Adds a float argument to a message.

Can optionally be chained with other calls to add(), newMessage() and send()

Parameters
payloadthe argument to be added to the message

◆ add() [3/5]

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()

Parameters
payloadthe argument to be added to the message

◆ add() [4/5]

OscSender & OscSender::add ( bool payload)

Adds a boolean argument to a message.

Can optionally be chained with other calls to add(), newMessage() and send()

Parameters
payloadthe argument to be added to the message

◆ add() [5/5]

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()

Parameters
ptrpointer to the data to be sent
num_bytesthe number of bytes to be sent

◆ send() [1/2]

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.

◆ send() [2/2]

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.


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