andrewm@0
|
1 /*
|
andrewm@0
|
2 TouchKeys: multi-touch musical keyboard control software
|
andrewm@0
|
3 Copyright (c) 2013 Andrew McPherson
|
andrewm@0
|
4
|
andrewm@0
|
5 This program is free software: you can redistribute it and/or modify
|
andrewm@0
|
6 it under the terms of the GNU General Public License as published by
|
andrewm@0
|
7 the Free Software Foundation, either version 3 of the License, or
|
andrewm@0
|
8 (at your option) any later version.
|
andrewm@0
|
9
|
andrewm@0
|
10 This program is distributed in the hope that it will be useful,
|
andrewm@0
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
andrewm@0
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
andrewm@0
|
13 GNU General Public License for more details.
|
andrewm@0
|
14
|
andrewm@0
|
15 You should have received a copy of the GNU General Public License
|
andrewm@0
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
andrewm@0
|
17
|
andrewm@0
|
18 =====================================================================
|
andrewm@0
|
19
|
andrewm@0
|
20 PianoTypes.h: some useful constants mainly relevant to continuous key angle
|
andrewm@0
|
21 */
|
andrewm@0
|
22
|
andrewm@0
|
23 #ifndef KEYCONTROL_PIANO_TYPES_H
|
andrewm@0
|
24 #define KEYCONTROL_PIANO_TYPES_H
|
andrewm@0
|
25
|
andrewm@0
|
26 #include "../Utility/Types.h"
|
andrewm@0
|
27
|
andrewm@0
|
28 #undef FIXED_POINT_PIANO_SAMPLES
|
andrewm@0
|
29
|
andrewm@0
|
30 // Data types. Allow for floating-point (more flexible) or fixed-point (faster) arithmetic
|
andrewm@0
|
31 // on piano key positions
|
andrewm@0
|
32 #ifdef FIXED_POINT_PIANO_SAMPLES
|
andrewm@0
|
33 typedef int key_position;
|
andrewm@0
|
34 typedef int key_velocity;
|
andrewm@0
|
35 #define scale_key_position(x) 4096*(key_position)(x)
|
andrewm@0
|
36 #define key_position_to_float(x) ((float)x/4096.0)
|
andrewm@0
|
37 #define key_abs(x) abs(x)
|
andrewm@0
|
38 #define calculate_key_velocity(dpos, dt) (key_velocity)((65536*dpos)/(key_position)dt)
|
andrewm@0
|
39 #define scale_key_velocity(x) (65536/4096)*(key_velocity)(x) // FIXME: TEST THIS!
|
andrewm@0
|
40 #else
|
andrewm@0
|
41 typedef float key_position;
|
andrewm@0
|
42 typedef float key_velocity;
|
andrewm@0
|
43 #define scale_key_position(x) (key_position)(x)
|
andrewm@0
|
44 #define key_position_to_float(x) (x)
|
andrewm@0
|
45 #define key_abs(x) fabsf(x)
|
andrewm@0
|
46 #define calculate_key_velocity(dpos, dt) (key_velocity)(dpos/(key_position)dt)
|
andrewm@0
|
47 #define scale_key_velocity(x) (key_velocity)(x)
|
andrewm@0
|
48 #endif /* FIXED_POINT_PIANO_SAMPLES */
|
andrewm@0
|
49
|
andrewm@0
|
50 #endif /* KEYCONTROL_PIANO_TYPES_H */ |