Mozzi
version v2.0
sound synthesis library for Arduino
AutoRange.h
1
/*
2
* AutoRange.h
3
*
4
* This file is part of Mozzi.
5
*
6
* Copyright 2013-2024 Tim Barrass and the Mozzi Team
7
*
8
* Mozzi is licensed under the GNU Lesser General Public Licence (LGPL) Version 2.1 or later.
9
*
10
*/
11
12
#ifndef AUTORANGE_H
13
#define AUTORANGE_H
14
18
template
<
class
T>
19
class
20
AutoRange
{
21
22
public
:
28
AutoRange
(T min_expected, T max_expected):range_min(max_expected),range_max(min_expected),range(0)
29
{
30
}
31
32
36
void
next
(T n)
37
{
38
if
(n > range_max)
39
{
40
range_max = n;
41
range = range_max - range_min;
42
}
43
else
44
{
45
if
(n< range_min)
46
{
47
range_min = n;
48
range = range_max - range_min;
49
}
50
}
51
}
52
56
T
getMin
()
57
{
58
return
range_min;
59
}
60
61
65
T
getMax
()
66
{
67
return
range_max;
68
}
69
70
74
T
getRange
()
75
{
76
return
range;
77
}
78
79
private
:
80
T range_max, range_min, range;
81
82
};
83
84
#endif
// #ifndef AUTORANGE_H
AutoRange::AutoRange
AutoRange(T min_expected, T max_expected)
Constructor.
Definition:
AutoRange.h:28
AutoRange::getMax
T getMax()
Returns the current maximum.
Definition:
AutoRange.h:65
AutoRange::getRange
T getRange()
Returns the current range.
Definition:
AutoRange.h:74
AutoRange::next
void next(T n)
Updates the current range.
Definition:
AutoRange.h:36
AutoRange::getMin
T getMin()
Returns the current minimum.
Definition:
AutoRange.h:56
AutoRange
Keeps a running calculation of the range of the input values it receives.
Definition:
AutoRange.h:20
Generated automatically using Doxygen. If info on this page is outdated, incomplete, or wrong, please open an issue at https://github.com/sensorium/Mozzi/issues