The Open Master Hearing Aid (openMHA)  openMHA
Open community platform for hearing aid algorithm research
mha_dblbuf_t< FIFO > Class Template Reference

The doublebuffer adapts blocksizes between an outer process, which provides input data and takes output data, and an inner process, which processes the input signal and generates output data using a different block size than the outer process. More...

Public Types

typedef FIFO::value_type value_type
 The datatype exchanged by the FIFO and this doublebuffer. More...
 

Public Member Functions

virtual unsigned get_inner_size () const
 
virtual unsigned get_outer_size () const
 
virtual unsigned get_delay () const
 
virtual unsigned get_fifo_size () const
 
virtual unsigned get_input_channels () const
 
virtual unsigned get_output_channels () const
 
virtual unsigned get_input_fifo_fill_count () const
 
virtual unsigned get_output_fifo_fill_count () const
 
virtual unsigned get_input_fifo_space () const
 
virtual unsigned get_output_fifo_space () const
 
virtual MHA_Errorget_inner_error () const
 
virtual void provoke_inner_error (const MHA_Error &)
 
virtual void provoke_outer_error (const MHA_Error &)
 
 mha_dblbuf_t (unsigned outer_size, unsigned inner_size, unsigned delay, unsigned input_channels, unsigned output_channels, const value_type &delay_data)
 Constructor creates FIFOs with specified delay. More...
 
virtual ~mha_dblbuf_t ()
 
virtual void process (const value_type *input_signal, value_type *output_signal, unsigned count)
 The outer process has to call this method to propagate the input signal to the inner process, and receives back the output signal. More...
 
virtual void input (value_type *input_signal)
 The inner process has to call this method to receive its input signal. More...
 
virtual void output (const value_type *output_signal)
 The outer process has to call this method to deliver its output signal. More...
 

Private Attributes

unsigned outer_size
 The block size used by the outer process. More...
 
unsigned inner_size
 The block size used by the inner process. More...
 
unsigned delay
 The delay introduced by bidirectional buffer size adaptation. More...
 
unsigned fifo_size
 The size of each of the FIFOs. More...
 
unsigned input_channels
 The number of input channels. More...
 
unsigned output_channels
 The number of output channels. More...
 
FIFO input_fifo
 The FIFO for transporting the input signal from the outer process to the inner process. More...
 
FIFO output_fifo
 The FIFO for transporting the output signal from the inner process to the outer process. More...
 
MHA_Errorinner_error
 Owned copy of exception to be thrown in inner thread. More...
 
MHA_Errorouter_error
 Owned copy of exception to be thrown in outer thread. More...
 

Detailed Description

template<class FIFO>
class mha_dblbuf_t< FIFO >

The doublebuffer adapts blocksizes between an outer process, which provides input data and takes output data, and an inner process, which processes the input signal and generates output data using a different block size than the outer process.

This class introduces the channels concept. Input and output may have different channel counts.

Member Typedef Documentation

◆ value_type

template<class FIFO >
typedef FIFO::value_type mha_dblbuf_t< FIFO >::value_type

The datatype exchanged by the FIFO and this doublebuffer.

Constructor & Destructor Documentation

◆ mha_dblbuf_t()

template<class FIFO >
mha_dblbuf_t< FIFO >::mha_dblbuf_t ( unsigned  outer_size,
unsigned  inner_size,
unsigned  delay,
unsigned  input_channels,
unsigned  output_channels,
const value_type delay_data 
)

Constructor creates FIFOs with specified delay.

Warning
The doublebuffer may block or raise an exception if the delay is too small. To avoid this, the delay should be

\[ delay >= (inner\_size - gcd(inner\_size, outer\_size)) \]

.
Parameters
outer_sizeThe block size used by the outer process.
inner_sizeThe block size used by the inner process.
delayThe total delay
input_channelsNumber of input channels
output_channelsNumber of output channels
delay_dataThe delay consists of copies of this value.

◆ ~mha_dblbuf_t()

template<class FIFO >
mha_dblbuf_t< FIFO >::~mha_dblbuf_t
virtual

Member Function Documentation

◆ get_inner_size()

template<class FIFO >
virtual unsigned mha_dblbuf_t< FIFO >::get_inner_size ( ) const
inlinevirtual

◆ get_outer_size()

template<class FIFO >
virtual unsigned mha_dblbuf_t< FIFO >::get_outer_size ( ) const
inlinevirtual

◆ get_delay()

template<class FIFO >
virtual unsigned mha_dblbuf_t< FIFO >::get_delay ( ) const
inlinevirtual

◆ get_fifo_size()

template<class FIFO >
virtual unsigned mha_dblbuf_t< FIFO >::get_fifo_size ( ) const
inlinevirtual

◆ get_input_channels()

template<class FIFO >
virtual unsigned mha_dblbuf_t< FIFO >::get_input_channels ( ) const
inlinevirtual

◆ get_output_channels()

template<class FIFO >
virtual unsigned mha_dblbuf_t< FIFO >::get_output_channels ( ) const
inlinevirtual

◆ get_input_fifo_fill_count()

template<class FIFO >
virtual unsigned mha_dblbuf_t< FIFO >::get_input_fifo_fill_count ( ) const
inlinevirtual

◆ get_output_fifo_fill_count()

template<class FIFO >
virtual unsigned mha_dblbuf_t< FIFO >::get_output_fifo_fill_count ( ) const
inlinevirtual

◆ get_input_fifo_space()

template<class FIFO >
virtual unsigned mha_dblbuf_t< FIFO >::get_input_fifo_space ( ) const
inlinevirtual

◆ get_output_fifo_space()

template<class FIFO >
virtual unsigned mha_dblbuf_t< FIFO >::get_output_fifo_space ( ) const
inlinevirtual

◆ get_inner_error()

template<class FIFO >
virtual MHA_Error* mha_dblbuf_t< FIFO >::get_inner_error ( ) const
inlinevirtual

◆ provoke_inner_error()

template<class FIFO >
void mha_dblbuf_t< FIFO >::provoke_inner_error ( const MHA_Error error)
virtual

◆ provoke_outer_error()

template<class FIFO >
void mha_dblbuf_t< FIFO >::provoke_outer_error ( const MHA_Error error)
virtual

◆ process()

template<class FIFO >
void mha_dblbuf_t< FIFO >::process ( const value_type input_signal,
value_type output_signal,
unsigned  count 
)
virtual

The outer process has to call this method to propagate the input signal to the inner process, and receives back the output signal.

Parameters
input_signalPointer to the input signal array.
output_signalPointer to the output signal array.
countThe number of data instances provided and expected, lower or equal to inner_size given to constructor.
Exceptions
MHA_ErrorWhen count is > outer_size as given to constructor or the underlying fifo implementation detects an error.

◆ input()

template<class FIFO >
void mha_dblbuf_t< FIFO >::input ( value_type input_signal)
virtual

The inner process has to call this method to receive its input signal.

Parameters
input_signalArray where the doublebuffer can store the signal.
Exceptions
MHA_ErrorWhen the underlying fifo implementation detects an error.

◆ output()

template<class FIFO >
void mha_dblbuf_t< FIFO >::output ( const value_type output_signal)
virtual

The outer process has to call this method to deliver its output signal.

Parameters
output_signalArray from which doublebuffer reads outputsignal.
Exceptions
MHA_ErrorWhen the underlying fifo implementation detects an error.

Member Data Documentation

◆ outer_size

template<class FIFO >
unsigned mha_dblbuf_t< FIFO >::outer_size
private

The block size used by the outer process.

◆ inner_size

template<class FIFO >
unsigned mha_dblbuf_t< FIFO >::inner_size
private

The block size used by the inner process.

◆ delay

template<class FIFO >
unsigned mha_dblbuf_t< FIFO >::delay
private

The delay introduced by bidirectional buffer size adaptation.

◆ fifo_size

template<class FIFO >
unsigned mha_dblbuf_t< FIFO >::fifo_size
private

The size of each of the FIFOs.

◆ input_channels

template<class FIFO >
unsigned mha_dblbuf_t< FIFO >::input_channels
private

The number of input channels.

◆ output_channels

template<class FIFO >
unsigned mha_dblbuf_t< FIFO >::output_channels
private

The number of output channels.

◆ input_fifo

template<class FIFO >
FIFO mha_dblbuf_t< FIFO >::input_fifo
private

The FIFO for transporting the input signal from the outer process to the inner process.

◆ output_fifo

template<class FIFO >
FIFO mha_dblbuf_t< FIFO >::output_fifo
private

The FIFO for transporting the output signal from the inner process to the outer process.

◆ inner_error

template<class FIFO >
MHA_Error* mha_dblbuf_t< FIFO >::inner_error
private

Owned copy of exception to be thrown in inner thread.

◆ outer_error

template<class FIFO >
MHA_Error* mha_dblbuf_t< FIFO >::outer_error
private

Owned copy of exception to be thrown in outer thread.


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