Plaquette
 
Loading...
Searching...
No Matches
MovingFilter.h
1/*
2 * MovingFilter.h
3 *
4 * (c) 2022 Sofian Audry :: info(@)sofianaudry(.)com
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef MOVING_FILTER_H_
21#define MOVING_FILTER_H_
22
23#include "PqCore.h"
24
25#define MOVING_FILTER_INFINITE_TIME_WINDOW (-1)
26
27namespace pq {
28
29class MovingFilter : public AnalogSource {
30protected:
36
37 virtual ~MovingFilter() {}
38
39public:
41 virtual void infiniteTimeWindow() = 0;
42
44 virtual void timeWindow(float seconds) = 0;
45
47 virtual float timeWindow() const = 0;
48
50 virtual bool timeWindowIsInfinite() const = 0;
51
53 virtual void cutoff(float hz);
54
56 virtual float cutoff() const;
57
59 virtual void reset();
60
65 virtual void resumeCalibrating();
66
71 virtual void pauseCalibrating();
72
74 virtual void toggleCalibrating();
75
77 virtual bool isCalibrating() const;
78
79protected:
80 // Start/stop calibration flag.
81 bool _isCalibrating : 1;
82 uint8_t _nValuesStep : 7;
83};
84
85}
86
87#endif
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
Definition MovingFilter.h:29
virtual void infiniteTimeWindow()=0
Sets time window to infinite.
virtual void resumeCalibrating()
Switches to calibration mode (default).
Definition MovingFilter.cpp:46
virtual void timeWindow(float seconds)=0
Changes the time window (expressed in seconds).
virtual bool isCalibrating() const
Returns true iff the moving filter is in calibration mode.
Definition MovingFilter.cpp:58
virtual void toggleCalibrating()
Toggles calibration mode.
Definition MovingFilter.cpp:54
virtual void reset()
Resets the moving filter.
Definition MovingFilter.cpp:42
virtual bool timeWindowIsInfinite() const =0
Returns true if time window is infinite.
virtual float timeWindow() const =0
Returns the time window (expressed in seconds).
virtual void pauseCalibrating()
Switches to non-calibration mode: calls to put(value) will return filtered value without updating the...
Definition MovingFilter.cpp:50
virtual float cutoff() const
Returns the time window cutoff frequency (expressed in Hz).
Definition MovingFilter.cpp:38
float seconds() const
Returns engine time in seconds.
Definition PqCore.h:348
Engine * engine() const
Returns the engine that owns this unit.
Definition PqCore.h:382