HARDT - The Ham Radio DSP Toolkit
hgenerator.h
1 #ifndef __HGENERATOR_H
2 #define __HGENERATOR_H
3 
4 #include "hardt.h"
5 #include "hsoundcard.h"
6 #include "hobject.h"
7 #include "hreader.h"
8 #include <math.h>
9 #include <limits>
10 
16 template <class T>
17 class HGenerator : public HReader<T>
18 {
19  private:
20 
21  T* _lot;
22  int _lotSize;
23  int _it;
24  float _delta;
25  H_SAMPLE_RATE _rate;
26 
27  float* _flot;
28 
29  float _zero;
30 
31  void Init(H_SAMPLE_RATE rate, int frequency, T amplitude, float phase);
32 
33  protected:
34 
43  HGenerator(H_SAMPLE_RATE rate, int frequency, T amplitude, float phase = 0);
44 
46  ~HGenerator();
47 
48  public:
49 
56  int Read(T* dest, size_t blocksize);
57 
59  void Calculate(int frequency, T amplitude, float phase);
60 
66  bool Command(HCommand* command) {
67  // No further propagation of commands
68  return true;
69  }
70 
76  inline T Current() {
77  return _lot[_it];
78  }
79 
85  inline T Next() {
86 
87  T value = _lot[_it];
88 
89  // Increase to next lot value
90  _it += _delta;
91 
92  // Past the end of the lot ?
93  if( _it >= _lotSize )
94  {
95  _it -= _lotSize;
96  }
97 
98  return value;
99  }
100 };
101 
102 #endif
HGenerator::Read
int Read(T *dest, size_t blocksize)
Definition: hgenerator.cpp:24
HGenerator::HGenerator
HGenerator(H_SAMPLE_RATE rate, int frequency, T amplitude, float phase=0)
Definition: hgenerator.cpp:7
HGenerator::Current
T Current()
Definition: hgenerator.h:76
HGenerator::Next
T Next()
Definition: hgenerator.h:85
HGenerator
Definition: hgenerator.h:17
HReader
Definition: hreader.h:24
HGenerator::Calculate
void Calculate(int frequency, T amplitude, float phase)
Definition: hgenerator.cpp:66
HCommand
Definition: hcommand.h:81
HGenerator::~HGenerator
~HGenerator()
Definition: hgenerator.cpp:17
HGenerator::Command
bool Command(HCommand *command)
Definition: hgenerator.h:66