The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
lsl2ac::save_var_t< T > Class Template Reference

LSL to AC bridge variable. More...

Inheritance diagram for lsl2ac::save_var_t< T >:
Inheritance graph

Public Member Functions

 save_var_t (const save_var_t &)=delete
 
 save_var_t (save_var_t &&)=delete
 
virtual ~save_var_t ()=default
 
save_var_toperator= (const save_var_t &)=delete
 
save_var_toperator= (save_var_t &&)=delete
 
 save_var_t (const lsl::stream_info &info_, MHA_AC::algo_comm_t &ac_, overrun_behavior ob_, int type_, int buflen_, int chunksize_, int nchannels_, int nsamples_)
 C'tor of lsl to ac bridge. More...
 
lsl::stream_info info () override
 Get stream info object from stream inlet. More...
 
void receive_frame () override
 Receive a samples from lsl and copy to AC space. More...
 
- Public Member Functions inherited from lsl2ac::save_var_base_t
virtual ~save_var_base_t ()=default
 

Private Member Functions

void pull_samples_ignore ()
 Pull new samples, ignore overrun. More...
 
void pull_samples_discard ()
 Pull new samples as long as there are samples ready for pickup in the LSL buffers. More...
 
void get_time_correction ()
 Refresh time correction value every 5s. More...
 
void insert_vars ()
 Insert stream value, time stamp and time offset into ac space. More...
 

Private Attributes

lsl::stream_inlet stream
 LSL stream outlet. More...
 
std::vector< T > buf
 Data buffer of the ac variable. More...
 
std::vector< double > ts_buf
 Timestamp buffer. More...
 
std::vector< double > tc_buf
 Clock correction buffer. More...
 
MHA_AC::algo_comm_tac
 Handle to AC space. More...
 
MHA_AC::comm_var_t cv
 Timeseries AC variable. More...
 
MHA_AC::comm_var_t ts
 Timestamp AC variable. More...
 
MHA_AC::comm_var_t tc
 Time correction AC variable. More...
 
std::string ts_name
 Timestamp AC variable name. More...
 
std::string tc_name
 Time correction AC variable name. More...
 
std::string new_name
 Number of new samples AC variable name. More...
 
std::chrono::time_point< std::chrono::steady_clock > tic
 time point of last time correction pull More...
 
bool skip =false
 Should the variable be skipped in future process calls? Only true when error occured. More...
 
overrun_behavior ob
 Behavior on stream overrun. More...
 
const std::string name
 Name of stream. More...
 
int32_t nchannels
 Number of channels. More...
 
std::size_t nsamples
 Number of samples per channel in the AC variable. More...
 
std::size_t chunksize
 Maximal chunk size of lsl stream. More...
 
std::size_t bufsize
 Total buffer size of the ac variable buffer. More...
 
int n_new_samples
 Number of most recently pulled samples per channel. More...
 

Detailed Description

template<typename T>
class lsl2ac::save_var_t< T >

LSL to AC bridge variable.

Constructor & Destructor Documentation

◆ save_var_t() [1/3]

template<typename T >
lsl2ac::save_var_t< T >::save_var_t ( const save_var_t< T > &  )
delete

◆ save_var_t() [2/3]

template<typename T >
lsl2ac::save_var_t< T >::save_var_t ( save_var_t< T > &&  )
delete

◆ ~save_var_t()

template<typename T >
virtual lsl2ac::save_var_t< T >::~save_var_t ( )
virtualdefault

◆ save_var_t() [3/3]

template<typename T >
lsl2ac::save_var_t< T >::save_var_t ( const lsl::stream_info &  info_,
MHA_AC::algo_comm_t ac_,
overrun_behavior  ob_,
int  type_,
int  buflen_,
int  chunksize_,
int  nchannels_,
int  nsamples_ 
)
inline

C'tor of lsl to ac bridge.

Parameters
name_Name of LSL stream to be received
info_LSL stream info object containing metadata
ac_Handle to ac space
ob_Overrun behavior. 0=Discard oldest, 1=Ignore
type_Type tag of the AC variable
buflen_LSL buffer size
chunksize_LSL chunk size
nchannels_Number of channels in the AC variable must be zero or equal to number of channels in LSL stream
nsamples_Number of samples per channel in the AC variable. Zero means resize as needed

Member Function Documentation

◆ operator=() [1/2]

template<typename T >
save_var_t& lsl2ac::save_var_t< T >::operator= ( const save_var_t< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
save_var_t& lsl2ac::save_var_t< T >::operator= ( save_var_t< T > &&  )
delete

◆ info()

template<typename T >
lsl::stream_info lsl2ac::save_var_t< T >::info ( )
inlineoverridevirtual

Get stream info object from stream inlet.

Implements lsl2ac::save_var_base_t.

◆ receive_frame()

template<typename T >
void lsl2ac::save_var_t< T >::receive_frame ( )
inlineoverridevirtual

Receive a samples from lsl and copy to AC space.

Handling of underrun is configuration-dependent

Implements lsl2ac::save_var_base_t.

◆ pull_samples_ignore()

template<typename T >
void lsl2ac::save_var_t< T >::pull_samples_ignore ( )
inlineprivate

Pull new samples, ignore overrun.

If nsamples=0, leaves the buffers in a state where the newest samples are at the beginning of the buffers, the state of the older samples is undefined and n_new_samples contains the number of new samples per channel. If nsamples is non-zero, the buffers are rotated so the oldest samples are the first in the buffer and n_new_samples contains the number of new samples per channel.

◆ pull_samples_discard()

template<typename T >
void lsl2ac::save_var_t< T >::pull_samples_discard ( )
inlineprivate

Pull new samples as long as there are samples ready for pickup in the LSL buffers.

If nsamples=0, leaves the buffers in a state where the newest samples are at the beginning of the buffers, the state of the older samples is undefined and n_new_samples contains total number of new samples per channel. If nsamples is non-zero, the buffers are rotated so the oldest samples come first. n_samples_new then contains the total number of new samples per channel. If n_new_samples is larger than the number of samples in the AC variable that means samples had be discarded.

◆ get_time_correction()

template<typename T >
void lsl2ac::save_var_t< T >::get_time_correction ( )
inlineprivate

Refresh time correction value every 5s.

◆ insert_vars()

template<typename T >
void lsl2ac::save_var_t< T >::insert_vars ( )
inlineprivate

Insert stream value, time stamp and time offset into ac space.

Member Data Documentation

◆ stream

template<typename T >
lsl::stream_inlet lsl2ac::save_var_t< T >::stream
private

LSL stream outlet.

Interface to lsl

◆ buf

template<typename T >
std::vector<T> lsl2ac::save_var_t< T >::buf
private

Data buffer of the ac variable.

◆ ts_buf

template<typename T >
std::vector<double> lsl2ac::save_var_t< T >::ts_buf
private

Timestamp buffer.

◆ tc_buf

template<typename T >
std::vector<double> lsl2ac::save_var_t< T >::tc_buf
private

Clock correction buffer.

◆ ac

template<typename T >
MHA_AC::algo_comm_t& lsl2ac::save_var_t< T >::ac
private

Handle to AC space.

◆ cv

template<typename T >
MHA_AC::comm_var_t lsl2ac::save_var_t< T >::cv
private

Timeseries AC variable.

◆ ts

template<typename T >
MHA_AC::comm_var_t lsl2ac::save_var_t< T >::ts
private

Timestamp AC variable.

◆ tc

template<typename T >
MHA_AC::comm_var_t lsl2ac::save_var_t< T >::tc
private

Time correction AC variable.

◆ ts_name

template<typename T >
std::string lsl2ac::save_var_t< T >::ts_name
private

Timestamp AC variable name.

◆ tc_name

template<typename T >
std::string lsl2ac::save_var_t< T >::tc_name
private

Time correction AC variable name.

◆ new_name

template<typename T >
std::string lsl2ac::save_var_t< T >::new_name
private

Number of new samples AC variable name.

◆ tic

template<typename T >
std::chrono::time_point<std::chrono::steady_clock> lsl2ac::save_var_t< T >::tic
private

time point of last time correction pull

◆ skip

template<typename T >
bool lsl2ac::save_var_t< T >::skip =false
private

Should the variable be skipped in future process calls? Only true when error occured.

◆ ob

template<typename T >
overrun_behavior lsl2ac::save_var_t< T >::ob
private

Behavior on stream overrun.

◆ name

template<typename T >
const std::string lsl2ac::save_var_t< T >::name
private

Name of stream.

Must be saved separately because the stream info might be unrecoverable in error cases

◆ nchannels

template<typename T >
int32_t lsl2ac::save_var_t< T >::nchannels
private

Number of channels.

◆ nsamples

template<typename T >
std::size_t lsl2ac::save_var_t< T >::nsamples
private

Number of samples per channel in the AC variable.

Zero means resize as needed.

◆ chunksize

template<typename T >
std::size_t lsl2ac::save_var_t< T >::chunksize
private

Maximal chunk size of lsl stream.

◆ bufsize

template<typename T >
std::size_t lsl2ac::save_var_t< T >::bufsize
private

Total buffer size of the ac variable buffer.

nsamples*nchannels if nsamples is set, chunksize*nchannels otherwise if chunksize is set, nchannels if neither nsamples and chunksize are set.

◆ n_new_samples

template<typename T >
int lsl2ac::save_var_t< T >::n_new_samples
private

Number of most recently pulled samples per channel.


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