annotate Source/TouchKeys/TouchkeyOscEmulator.h @ 56:b4a2d2ae43cf tip

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