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 *callbackArg=nullptr)
 
void setBinaryDataCallback (std::function< bool(const char *, unsigned int, void *)> callback, void *callbackArg=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/bar-visual/render.cpp, Trill/craft-visual/render.cpp, Trill/custom-slider/render.cpp, Trill/flex-default/render.cpp, Trill/flex-visual/render.cpp, Trill/general-settings/render.cpp, Trill/general-visual/render.cpp, Trill/hex-visual/render.cpp, Trill/multiple-devices/render.cpp, Trill/ring-sound/render.cpp, Trill/ring-visual/render.cpp, Trill/square-multitouch/render.cpp, and Trill/square-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
0 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.
Returns
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, Gui/sequencer/render.cpp, and Trill/ring-sound/render.cpp.
DataBuffer & Gui::getDataBuffer ( unsigned int  bufferId)

Get the DataBuffer object corresponding to the identifier that was assigned to it during creation

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 *  callbackArg = 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
callbackArgan opaque pointer that will be passed to the callback
Examples:
Gui/frequency-response/render.cpp, Trill/craft-visual/render.cpp, Trill/flex-visual/render.cpp, Trill/general-settings/render.cpp, and Trill/multiple-devices/render.cpp.
void Gui::setBinaryDataCallback ( std::function< bool(const char *, unsigned int, void *)>  callback,
void *  callbackArg = nullptr 
)
inline

Set callback to parse binary data received from the client.

Parameters
callbackCallback to be called whenever new binary 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 to the callback are a pointer to and the size of the data received on the web-socket. The third parameter is a user-defined opaque pointer.
callbackArgPointer 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.
Examples:
Trill/multiple-devices/render.cpp.
template<typename T , typename A >
int Gui::sendBuffer ( unsigned int  bufferId,
std::vector< T, A > &  buffer 
)
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: