andrewm@0: /* andrewm@0: TouchKeys: multi-touch musical keyboard control software andrewm@0: Copyright (c) 2013 Andrew McPherson andrewm@0: andrewm@0: This program is free software: you can redistribute it and/or modify andrewm@0: it under the terms of the GNU General Public License as published by andrewm@0: the Free Software Foundation, either version 3 of the License, or andrewm@0: (at your option) any later version. andrewm@0: andrewm@0: This program is distributed in the hope that it will be useful, andrewm@0: but WITHOUT ANY WARRANTY; without even the implied warranty of andrewm@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the andrewm@0: GNU General Public License for more details. andrewm@0: andrewm@0: You should have received a copy of the GNU General Public License andrewm@0: along with this program. If not, see . andrewm@0: andrewm@0: ===================================================================== andrewm@0: andrewm@0: TouchkeyMultiFingerTriggerMappingFactory.h: factory for the multiple- andrewm@0: finger trigger mapping, which performs actions when two or more fingers andrewm@0: are added or removed from the key. andrewm@0: */ andrewm@0: andrewm@0: andrewm@0: #ifndef __TouchKeys__TouchkeyMultiFingerTriggerMappingFactory__ andrewm@0: #define __TouchKeys__TouchkeyMultiFingerTriggerMappingFactory__ andrewm@0: andrewm@0: #include "../TouchkeyBaseMappingFactory.h" andrewm@0: #include "TouchkeyMultiFingerTriggerMapping.h" andrewm@0: andrewm@0: class TouchkeyMultiFingerTriggerMappingFactory : public TouchkeyBaseMappingFactory { andrewm@0: private: andrewm@0: andrewm@0: public: andrewm@0: // ***** Constructor ***** andrewm@0: andrewm@0: // Default constructor, containing a reference to the PianoKeyboard class. andrewm@42: TouchkeyMultiFingerTriggerMappingFactory(PianoKeyboard &keyboard, MidiKeyboardSegment& segment); andrewm@0: andrewm@0: // ***** Destructor ***** andrewm@0: andrewm@0: ~TouchkeyMultiFingerTriggerMappingFactory() {} andrewm@0: andrewm@0: // ***** Accessors / Modifiers ***** andrewm@0: andrewm@0: virtual const std::string factoryTypeName() { return "Multi-Finger\nTrigger"; } andrewm@36: andrewm@42: // ***** Class-Specific Methods ***** andrewm@42: andrewm@42: // Parameters for multi-finger trigger andrewm@42: int getTouchesForTrigger() { return numTouchesForTrigger_; } andrewm@42: int getFramesForTrigger() { return numFramesForTrigger_; } andrewm@42: int getConsecutiveTapsForTrigger() { return numConsecutiveTapsForTrigger_; } andrewm@42: timestamp_diff_type getMaxTimeBetweenTapsForTrigger() { return maxTapSpacing_; } andrewm@42: bool getNeedsMidiNoteOn() { return needsMidiNoteOn_; } andrewm@42: int getTriggerOnAction() { return triggerOnAction_; } andrewm@42: int getTriggerOffAction() { return triggerOffAction_; } andrewm@42: int getTriggerOnNoteNumber() { return triggerOnNoteNum_; } andrewm@42: int getTriggerOffNoteNumber() { return triggerOffNoteNum_; } andrewm@42: int getTriggerOnNoteVelocity() { return triggerOnNoteVel_; } andrewm@42: int getTriggerOffNoteVelocity() { return triggerOffNoteVel_; } andrewm@42: andrewm@42: void setTouchesForTrigger(int touches); andrewm@42: void setFramesForTrigger(int frames); andrewm@42: void setConsecutiveTapsForTrigger(int taps); andrewm@42: void setMaxTimeBetweenTapsForTrigger(timestamp_diff_type timeDiff); andrewm@42: void setNeedsMidiNoteOn(bool needsMidi); andrewm@42: void setTriggerOnAction(int action); andrewm@42: void setTriggerOffAction(int action); andrewm@42: void setTriggerOnNoteNumber(int note); andrewm@42: void setTriggerOffNoteNumber(int note); andrewm@42: void setTriggerOnNoteVelocity(int velocity); andrewm@42: void setTriggerOffNoteVelocity(int velocity); andrewm@42: andrewm@49: #ifndef TOUCHKEYS_NO_GUI andrewm@42: // ***** GUI Support ***** andrewm@42: bool hasBasicEditor() { return true; } andrewm@42: MappingEditorComponent* createBasicEditor(); andrewm@42: bool hasExtendedEditor() { return false; } andrewm@42: MappingEditorComponent* createExtendedEditor() { return nullptr; } andrewm@49: #endif andrewm@42: andrewm@49: // ****** OSC Control Support ****** andrewm@49: OscMessage* oscControlMethod(const char *path, const char *types, andrewm@49: int numValues, lo_arg **values, void *data); andrewm@36: // ****** Preset Save/Load ****** andrewm@36: XmlElement* getPreset(); andrewm@36: bool loadPreset(XmlElement const* preset); andrewm@42: andrewm@42: private: andrewm@42: // ***** Private Methods ***** andrewm@42: void initializeMappingParameters(int noteNumber, TouchkeyMultiFingerTriggerMapping *mapping); andrewm@42: andrewm@42: // Parameters andrewm@42: int numTouchesForTrigger_; // How many touches are needed for a trigger andrewm@42: int numFramesForTrigger_; // How many consecutive frames with these touches are needed to trigger andrewm@42: int numConsecutiveTapsForTrigger_; // How many taps with this number of touches are needed to trigger andrewm@42: timestamp_diff_type maxTapSpacing_; // How far apart the taps can come and be considered a multi-tap gesture andrewm@42: bool needsMidiNoteOn_; // Whether the MIDI note has to be on for this gesture to trigger andrewm@42: int triggerOnAction_, triggerOffAction_; // Actions to take on trigger on/off andrewm@42: int triggerOnNoteNum_, triggerOffNoteNum_; // Which notes to send if a note is being sent andrewm@42: int triggerOnNoteVel_, triggerOffNoteVel_; // Velocity to send if a note is being sent andrewm@0: }; andrewm@0: andrewm@0: #endif /* defined(__TouchKeys__TouchkeyMultiFingerTriggerMappingFactory__) */