Mozzi  version 2015-05-11-20:23
sound synthesis library for Arduino
 All Classes Functions Typedefs Groups
WaveShaper.h
1 /*
2  * WaveShaper.h
3  *
4  * Copyright 2012 Tim Barrass.
5  *
6  * This file is part of Mozzi.
7  *
8  * Mozzi is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
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 (int8_t) pgm_read_byte_near(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 (uint16_t) pgm_read_word_near(table + in);
94  }
95 
96 private:
97  const int16_t * table;
98 };
99 
103 #endif /* WAVESHAPER_H_ */
104 
105 
int8_t next(byte in)
Maps input to output, transforming it according to the table being used.
Definition: WaveShaper.h:52
WaveShaper maps values from its input to values in a table, which are returned as output...
Definition: WaveShaper.h:22
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(const int8_t *TABLE_NAME)
Constructor.
Definition: WaveShaper.h:38