HARDT - The Ham Radio DSP Toolkit
hiqfirdecimator.h
1 #ifndef __HIQFIRDECIMATOR_H
2 #define __HIQFIRDECIMATOR_H
3 
4 #include "hardt.h"
5 #include "hreader.h"
6 #include "hwriter.h"
7 #include "hwriterconsumer.h"
8 #include "hprobe.h"
9 #include "hfir.h"
10 
11 #include <vector>
12 
14 template <class T>
15 class HIqFirDecimator: public HReader<T>, public HWriter<T>, public HWriterConsumer<T>
16 {
17  private:
18 
19  HWriter<T>* _writer;
20  HReader<T>* _reader;
21  size_t _blocksize;
22 
23  HProbe<T>* _probe;
24 
25  int _factor;
26  T* _buffer;
27  T* _filtered;
28  size_t _length;
29  bool _collect;
30 
31  HFir<T>* _firI;
32  HFir<T>* _firQ;
33 
34 
35  void Init(float* coefficients, int points);
36 
37  public:
38 
55  HIqFirDecimator(HWriter<T>* writer, int factor, float* coefficients, int points, size_t blocksize, bool collect = true, HProbe<T>* probe = nullptr);
56 
73  HIqFirDecimator(HWriterConsumer<T>* consumer, int factor, float* coefficients, int points, size_t blocksize, bool collect = true, HProbe<T>* probe = nullptr);
74 
92  HIqFirDecimator(HReader<T>* reader, int factor, float* coefficients, int points, size_t blocksize, bool collect = true, HProbe<T>* probe = nullptr);
93 
95  void SetWriter(HWriter<T>* writer) {
96  _writer = writer;
97  }
98 
103 
110  int Write(T* src, size_t blocksize);
111 
118  int Read(T* dest, size_t blocksize);
119 
123  bool Start() {
124  if( _writer != nullptr )
125  {
126  return _writer->Start();
127  }
128  if( _reader != nullptr )
129  {
130  return _reader->Start();
131  }
132  return true;
133  }
134 
138  bool Stop() {
139  if( _writer != nullptr )
140  {
141  return _writer->Stop();
142  }
143  if( _reader != nullptr )
144  {
145  return _reader->Stop();
146  }
147  return true;
148  }
149 
153  bool Command(HCommand* command) {
154  if( _writer != nullptr )
155  {
156  return _writer->Command(command);
157  }
158  if( _reader != nullptr )
159  {
160  return _reader->Command(command);
161  }
162  return true;
163  }
164 };
165 
166 #endif
HReader::Command
virtual bool Command(HCommand *command)=0
HIqFirDecimator::Read
int Read(T *dest, size_t blocksize)
Definition: hiqfirdecimator.cpp:117
HIqFirDecimator::Command
bool Command(HCommand *command)
Definition: hiqfirdecimator.h:153
HReader::Stop
virtual bool Stop()
Definition: hreader.h:41
HWriter
Definition: hwriter.h:10
HIqFirDecimator::Start
bool Start()
Definition: hiqfirdecimator.h:123
HReader::Start
virtual bool Start()
Definition: hreader.h:35
HIqFirDecimator::HIqFirDecimator
HIqFirDecimator(HWriter< T > *writer, int factor, float *coefficients, int points, size_t blocksize, bool collect=true, HProbe< T > *probe=nullptr)
Definition: hiqfirdecimator.cpp:9
HIqFirDecimator::~HIqFirDecimator
~HIqFirDecimator()
Definition: hiqfirdecimator.cpp:52
HWriter::Command
virtual bool Command(HCommand *command)=0
HReader
Definition: hreader.h:24
HWriter::Start
virtual bool Start()
Definition: hwriter.h:21
HProbe
Definition: hprobe.h:10
HFir
Definition: hfir.h:6
HIqFirDecimator::Stop
bool Stop()
Definition: hiqfirdecimator.h:138
HCommand
Definition: hcommand.h:81
HIqFirDecimator::SetWriter
void SetWriter(HWriter< T > *writer)
Definition: hiqfirdecimator.h:95
HWriter::Stop
virtual bool Stop()
Definition: hwriter.h:27
HIqFirDecimator::Write
int Write(T *src, size_t blocksize)
Definition: hiqfirdecimator.cpp:80
HWriterConsumer
Definition: hwriterconsumer.h:8
HIqFirDecimator
Definition: hiqfirdecimator.h:15