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: TouchkeyControlMappingFactory.h: factory for the TouchKeys control andrewm@0: mapping, which converts an arbitrary touch parameter into a MIDI or andrewm@0: OSC control message. andrewm@0: */ andrewm@0: andrewm@0: andrewm@0: #ifndef __touchkeys__TouchkeyControlMappingFactory__ andrewm@0: #define __touchkeys__TouchkeyControlMappingFactory__ andrewm@0: andrewm@0: #include andrewm@0: andrewm@0: #include "../TouchkeyBaseMappingFactory.h" andrewm@0: #include "TouchkeyControlMapping.h" andrewm@0: andrewm@0: // Factory class to produce Touchkey control messages for generic MIDI/OSC controllers andrewm@0: andrewm@0: class TouchkeyControlMappingFactory : public TouchkeyBaseMappingFactory { andrewm@0: private: andrewm@0: static const int kDefaultController; andrewm@0: static const float kDefaultOutputRangeMin; andrewm@0: static const float kDefaultOutputRangeMax; andrewm@0: static const float kDefaultOutputDefault; andrewm@0: andrewm@0: public: andrewm@0: // ***** Constructor ***** andrewm@0: andrewm@0: // Default constructor, containing a reference to the PianoKeyboard class. andrewm@0: TouchkeyControlMappingFactory(PianoKeyboard &keyboard, MidiKeyboardSegment& segment); andrewm@0: andrewm@0: // ***** Destructor ***** andrewm@0: andrewm@0: ~TouchkeyControlMappingFactory(); andrewm@0: andrewm@0: // ***** Accessors / Modifiers ***** andrewm@0: andrewm@0: virtual const std::string factoryTypeName() { return "Control"; } andrewm@0: andrewm@0: // ***** Class-Specific Methods ***** andrewm@0: andrewm@0: int getController() { return midiControllerNumber_; } andrewm@0: int getInputParameter() { return inputParameter_; } andrewm@0: int getInputType() { return inputType_; } andrewm@0: float getRangeInputMin() { return inputRangeMin_; } andrewm@0: float getRangeInputMax() { return inputRangeMax_; } andrewm@0: float getRangeInputCenter() { return inputRangeCenter_; } andrewm@0: float getRangeOutputMin() { return outputRangeMin_; } andrewm@0: float getRangeOutputMax() { return outputRangeMax_; } andrewm@0: float getRangeOutputDefault() { return outputDefault_; } andrewm@0: float getThreshold() { return threshold_; } andrewm@0: bool getIgnoresTwoFingers() { return ignoresTwoFingers_; } andrewm@0: bool getIgnoresThreeFingers() { return ignoresThreeFingers_; } andrewm@41: int getDirection(); andrewm@41: int getOutOfRangeBehavior() { return outOfRangeBehavior_; } andrewm@41: bool getUses14BitControl() { return use14BitControl_; } andrewm@0: andrewm@0: void setInputParameter(int inputParameter); andrewm@0: void setInputType(int inputType); andrewm@0: void setController(int controller); andrewm@0: //void setRange(float inputMin, float inputMax, float inputCenter, float outputMin, float outputMax, float outputDefault); andrewm@0: void setRangeInputMin(float inputMin); andrewm@0: void setRangeInputMax(float inputMax); andrewm@0: void setRangeInputCenter(float inputCenter); andrewm@0: void setRangeOutputMin(float outputMin); andrewm@0: void setRangeOutputMax(float outputMax); andrewm@0: void setRangeOutputDefault(float outputDefault); andrewm@0: void setThreshold(float threshold); andrewm@0: void setIgnoresTwoFingers(bool ignoresTwo); andrewm@0: void setIgnoresThreeFingers(bool ignoresThree); andrewm@0: void setDirection(int direction); andrewm@41: void setOutOfRangeBehavior(int behavior); andrewm@41: void setUses14BitControl(bool use); andrewm@0: andrewm@49: #ifndef TOUCHKEYS_NO_GUI andrewm@0: // ***** GUI Support ***** andrewm@0: bool hasBasicEditor() { return true; } andrewm@0: MappingEditorComponent* createBasicEditor(); andrewm@41: bool hasExtendedEditor() { return true; } andrewm@41: MappingEditorComponent* createExtendedEditor(); andrewm@49: #endif andrewm@49: 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@0: andrewm@33: // ****** Preset Save/Load ****** andrewm@33: XmlElement* getPreset(); andrewm@33: bool loadPreset(XmlElement const* preset); andrewm@33: andrewm@0: private: andrewm@0: // ***** Private Methods ***** andrewm@0: void initializeMappingParameters(int noteNumber, TouchkeyControlMapping *mapping); andrewm@0: andrewm@0: int inputParameter_; // Type of input data andrewm@0: int inputType_; // Whether data is absolute or relative andrewm@0: float outputRangeMin_, outputRangeMax_; // Output ranges andrewm@0: float outputDefault_; // Default values andrewm@0: float threshold_; // Detection threshold for relative motion andrewm@0: bool ignoresTwoFingers_; // Whether this mapping suspends messages when two andrewm@0: bool ignoresThreeFingers_; // or three fingers are present andrewm@0: int direction_; // Whether the mapping uses the absolute value in negative cases andrewm@0: }; andrewm@0: andrewm@0: #endif /* defined(__touchkeys__TouchkeyControlMappingFactory__) */