Mozzi  alpha 0.01.1t
sound synthesis library for Arduino
 All Classes Functions Typedefs
WaveShaper.h
00001 /*
00002  * WaveShaper.h
00003  *
00004  * Copyright 2012 Tim Barrass.
00005  *
00006  * This file is part of Mozzi.
00007  *
00008  * Mozzi is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * Mozzi is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with Mozzi.  If not, see <http://www.gnu.org/licenses/>.
00020  *
00021  */
00022 
00023 #ifndef WAVESHAPER_H_
00024 #define WAVESHAPER_H_
00025 
00026 #include "Arduino.h"
00027 
00032 template <class T>
00033 class WaveShaper
00034                 {}
00035 ;
00036 
00037 
00038 
00040 template <>
00041 class WaveShaper < char>
00042 {
00043 
00044 public:
00049                 WaveShaper(const char  * TABLE_NAME):table(TABLE_NAME)
00050                 {
00051                                 ;
00052                 }
00053 
00054 
00062                 inline
00063                 char next(unsigned char in)
00064                 {
00065                                 return (char) pgm_read_byte_near(table + in);
00066                 }
00067 
00068 private:
00069                 const char  * table;
00070 };
00071 
00072 
00073 
00075 template <>
00076 class WaveShaper <int>
00077 {
00078 
00079 public:
00084                 WaveShaper(const int __attribute__((progmem)) * TABLE_NAME):table(TABLE_NAME)
00085                 {
00086                                 ;
00087                 }
00088 
00089 
00100                 inline
00101                 int next(int in)
00102                 {
00103                                 return (unsigned int) pgm_read_word_near(table + in);
00104                 }
00105 
00106 private:
00107                 const int __attribute__((progmem)) * table;
00108 };
00109 
00110 
00111 #endif /* WAVESHAPER_H_ */
00112 
00113