HARDT - The Ham Radio DSP Toolkit
hlinearmixer.h
1 #ifndef __HLINEARMIXER_H
2 #define __HLINEARMIXER_H
3 
7 template <class T>
8 class HLinearMixer : public HReader<T>, public HWriter<T>, public HWriterConsumer<T>
9 {
10  private:
11 
12  HReader<T>* _reader_1;
13  HReader<T>* _reader_2;
14  HWriter<T>* _writer;
15  bool _wait;
16 
17  int _blocksize;
18  T* _buffer_1;
19  T* _buffer_2;
20 
21  HProbe<T>* _probe;
22 
23  public:
24 
26  HLinearMixer(HReader<T>* reader_1, HReader<T>* reader_2, size_t blocksize, HProbe<T>* probe = NULL);
27 
29  HLinearMixer(HReader<T>* reader, HWriter<T>* writer, size_t blocksize, HProbe<T>* probe = NULL);
30 
35  HLinearMixer(HWriter<T>* writer, size_t blocksize, HProbe<T>* probe = NULL);
36 
38  HLinearMixer(HReader<T>* reader, HWriterConsumer<T>* consumer, size_t blocksize, HProbe<T>* probe = NULL);
39 
41  HLinearMixer(HWriterConsumer<T>* consumer, size_t blocksize, HProbe<T>* probe = NULL);
42 
44  ~HLinearMixer();
45 
47  void Init(size_t blocksize);
48 
50  int Read(T* dest, size_t blocksize);
51 
53  int Write(T* src, size_t blocksize);
54 
56  bool Start();
57 
59  bool Stop();
60 
62  void SetWriter(HWriter<T>* writer)
63  {
64  _writer = writer;
65  }
66 
68  bool Command(HCommand* command) {
69  if( _writer != nullptr )
70  {
71  if (!_writer->Command(command)) {
72  return false;
73  }
74  }
75  if( _reader_1 != nullptr )
76  {
77  if (!_reader_1->Command(command)) {
78  return false;
79  }
80  }
81  if( _reader_2 != nullptr )
82  {
83  if( !_reader_2->Command(command) ) {
84  return false;
85  }
86  }
87  return true;
88  }
89 };
90 
91 #endif
HReader::Command
virtual bool Command(HCommand *command)=0
HLinearMixer::Stop
bool Stop()
Definition: hlinearmixer.cpp:213
HLinearMixer::Write
int Write(T *src, size_t blocksize)
Definition: hlinearmixer.cpp:138
HLinearMixer::Init
void Init(size_t blocksize)
Definition: hlinearmixer.cpp:87
HWriter
Definition: hwriter.h:10
HLinearMixer::~HLinearMixer
~HLinearMixer()
Definition: hlinearmixer.cpp:79
HWriter::Command
virtual bool Command(HCommand *command)=0
HReader
Definition: hreader.h:24
HLinearMixer::Command
bool Command(HCommand *command)
Definition: hlinearmixer.h:68
HProbe
Definition: hprobe.h:10
HLinearMixer::Read
int Read(T *dest, size_t blocksize)
Definition: hlinearmixer.cpp:95
HCommand
Definition: hcommand.h:81
HLinearMixer::Start
bool Start()
Definition: hlinearmixer.cpp:191
HLinearMixer
Definition: hlinearmixer.h:8
HLinearMixer::SetWriter
void SetWriter(HWriter< T > *writer)
Definition: hlinearmixer.h:62
HLinearMixer::HLinearMixer
HLinearMixer(HReader< T > *reader_1, HReader< T > *reader_2, size_t blocksize, HProbe< T > *probe=NULL)
Definition: hlinearmixer.cpp:12
HWriterConsumer
Definition: hwriterconsumer.h:8