Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Files Functions Variables Typedefs Macros Groups
Public Member Functions | List of all members
Gui Class Reference

Public Member Functions

 Gui (unsigned int port, std::string address)
 
int setup (unsigned int port=5555, std::string address="gui")
 
int setup (std::string projectName, unsigned int port=5555, std::string address="gui")
 
void cleanup ()
 
bool isConnected ()
 
unsigned int setBuffer (char bufferType, unsigned int size)
 
DataBuffergetDataBuffer (unsigned int bufferId)
 
void setControlDataCallback (std::function< bool(const char *, int, void *)> callback, void *customControlData=nullptr)
 
void setBinaryDataCallback (std::function< bool(const char *, int, void *)> callback, void *customBinaryData=nullptr)
 
template<typename T , typename A >
int sendBuffer (unsigned int bufferId, std::vector< T, A > &buffer)
 
template<typename T , size_t N>
int sendBuffer (unsigned int bufferId, T(&buffer)[N])
 
template<typename T >
int sendBuffer (unsigned int bufferId, T value)
 

Member Function Documentation

int Gui::setup ( std::string  projectName,
unsigned int  port = 5555,
std::string  address = "gui" 
)

Sets the web socket communication between server and client. Two different web socket connections will be configured, one for control data and the other one for raw binary data.

Parameters
portPort on which to stablish the the web socket communication.
addressBase address used to stalish the web socket communication.
projectNameProject name to be sent to via the web-socket to the client.
Returns
O if web sockets have been configured.
unsigned int Gui::setBuffer ( char  bufferType,
unsigned int  size 
)

Sets the buffer type and size of the container.

Parameters
bufferTypetype of the buffer, can be float (f), int (i) or char (c)
sizeMaximum number of elements that the buffer can hold. Buffer ID, generated automatically based on the number of buffers and the order on which they have been created.
DataBuffer & Gui::getDataBuffer ( unsigned int  bufferId)

Returns a DataBuffer object which represents a typed buffer holding a number of bytes that an be retrieved in different formats.

Parameters
bufferIdbuffer ID
void Gui::setControlDataCallback ( std::function< bool(const char *, int, void *)>  callback,
void *  customControlData = nullptr 
)
inline

Set callback to parse control data received from the client.

Parameters
callbackCallback to be called whenever new control data is received. Takes a byte buffer, the size of the buffer and a pointer as parameters. The first two parameters are used for the data received on the web-socket. The third parameter is used to access data structures pointed by the user.
customControlDataPointer to data structure to be pased to the callback.
void Gui::setBinaryDataCallback ( std::function< bool(const char *, int, void *)>  callback,
void *  customBinaryData = nullptr 
)
inline

Set callback to parse binary data received from the client.

Parameters
callbackCallback to be called whenever new data is received. Takes a byte buffer, the size of the buffer and a pointer as parameters. The first two parameters are used for the data received on the web-socket. The third parameter is used to access data structures pointed by the user.
customBinaryDataPointer to data structure to be pased to the callback.
template<typename T , typename A >
int Gui::sendBuffer ( unsigned int  bufferId,
std::vector< T, A > &  buffer 
)

Sends a buffer (a vector) through the web-socket to the client with a given ID.

Parameters
bufferIdGiven buffer ID
bufferVector of arbitrary length and type
template<typename T , size_t N>
int Gui::sendBuffer ( unsigned int  bufferId,
T(&)  buffer[N] 
)

Sends a buffer (an array) through the web-socket to the client with a given ID.

Parameters
bufferIdGiven buffer ID
bufferArray of arbitrary size and type
template<typename T >
int Gui::sendBuffer ( unsigned int  bufferId,
value 
)

Sends a single value through the web-socket to the client with a given ID.

Parameters
bufferIdGiven buffer ID
valueof arbitrary type

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