Mercurial > hg > touchkeys
comparison Source/TouchKeys/TouchkeyOscEmulator.h @ 9:f943785252fc
First prototype of TouchKeys OSC emulation. Not fully working yet, especially with mappings, but contains the basic mechanics.
author | Andrew McPherson <andrewm@eecs.qmul.ac.uk> |
---|---|
date | Wed, 20 Nov 2013 00:38:15 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
8:2832beb744bb | 9:f943785252fc |
---|---|
1 /* | |
2 TouchKeys: multi-touch musical keyboard control software | |
3 Copyright (c) 2013 Andrew McPherson | |
4 | |
5 This program is free software: you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation, either version 3 of the License, or | |
8 (at your option) any later version. | |
9 | |
10 This program is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 GNU General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program. If not, see <http://www.gnu.org/licenses/>. | |
17 | |
18 ===================================================================== | |
19 | |
20 TouchkeyOscEmulator.h: emulates a TouchKeys source using OSC messages | |
21 */ | |
22 | |
23 #ifndef TOUCHKEYOSCEMULATOR_H_INCLUDED | |
24 #define TOUCHKEYOSCEMULATOR_H_INCLUDED | |
25 | |
26 #include "Osc.h" | |
27 #include "PianoKeyboard.h" | |
28 | |
29 class TouchkeyOscEmulator : public OscHandler { | |
30 public: | |
31 // *** Constructor *** | |
32 TouchkeyOscEmulator(PianoKeyboard& keyboard, OscMessageSource& messageSource); | |
33 | |
34 // *** Destructor *** | |
35 ~TouchkeyOscEmulator(); | |
36 | |
37 // *** TouchKeys emulation methods *** | |
38 int lowestMidiNote() { return lowestMidiNote_; } | |
39 void setLowestMidiNote(int note) { lowestMidiNote_ = note; } | |
40 | |
41 void allTouchesOff(bool send = true); | |
42 | |
43 // *** OSC handler method *** | |
44 bool oscHandlerMethod(const char *path, const char *types, int numValues, lo_arg **values, void *data); | |
45 | |
46 // *** Data processing methods *** | |
47 // New touch data point received | |
48 void touchReceived(int key, int touch, float x, float y); | |
49 | |
50 // Touch removed | |
51 void touchOffReceived(int key, int touch); | |
52 | |
53 private: | |
54 void clearTouchData(int i); // Clear touch data for a particular key | |
55 void removeTouchFromFrame(int note, int index); // Remove a particular touch from the frame | |
56 void addTouchToFrame(int note, int touchId, float x, float y); // Add a touch with a particular ID | |
57 void updateTouchInFrame(int note, int index, float x, float y); // Update the touch at the given index | |
58 | |
59 private: | |
60 PianoKeyboard& keyboard_; // Main keyboard controller | |
61 OscMessageSource& source_; // Source of OSC messages | |
62 | |
63 int lowestMidiNote_; // Lowest MIDI note | |
64 | |
65 KeyTouchFrame touchFrames_[127]; // Current state of each virtual TouchKey | |
66 int touchIdAssignments_[127][3]; // Assignments between OSC touch IDs and TouchKeys touch IDs | |
67 }; | |
68 | |
69 #endif // TOUCHKEYOSCEMULATOR_H_INCLUDED |