Mozzi  version v2.0
sound synthesis library for Arduino
OverSample.h
1 /*
2  * OverSample.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 OVERSAMPLE_H
13 #define OVERSAMPLE_H
14 
15 #include "RollingAverage.h"
16 
17 
41 template <class T, const uint8_t RESOLUTION_INCREASE_BITS>
42 class OverSample: public RollingAverage<T, (1<<(RESOLUTION_INCREASE_BITS*2))>
43 {
44 
45 public:
46  using RollingAverage<T, (1<<(RESOLUTION_INCREASE_BITS*2))>::add;
47 
53  T next(T input)
54  {
55  return add(input)>>RESOLUTION_INCREASE_BITS;
56  }
57 
58 };
59 
60 
66 #endif // #ifndef OVERSAMPLE_H
Enables the resolution of analog inputs to be increased by oversampling and decimation.
Definition: OverSample.h:43
Calculates a running average over a specified number of the most recent readings.