HARDT - The Ham Radio DSP Toolkit
hinterpolator.h
1 #ifndef __HINTERPOLATOR_H
2 #define __HINTERPOLATOR_H
3 
4 #include "hreader.h"
5 #include "hwriter.h"
6 #include "hwriterconsumer.h"
7 #include "hprobe.h"
8 
9 #include <vector>
10 
12 template <class T>
13 class HInterpolator: public HReader<T>, public HWriter<T>, public HWriterConsumer<T>
14 {
15  private:
16 
17  HWriter<T>* _writer;
18  HReader<T>* _reader;
19  size_t _blocksize;
20 
21  HProbe<T>* _probe;
22 
23  int _factor;
24  T* _inBuffer;
25  T* _outBuffer;
26  int _length;
27 
28  float * _coefficients;
29  int _firLength;
30  std::vector<HFir<T>*> _firs;
31 
32  void Init(float* coefficients = nullptr);
33 
34  protected:
35 
44  HInterpolator(HWriter<T>* writer, int factor, size_t blocksize, HProbe<T>* probe = nullptr);
45 
54  HInterpolator(HWriterConsumer<T>* consumer, int factor, size_t blocksize, HProbe<T>* probe = nullptr);
55 
64  HInterpolator(HReader<T>* reader, int factor, size_t blocksize, HProbe<T>* probe = nullptr);
65 
66  public:
67 
78  HInterpolator(HWriter<T>* writer, int factor, float* coefficients, int length, size_t blocksize, HProbe<T>* probe = nullptr);
79 
90  HInterpolator(HWriterConsumer<T>* consumer, int factor, float* coefficients, int length, size_t blocksize, HProbe<T>* probe = nullptr);
91 
102  HInterpolator(HReader<T>* reader, int factor, float* coefficients, int length, size_t blocksize, HProbe<T>* probe = nullptr);
103 
109  void SetWriter(HWriter<T>* writer) {
110  _writer = writer;
111  }
112 
116  ~HInterpolator();
117 
124  int Write(T* src, size_t blocksize);
125 
132  int Read(T* dest, size_t blocksize);
133 
137  bool Start() {
138  if( _writer != nullptr )
139  {
140  return _writer->Start();
141  }
142  if( _reader != nullptr )
143  {
144  return _reader->Start();
145  }
146  return true;
147  }
148 
152  bool Stop() {
153  if( _writer != nullptr )
154  {
155  return _writer->Stop();
156  }
157  if( _reader != nullptr )
158  {
159  return _reader->Stop();
160  }
161  return true;
162  }
163 
169  bool Command(HCommand* command) {
170  if( _writer != nullptr )
171  {
172  return _writer->Command(command);
173  }
174  if( _reader != nullptr )
175  {
176  return _reader->Command(command);
177  }
178  return true;
179  }
180 };
181 
182 #endif
HReader::Command
virtual bool Command(HCommand *command)=0
HInterpolator
Definition: hinterpolator.h:13
HInterpolator::Stop
bool Stop()
Definition: hinterpolator.h:152
HReader::Stop
virtual bool Stop()
Definition: hreader.h:41
HWriter
Definition: hwriter.h:10
HReader::Start
virtual bool Start()
Definition: hreader.h:35
HInterpolator::HInterpolator
HInterpolator(HWriter< T > *writer, int factor, size_t blocksize, HProbe< T > *probe=nullptr)
Definition: hinterpolator.cpp:9
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
HInterpolator::SetWriter
void SetWriter(HWriter< T > *writer)
Definition: hinterpolator.h:109
HCommand
Definition: hcommand.h:81
HInterpolator::Read
int Read(T *dest, size_t blocksize)
Definition: hinterpolator.cpp:197
HWriter::Stop
virtual bool Stop()
Definition: hwriter.h:27
HInterpolator::Write
int Write(T *src, size_t blocksize)
Definition: hinterpolator.cpp:151
HInterpolator::Start
bool Start()
Definition: hinterpolator.h:137
HInterpolator::Command
bool Command(HCommand *command)
Definition: hinterpolator.h:169
HWriterConsumer
Definition: hwriterconsumer.h:8
HInterpolator::~HInterpolator
~HInterpolator()
Definition: hinterpolator.cpp:101