Plaquette
 
Loading...
Searching...
No Matches
SquareWave.h
1/*
2 * SquareWave.h
3 *
4 * (c) 2015 Sofian Audry :: info(@)sofianaudry(.)com
5 * (c) 2015 Thomas O Fredericks :: tof(@)t-o-f(.)info
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef SQUARE_WAVE_H_
22#define SQUARE_WAVE_H_
23
24#include "AbstractWave.h"
25
26namespace pq {
27
32class [[deprecated("Use Wave(SQUARE) instead.")]] SquareWave : public AbstractWave {
33public:
38 SquareWave(Engine& engine = Engine::primary());
39
45 SquareWave(float period, Engine& engine = Engine::primary());
46
53 SquareWave(float period, float skew, Engine& engine = Engine::primary());
54
55 virtual ~SquareWave() {}
56
57 // /// Returns true iff the input is "on".
58 // virtual bool isOn();
59
60 // /// Returns true iff the input is "off".
61 // virtual bool isOff() { return !isOn(); }
62
63 // /// Operator that allows usage in conditional expressions.
64 // explicit operator bool() { return isOn(); }
65
66 // /// Returns true if the value rose.
67 // virtual bool rose() { return changeState() > 0; }
68
69 // /// Returns true if the value fell.
70 // virtual bool fell() { return changeState() < 0; }
71
72 // /// Returns true if the value changed.
73 // virtual bool changed() { return changeState() != 0; }
74
75 // /// Difference between current and previous value of the unit.
76 // virtual int8_t changeState() { return _changeState; }
77
78 // /// Registers event callback on rise event.
79 // virtual void onRise(EventCallback callback) { onEvent(callback, EVENT_RISE); }
80
81 // /// Registers event callback on fall event.
82 // virtual void onFall(EventCallback callback) { onEvent(callback, EVENT_FALL); }
83
84 // /// Registers event callback on change event.
85 // virtual void onChange(EventCallback callback) { onEvent(callback, EVENT_CHANGE); }
86
87 // /**
88 // * Returns oscillator's on/off with given phase shift (in % of period).
89 // * Supports values outside [0,1], which will be wrapped accordingly.
90 // * @param phase the phase shift (in % of period)
91 // * @return the boolean value of oscillator with given phase shift
92 // */
93 // virtual bool shiftByIsOn(float phaseShift);
94
95 // /**
96 // * Returns the oscillator's on/off at a given absolute phase (in % of period).
97 // * Supports values outside [0,1], which will be wrapped accordingly.
98 // * @param phase the absolute phase at which to evaluate the oscillator (in % of period)
99 // * @return the value of the oscillator at the given phase
100 // */
101 // virtual bool atPhaseIsOn(float phase);
102
104 [[deprecated("Use skew(float) instead.")]]
105 virtual void dutyCycle(float dutyCycle) { skew(dutyCycle); }
106
108 [[deprecated("Use skew() instead.")]]
109 virtual float dutyCycle() const { return skew(); }
110
111protected:
112 // Core Plaquette methods.
113 virtual void step();
114
116 // virtual bool eventTriggered(EventType eventType) {
117 // switch (eventType) {
118 // case EVENT_CHANGE: return changed();
119 // case EVENT_RISE: return rose();
120 // case EVENT_FALL: return fell();
121 // default: return AbstractWave::eventTriggered(eventType);
122 // }
123 // }
124
125protected:
126 // Returns value in [0, 1].
127 virtual q0_32u_t _getFixed32(q0_32u_t t);
128
129 // The current high/low value of the unit.
130 bool _onValue = false;
131};
132
134[[deprecated("Use Wave(SQUARE) instead.")]]
135typedef SquareWave SquareOsc;
136
137}
138
139#endif
Triangle/sawtooth oscillator.
Definition AbstractWave.h:33
The main Plaquette static class containing all the units.
Definition PqCore.h:60
Definition SquareWave.h:32
virtual float dutyCycle() const
Definition SquareWave.h:109
virtual void dutyCycle(float dutyCycle)
Definition SquareWave.h:105