uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
lookup_tables.h
Go to the documentation of this file.
1 
8 /*
9  * Copyright 2015, 2016 Sebastian Neuser
10  *
11  * This file is part of the uMIDI firmware.
12  *
13  * The MIDI volume controller firmware is free software: you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation, either version 3 of the License, or
16  * (at your option) any later version.
17  *
18  * The MIDI volume controller firmware is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with the uMIDI firmware. If not, see <http://www.gnu.org/licenses/>.
25  */
26 
27 #ifndef _LOOKUP_TABLES_H
28 #define _LOOKUP_TABLES_H
29 
30 
31 //---------------- includes ----------------//
32 #include <stdint.h>
33 #include <avr/pgmspace.h>
34 
35 
36 //---------------- Lookup table declarations ----------------//
37 
39 extern const uint8_t lookup_table_resolution;
40 
42 extern const uint16_t exp_table[] PROGMEM;
43 
45 extern const uint16_t log_table[] PROGMEM;
46 
48 extern const uint16_t sine_table[] PROGMEM;
49 
50 
51 //---------------- Inline functions to read out the tables ----------------//
52 
58 inline uint16_t lookup_exp(uint8_t x)
59 {
60  return pgm_read_word(&(exp_table[x]));
61 }
62 
68 inline uint16_t lookup_log(uint8_t x)
69 {
70  return pgm_read_word(&(log_table[x]));
71 }
72 
78 inline uint16_t lookup_sine(uint8_t x)
79 {
80  return pgm_read_word(&(sine_table[x]));
81 }
82 
83 //---------------- EOF ----------------//
84 #endif // LOOKUP_TABLES_H
85 
const uint16_t log_table[]
Lookup table for the natural logaritm function.
uint16_t lookup_exp(uint8_t x)
Looks up an exponential value in the corresponding table.
Definition: lookup_tables.h:58
const uint16_t exp_table[]
Lookup table for an exponential function.
uint16_t lookup_sine(uint8_t x)
Looks up a sine function value in the corresponding table.
Definition: lookup_tables.h:78
uint16_t lookup_log(uint8_t x)
Looks up the natural log value in the corresponding table.
Definition: lookup_tables.h:68
const uint16_t sine_table[]
Lookup table for the sine function.
const uint8_t lookup_table_resolution
Resolution (y-axis) of the lookup tables in bits.