Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 125 lines (94 sloc) 3.198 kb
4d0d6b5 @blajzer Added license (MIT).
authored
1 /*
2 Copyright (c) 2009-2010 Brett Lajzer
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy
5 of this software and associated documentation files (the "Software"), to deal
6 in the Software without restriction, including without limitation the rights
7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 copies of the Software, and to permit persons to whom the Software is
9 furnished to do so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in
12 all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 THE SOFTWARE.
21 */
22
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
23 #ifndef _WAFFLE_GENERATORS_H_
24 #define _WAFFLE_GENERATORS_H_
25
26 #include "Module.h"
27
28 #include <cstdlib>
29
30 namespace waffle {
31
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
32 class WaveformGenerator : public Module {
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
33 public:
c39a649 @blajzer Modules can now be shared, and assembled in cyclical graphs.
authored
34 virtual ~WaveformGenerator(){};
35
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
36 void setFreq(Module *f);
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
37 void setPhase(Module *p);
c39a649 @blajzer Modules can now be shared, and assembled in cyclical graphs.
authored
38
39 virtual bool isValid();
40 virtual void reset();
621ac41 @blajzer Modules now pass ownership to Waffle when added as a patch. This fixes g...
authored
41
42 virtual void gatherSubModules(std::set<Module *> &modules);
43
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
44 protected:
c39a649 @blajzer Modules can now be shared, and assembled in cyclical graphs.
authored
45 WaveformGenerator() : Module(), m_freq(NULL), m_phase(NULL), m_pos(0.0) {} //should never be explicitly instantiated
46 WaveformGenerator(Module *f, Module *p) : Module(), m_freq(f), m_phase(p), m_pos(0.0) {} //should never be explicitly instantiated
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
47
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
48 Module *m_freq;
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
49 Module *m_phase;
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
50 double m_pos;
51 };
52
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
53 class GenSine : public WaveformGenerator {
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
54 public:
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
55 GenSine(Module *f, Module *p);
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
56
57 virtual double run();
58 };
59
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
60 class GenTriangle : public WaveformGenerator {
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
61 public:
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
62 GenTriangle(Module *f, Module *p);
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
63
64 virtual double run();
65 };
66
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
67 class GenSawtooth : public WaveformGenerator {
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
68 public:
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
69 GenSawtooth(Module *f, Module *p);
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
70
71 virtual double run();
72 };
73
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
74 class GenRevSawtooth : public WaveformGenerator {
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
75 public:
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
76 GenRevSawtooth(Module *f, Module *p);
77
78 virtual double run();
79 };
80
81 class GenSquare : public WaveformGenerator {
82 public:
83 GenSquare() : WaveformGenerator(), m_thresh(NULL) {}
84 GenSquare(Module *f, Module *p, Module *t);
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
85 void setThreshold(Module *t);
86
87 virtual double run();
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
88 virtual bool isValid() {
89 if(WaveformGenerator::isValid() && m_thresh != NULL)
90 return m_thresh->isValid();
91 else
92 return false;
93 }
621ac41 @blajzer Modules now pass ownership to Waffle when added as a patch. This fixes g...
authored
94
95 virtual void gatherSubModules(std::set<Module *> &modules);
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
96
97 protected:
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
98 Module *m_thresh;
99 };
100
101 class GenNoise : public Module {
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
102 public:
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
103 virtual double run();
104 virtual bool isValid(){ return true; }
621ac41 @blajzer Modules now pass ownership to Waffle when added as a patch. This fixes g...
authored
105
106 virtual void gatherSubModules(std::set<Module *> &modules) { }
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
107 };
108
109 class Value : public Module {
110 public:
621ac41 @blajzer Modules now pass ownership to Waffle when added as a patch. This fixes g...
authored
111 Value() : Module(), m_value(0.0) {}
112 Value(double v) : Module(), m_value(v) {}
113 virtual double run(){}
2d60157 @blajzer Optimization and potential infinite recursion fixes.
authored
114 virtual double getValue();
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
115 virtual bool isValid(){ return true; }
621ac41 @blajzer Modules now pass ownership to Waffle when added as a patch. This fixes g...
authored
116 virtual void gatherSubModules(std::set<Module *> &modules) { }
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
117 void setValue(double v);
118
074fe77 @blajzer Refactoring, README, phase support, validation fixes.
authored
119 protected:
d019516 Broke filters and generators out into multiple files for easier maintain...
Brett Lajzer authored
120 double m_value;
121 };
122
123 }
124 #endif
Something went wrong with that request. Please try again.