Mozzi  version 2016-12-11-17:03
sound synthesis library for Arduino
OverSample.h
1 #ifndef OVERSAMPLE_H
2 #define OVERSAMPLE_H
3 
4 /*
5  * OverSample.h
6  *
7  * Copyright 2013 Tim Barrass.
8  *
9  * This file is part of Mozzi.
10  *
11  * Mozzi is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
12  *
13  */
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
Calculates a running average over a specified number of the most recent readings. ...
Enables the resolution of analog inputs to be increased by oversampling and decimation.
Definition: OverSample.h:42