HARDT - The Ham Radio DSP Toolkit
Public Member Functions | List of all members
HMux< T > Class Template Reference

#include <hmux.h>

Inheritance diagram for HMux< T >:
Inheritance graph
[legend]
Collaboration diagram for HMux< T >:
Collaboration graph
[legend]

Public Member Functions

 HMux (std::vector< HReader< T > * > readers, size_t blocksize, bool duplex=false)
 
 HMux (HWriter< T > *writer, int writers, size_t blocksize, bool duplex=false)
 
 HMux (std::vector< HWriterConsumer< T > * > consumers, size_t blocksize, bool duplex=false)
 
 ~HMux ()
 
int Read (T *dest, size_t blocksize)
 
int Write (T *src, size_t blocksize)
 
bool Command (HCommand *command)
 
void SetWriter (HWriter< T > *writer)
 
bool Start ()
 
bool Stop ()
 
- Public Member Functions inherited from HReader< T >
virtual ~HReader ()=default
 
HReader< T > * Reader ()
 
- Public Member Functions inherited from HObject
 HObject ()
 
- Public Member Functions inherited from HWriter< T >
virtual ~HWriter ()=default
 
HWriter< T > * Writer ()
 
- Public Member Functions inherited from HWriterConsumer< T >
HWriterConsumer< T > * Consumer ()
 

Detailed Description

template<class T>
class HMux< T >

Taking a list of readers, the read from each reader and interlace the samples - then return the resulting buffer. (or await writes from a number of writers, then multiplex the incomming data and write to the next writer)

Ex: Having processed the left and right part of a stereo signal, a HMux object is then created with the left and right HReader objects. The HMux object will then read the left and right samples, interlace them and return a set of samples ready to output from a 2-channel soundcard.

IQ samples having been processed in parallel branches may also require multiplexing again to end up with an IQ signal (for detection or other reasons).

Do note that the output from the multiplexer will be the total number of samples read or written by the upstream readers or writers. Having two readers that each returns 1024 samples will yield a read of 2048 samples.

A special use of the multiplexer is to have a single stream (reader og writer) and then multiplexing the input data into two identical channels. This is usefull when you want to output a mono stream as a dual-channel ("stereo") headset.

Constructor & Destructor Documentation

◆ HMux() [1/3]

template<class T >
HMux< T >::HMux ( std::vector< HReader< T > * >  readers,
size_t  blocksize,
bool  duplex = false 
)

Construct a new HMux

Parameters
readersA list o reader to read from
blocksizeNumber of blocks to read
duplexIf set to true, the number of readers must be 1. Read a single block, then duplicate the block and output same block as two channels multiplexed (mono->stereo for mono input)

◆ HMux() [2/3]

template<class T >
HMux< T >::HMux ( HWriter< T > *  writer,
int  writers,
size_t  blocksize,
bool  duplex = false 
)

Construct a new HMux

Parameters
writerThe writer to write the final multiplexed signal to
writersNumber of writers, writing to this multiplexer
blocksizeNumber of blocks to write
duplexIf set to true, the number of writers must be 1. When a single block is written, then duplicate the block and output same block as two channels multiplexed (mono->stereo for mono input)

◆ HMux() [3/3]

template<class T >
HMux< T >::HMux ( std::vector< HWriterConsumer< T > * >  consumers,
size_t  blocksize,
bool  duplex = false 
)

Construct a new HMux

Parameters
consumersThe upstream consumers
blocksizeNumber of blocks to write
duplexIf set to true, the number of upstream writers must be 1. When a single block is written, then duplicate the block and output same block as two channels multiplexed (mono->stereo for mono input)

◆ ~HMux()

template<class T >
HMux< T >::~HMux

Default destructor

Member Function Documentation

◆ Command()

template<class T >
bool HMux< T >::Command ( HCommand command)
inlinevirtual

Execute or carry through a command

Implements HReader< T >.

◆ Read()

template<class T >
int HMux< T >::Read ( T *  dest,
size_t  blocksize 
)
virtual

Read a block of samples

Implements HReader< T >.

◆ SetWriter()

template<class T >
void HMux< T >::SetWriter ( HWriter< T > *  writer)
inlinevirtual

◆ Start()

template<class T >
bool HMux< T >::Start ( )
inlinevirtual

Start the multiplexer

Reimplemented from HReader< T >.

◆ Stop()

template<class T >
bool HMux< T >::Stop ( )
inlinevirtual

Stop the multiplexer

Reimplemented from HReader< T >.

◆ Write()

template<class T >
int HMux< T >::Write ( T *  src,
size_t  blocksize 
)
virtual

Write a block of samples

Implements HWriter< T >.


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