Mozzi  version v2.0
sound synthesis library for Arduino
WaveShaper.h
1 /*
2  * WaveShaper.h
3  *
4  * This file is part of Mozzi.
5  *
6  * Copyright 2012-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 WAVESHAPER_H_
13 #define WAVESHAPER_H_
14 
15 #include "Arduino.h"
16 
21 template <class T>
23  {}
24 ;
25 
26 
28 template <>
29 class WaveShaper <char>
30 {
31 
32 public:
38  WaveShaper(const int8_t * TABLE_NAME):table(TABLE_NAME)
39  {
40  ;
41  }
42 
43 
51  inline
52  int8_t next(byte in)
53  {
54  return FLASH_OR_RAM_READ<const int8_t>(table + in);
55  }
56 
57 private:
58  const int8_t * table;
59 };
60 
61 
62 
64 template <>
65 class WaveShaper <int>
66 {
67 
68 public:
74  WaveShaper(const int16_t * TABLE_NAME):table(TABLE_NAME)
75  {
76  ;
77  }
78 
79 
90  inline
91  int next(int in)
92  {
93  return FLASH_OR_RAM_READ<const int16_t>(table + in);
94  }
95 
96 private:
97  const int16_t * table;
98 };
99 
103 #endif /* WAVESHAPER_H_ */
WaveShaper(const int8_t *TABLE_NAME)
Constructor.
Definition: WaveShaper.h:38
int8_t next(byte in)
Maps input to output, transforming it according to the table being used.
Definition: WaveShaper.h:52
int next(int in)
Maps input to output, transforming it according to the table being used.
Definition: WaveShaper.h:91
WaveShaper(const int16_t *TABLE_NAME)
Constructor.
Definition: WaveShaper.h:74
WaveShaper maps values from its input to values in a table, which are returned as output.
Definition: WaveShaper.h:23