The Open Master Hearing Aid (openMHA)
openMHA
Open community platform for hearing aid algorithm research
|
Class for converting messages received at a single osc address to a single AC variable. More...
Public Member Functions | |
osc_variable_t (const osc_variable_t &)=delete | |
An instance of this class cannot safely be copied. More... | |
osc_variable_t (const std::string &name, unsigned int size, MHA_AC::algo_comm_t &hAC, lo_server_thread lost) | |
Constructor. More... | |
void | sync_osc2ac () |
Copies the latest OSC data from the OSC storage to the AC storage. More... | |
void | ac_insert () |
Insert/Re-insert the AC variable into AC space. More... | |
int | handler (const char *types, lo_arg **argv, int argc) |
Callback function called by network thread managed by liblo when a new OSC message has been received. More... | |
Static Public Member Functions | |
static int | handler (const char *path, const char *types, lo_arg **argv, int argc, lo_message msg, void *user_data) |
Callback function called by network thread managed by liblo when a new OSC message has been received. More... | |
Private Attributes | |
std::string | acname |
Name of the ac variable. More... | |
std::string | oscaddr |
OSC address. More... | |
MHA_AC::waveform_t | ac_data |
AC variable storage. More... | |
MHASignal::waveform_t | osc_data |
OSC variable storage. More... | |
std::string | name_ |
Name of AC variable and OSC address without the initial slash. More... | |
Class for converting messages received at a single osc address to a single AC variable.
OSC variables are received asynchronously in a network thread and must not modify their AC variables directly, because MHA plugins may only access their AC variables while executing their prepare, release, or process callbacks.
One osc2ac plugin uses multiple instances of osc_variable_t, one for each mapping of an OSC address to an AC variable.
|
delete |
An instance of this class cannot safely be copied.
osc_variable_t::osc_variable_t | ( | const std::string & | name, |
unsigned int | size, | ||
MHA_AC::algo_comm_t & | hAC, | ||
lo_server_thread | lost | ||
) |
Constructor.
Allocates memory.
name | The name of the AC variable that stores the latest value. |
size | Number of elements to copy from OSC message to AC variable. |
hAC | Handle of Algorithm Communication Variable space. |
lost | libLO Server Thread. |
|
inline |
Copies the latest OSC data from the OSC storage to the AC storage.
To be executed during process callback of osc2ac plugin.
|
inline |
Insert/Re-insert the AC variable into AC space.
Should be done in each process callback.
|
static |
Callback function called by network thread managed by liblo when a new OSC message has been received.
This static method forwards to the instance method by casting user_data to osc_variable_t*.
path | Unused. |
types | The OSC data type indicator of the received message. |
argv | Array of received OSC data. |
argc | Number of elements in array of received OSC data. |
msg | Unused. |
user_data | Pointer to osc_variable_t instance. |
int osc_variable_t::handler | ( | const char * | types, |
lo_arg ** | argv, | ||
int | argc | ||
) |
Callback function called by network thread managed by liblo when a new OSC message has been received.
This instance method checks if the received data is of expected length and contains only floats, and if yes, copies the data into the buffer osc_data where the latest received data for this osc address is stored until it is either overwritten by the next data for the same osc address or copied to an AC variable.
types | The OSC data type indicator of the received message. |
argv | Array of received OSC data. |
argc | Number of elements in array of received OSC data. |
|
private |
Name of the ac variable.
|
private |
OSC address.
|
private |
AC variable storage.
|
private |
OSC variable storage.
|
private |
Name of AC variable and OSC address without the initial slash.