Plaquette
 
Loading...
Searching...
No Matches
AbstractWave.h
1/*
2 * AbstractWave.h
3 *
4 * (c) 2022 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 ABSTRACT_WAVE_H_
22#define ABSTRACT_WAVE_H_
23
24#include "PqCore.h"
25#include "AbstractOscillator.h"
26#include "pq_phase_utils.h"
27
28namespace pq {
29
34public:
40
47
55
56 virtual ~AbstractWave() {}
57
59 virtual float get();
60
68 virtual float shiftBy(float phaseShift);
69
75 virtual float shiftByTime(float timeShift);
76
85 virtual float atPhase(float phase);
86
91 virtual void amplitude(float amplitude);
92
94 virtual float amplitude() const { return fixed32ToFloat(_amplitude); }
95
100 virtual void skew(float skew);
101
103 virtual float skew() const { return fixed32ToFloat(_skew32); }
104
110 [[deprecated("Use skew(float) instead.")]]
111 virtual void width(float width) { skew(width); }
112
115 [[deprecated("Use skew() instead.")]]
116 virtual float width() const { return skew(); }
117
119 virtual void onBang(EventCallback callback);
120
121protected:
122 // Core Plaquette methods.
123 virtual void begin();
124 virtual void step();
125
126 // Returns true if event is triggered.
127 virtual bool eventTriggered(EventType eventType);
128
129 // Returns value in [0, 1] as fixed32-point value (to be defined by subclasses).
130 virtual q0_32u_t _getFixed32(q0_32u_t t) = 0;
131
132 // Returns amplified version of _get(t).
133 virtual float _getAmplified(q0_32u_t t);
134
135 // Amplitude (in %).
136 q0_32u_t _amplitude;
137
138 // Skew of the signal.
139 q0_32u_t _skew32;
140};
141
142}
143
144#endif
Triangle/sawtooth oscillator.
Definition AbstractOscillator.h:33
virtual float period() const
Returns the period (in seconds).
Definition AbstractOscillator.h:50
virtual float phaseShift() const
Returns the phase shift (ie.
Definition AbstractOscillator.cpp:166
virtual float phase() const
Returns the phase (in % of period).
Definition AbstractOscillator.h:83
Triangle/sawtooth oscillator.
Definition AbstractWave.h:33
virtual float atPhase(float phase)
Returns the oscillator's value at a given absolute phase (in % of period).
Definition AbstractWave.cpp:71
virtual void width(float width)
Definition AbstractWave.h:111
virtual float get()
Returns value in [0, 1].
Definition AbstractWave.cpp:36
virtual float skew() const
Returns the skew of the signal.
Definition AbstractWave.h:103
virtual void onBang(EventCallback callback)
Registers event callback on wave end-of-period ("bang") event.
Definition AbstractWave.cpp:84
virtual float amplitude() const
Returns the amplitude of the wave.
Definition AbstractWave.h:94
virtual float shiftBy(float phaseShift)
Returns oscillator's value with given phase shift (in % of period).
Definition AbstractWave.cpp:63
virtual float shiftByTime(float timeShift)
Returns oscillator's value with given phase shift expressed in time (in seconds).
Definition AbstractWave.cpp:67
virtual float width() const
Definition AbstractWave.h:116
virtual bool eventTriggered(EventType eventType)
Returns true iff an event of a certain type has been triggered.
Definition AbstractWave.cpp:88
An analog analog source that contains a value constrained to a finite range (typically in [0,...
Definition PqCore.h:444
The main Plaquette static class containing all the units.
Definition PqCore.h:60
static Engine & primary()
Returns the main instance of Plaquette.
Definition PqCore.cpp:31
Engine * engine() const
Returns the engine that owns this unit.
Definition PqCore.h:382