Mozzi
version v2.0
sound synthesis library for Arduino
AutoMap.h
1
/*
2
* AutoMap.h
3
/*
4
* AutoMap.h
5
*
6
* This file is part of Mozzi.
7
*
8
* Copyright 2012-2024 Tim Barrass and the Mozzi Team
9
*
10
* Mozzi is licensed under the GNU Lesser General Public Licence (LGPL) Version 2.1 or later.
11
*
12
*/
13
14
#ifndef AUTOMAP_H_
15
#define AUTOMAP_H_
16
17
// for map - maybe rewrite my own templated map for better efficiency
18
#include <Arduino.h>
// for map
19
20
#include "AutoRange.h"
21
29
class
AutoMap
:
public
AutoRange
<int>
30
{
31
public
:
36
AutoMap
(
int
min_expected,
int
max_expected,
int
map_to_min,
int
map_to_max)
37
:
inherited
(min_expected,max_expected),map_min(map_to_min), map_max(map_to_max)
38
{
39
}
40
41
47
inline
48
int
next
(
int
n)
49
{
50
inherited::next
(n);
51
return
map(n,
inherited::getMin
(),
inherited::getMax
(),map_min,map_max);
52
}
53
59
inline
60
int
operator()
(
int
n)
61
{
62
return
next
(n);
63
}
64
65
66
private
:
67
typedef
AutoRange <int>
inherited;
68
int
map_min, map_max;
69
};
70
71
77
#endif
// #ifndef AUTOMAP_H_
AutoRange< int >
AutoMap::next
int next(int n)
Process the next value and return it mapped to the range which was set in the constructor.
Definition:
AutoMap.h:48
AutoRange< int >::getMax
int getMax()
Returns the current maximum.
Definition:
AutoRange.h:65
AutoRange< int >::next
void next(int n)
Updates the current range.
Definition:
AutoRange.h:36
AutoRange< int >::getMin
int getMin()
Returns the current minimum.
Definition:
AutoRange.h:56
AutoMap::AutoMap
AutoMap(int min_expected, int max_expected, int map_to_min, int map_to_max)
Constructor.
Definition:
AutoMap.h:36
AutoMap::operator()
int operator()(int n)
Process the next value and return it mapped to the range which was set in the constructor.
Definition:
AutoMap.h:60
AutoMap
Automatically map an input value to an output range without knowing the precise range of inputs befor...
Definition:
AutoMap.h:30
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