The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
osc_variable_t Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ osc_variable_t() [1/2]

osc_variable_t::osc_variable_t ( const osc_variable_t )
delete

An instance of this class cannot safely be copied.

◆ osc_variable_t() [2/2]

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.

Parameters
nameThe name of the AC variable that stores the latest value.
sizeNumber of elements to copy from OSC message to AC variable.
hACHandle of Algorithm Communication Variable space.
lostlibLO Server Thread.

Member Function Documentation

◆ sync_osc2ac()

void osc_variable_t::sync_osc2ac ( )
inline

Copies the latest OSC data from the OSC storage to the AC storage.

To be executed during process callback of osc2ac plugin.

◆ ac_insert()

void osc_variable_t::ac_insert ( )
inline

Insert/Re-insert the AC variable into AC space.

Should be done in each process callback.

◆ handler() [1/2]

int osc_variable_t::handler ( const char *  path,
const char *  types,
lo_arg **  argv,
int  argc,
lo_message  msg,
void *  user_data 
)
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*.

Parameters
pathUnused.
typesThe OSC data type indicator of the received message.
argvArray of received OSC data.
argcNumber of elements in array of received OSC data.
msgUnused.
user_dataPointer to osc_variable_t instance.
Returns
1 if the message was accepted, 0 if not.

◆ handler() [2/2]

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.

Parameters
typesThe OSC data type indicator of the received message.
argvArray of received OSC data.
argcNumber of elements in array of received OSC data.
Returns
1 if the message had correct length and contained only floats, 0 if not.

Member Data Documentation

◆ acname

std::string osc_variable_t::acname
private

Name of the ac variable.

◆ oscaddr

std::string osc_variable_t::oscaddr
private

OSC address.

◆ ac_data

MHA_AC::waveform_t osc_variable_t::ac_data
private

AC variable storage.

◆ osc_data

MHASignal::waveform_t osc_variable_t::osc_data
private

OSC variable storage.

◆ name_

std::string osc_variable_t::name_
private

Name of AC variable and OSC address without the initial slash.


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