Bela
Real-time, ultra-low-latency audio and sensor processing system for BeagleBone Black
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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(JSONObject &, void *)> callback, void *customControlData=nullptr)
 
void setBinaryDataCallback (std::function< bool(const char *, unsigned int, void *)> callback, void *customBinaryData=nullptr)
 
int sendControl (JSONValue *root)
 
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 *ptr, size_t count)
 
template<typename T >
int sendBuffer (unsigned int bufferId, T value)
 

Detailed Description

Examples:
Gui/ambient-ellipse/render.cpp, Gui/bela-to-gui/render.cpp, Gui/clock/render.cpp, Gui/empty-project/render.cpp, Gui/frequency-response/render.cpp, Gui/graph/render.cpp, Gui/gui-to-bela/render.cpp, Gui/mouse-track/render.cpp, Gui/sequencer/render.cpp, Gui/sliders/render.cpp, Trill/flex-default/render.cpp, and Trill/flex-visual/render.cpp.

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.
Examples:
Gui/gui-to-bela/render.cpp, Gui/mouse-track/render.cpp, and Gui/sequencer/render.cpp.
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
Examples:
Gui/gui-to-bela/render.cpp, Gui/mouse-track/render.cpp, and Gui/sequencer/render.cpp.
void Gui::setControlDataCallback ( std::function< bool(JSONObject &, 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. The callback takes a JSONObject, and an opaque pointer, which is passed at the moment of registering the callback. The callback should return true if the default callback should be called afterward or false otherwise.
callbackthe function to be called upon receiving data on the control WebSocket
customBinaryDataan opaque pointer that will be passed to the callback
Examples:
Gui/frequency-response/render.cpp, and Trill/flex-visual/render.cpp.
void Gui::setBinaryDataCallback ( std::function< bool(const char *, unsigned int, void *)>  callback,
void *  customBinaryData = nullptr 
)
inline

Set callback to parse binary data received from the client.

Parameters
callbackCallback to be called whenever new control data is received. It takes a byte buffer, the size of the buffer and a pointer as parameters, returns trueif the default callback should be called afterward or false otherwise. The first two parameters are used for the data received on the web-socket. The third parameter is a user-defined opaque pointer
customBinaryDataPointer to be passed to the callback.
int Gui::sendControl ( JSONValue root)

Sends a JSON value to the control websocket. Returns 0 on success, or an error code otherwise.

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
Examples:
Gui/ambient-ellipse/render.cpp, Gui/bela-to-gui/render.cpp, Gui/clock/render.cpp, Gui/frequency-response/render.cpp, Gui/graph/render.cpp, Gui/sequencer/render.cpp, Trill/flex-default/render.cpp, and Trill/flex-visual/render.cpp.
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,
T *  ptr,
size_t  count 
)

Sends a buffer (pointer) of specified length through the websocket to the client with a given ID.

Parameters
bufferIdBuffer ID
bufferPointer to the location of memory to send
countnumber of elements to send
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: