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

Sound data handling of io tcp library. More...

Classes

union  float_union
 This union helps in conversion of floats from host byte order to network byte order and back again. More...
 

Public Member Functions

 io_tcp_sound_t (int fragsize, float samplerate)
 Initialize sound data handling. More...
 
virtual ~io_tcp_sound_t ()
 Do-nothing destructor. More...
 
virtual void prepare (int num_inchannels, int num_outchannels)
 Called during prepare, sets number of audio channels and allocates sound data storage. More...
 
virtual void release ()
 Called during release. More...
 
virtual int chunkbytes_in () const
 Number of bytes that constitute one input sound chunk. More...
 
virtual std::string header () const
 Create the tcp sound header lines. More...
 
virtual mha_wave_tntoh (const std::string &data)
 Copy data received from tcp into mha_wave_t structure. More...
 
virtual std::string hton (const mha_wave_t *s_out)
 Copy sound data from the output sound structure to a string. More...
 

Static Private Member Functions

static void check_sound_data_type ()
 Check if mha_real_t is a usable 32-bit floating point type. More...
 

Private Attributes

int fragsize
 Number of sound samples in each channel expected and returned from processing callback. More...
 
float samplerate
 Sampling rate. More...
 
int num_inchannels
 Number of input channels. More...
 
int num_outchannels
 
MHASignal::waveform_ts_in
 Storage for input signal. More...
 

Detailed Description

Sound data handling of io tcp library.

Constructor & Destructor Documentation

◆ io_tcp_sound_t()

io_tcp_sound_t::io_tcp_sound_t ( int  fragsize,
float  samplerate 
)

Initialize sound data handling.

Checks sound data type by calling

See also
check_sound_data_type.
Parameters
fragsizeNumber of sound samples in each channel expected and returned from processing callback.
samplerateNumber of samples per second in each channel.

◆ ~io_tcp_sound_t()

virtual io_tcp_sound_t::~io_tcp_sound_t ( )
inlinevirtual

Do-nothing destructor.

Member Function Documentation

◆ check_sound_data_type()

void io_tcp_sound_t::check_sound_data_type ( )
staticprivate

Check if mha_real_t is a usable 32-bit floating point type.

Exceptions
MHA_Errorif mha_real_t is not compatible to 32-bit float.

◆ prepare()

void io_tcp_sound_t::prepare ( int  num_inchannels,
int  num_outchannels 
)
virtual

Called during prepare, sets number of audio channels and allocates sound data storage.

Parameters
num_inchannelsNumber of input audio channels.
num_outchannelsNumber of output audio channels.

◆ release()

void io_tcp_sound_t::release ( void  )
virtual

Called during release.

Deletes sound data storage.

◆ chunkbytes_in()

int io_tcp_sound_t::chunkbytes_in ( ) const
virtual

Number of bytes that constitute one input sound chunk.

Returns
Number of bytes to read from TCP connection before invoking signal processing.

◆ header()

std::string io_tcp_sound_t::header ( ) const
virtual

Create the tcp sound header lines.

◆ ntoh()

mha_wave_t * io_tcp_sound_t::ntoh ( const std::string &  data)
virtual

Copy data received from tcp into mha_wave_t structure.


Doing network-to-host byte order swapping in the process.

Parameters
dataOne chunk (
See also
chunkbytes_in) of sound data to process.
Returns
Pointer to the sound data storage.

◆ hton()

std::string io_tcp_sound_t::hton ( const mha_wave_t s_out)
virtual

Copy sound data from the output sound structure to a string.


Doing host-to-network byte order swapping while at it.

Parameters
s_outPointer to the storage of the sound to put out.
Returns
The sound data in network byte order.

Member Data Documentation

◆ fragsize

int io_tcp_sound_t::fragsize
private

Number of sound samples in each channel expected and returned from processing callback.

◆ samplerate

float io_tcp_sound_t::samplerate
private

Sampling rate.

Number of samples per second in each channel.

◆ num_inchannels

int io_tcp_sound_t::num_inchannels
private

Number of input channels.

Number of channels expected from and returned by signal processing callback.

◆ num_outchannels

int io_tcp_sound_t::num_outchannels
private

◆ s_in

MHASignal::waveform_t* io_tcp_sound_t::s_in
private

Storage for input signal.


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