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 TouchkeyControlMappingFactory.h: factory for the TouchKeys control
|
andrewm@0
|
21 mapping, which converts an arbitrary touch parameter into a MIDI or
|
andrewm@0
|
22 OSC control message.
|
andrewm@0
|
23 */
|
andrewm@0
|
24
|
andrewm@0
|
25
|
andrewm@0
|
26 #ifndef __touchkeys__TouchkeyControlMappingFactory__
|
andrewm@0
|
27 #define __touchkeys__TouchkeyControlMappingFactory__
|
andrewm@0
|
28
|
andrewm@0
|
29 #include <iostream>
|
andrewm@0
|
30
|
andrewm@0
|
31 #include "../TouchkeyBaseMappingFactory.h"
|
andrewm@0
|
32 #include "TouchkeyControlMapping.h"
|
andrewm@0
|
33
|
andrewm@0
|
34 // Factory class to produce Touchkey control messages for generic MIDI/OSC controllers
|
andrewm@0
|
35
|
andrewm@0
|
36 class TouchkeyControlMappingFactory : public TouchkeyBaseMappingFactory<TouchkeyControlMapping> {
|
andrewm@0
|
37 private:
|
andrewm@0
|
38 static const int kDefaultController;
|
andrewm@0
|
39 static const float kDefaultOutputRangeMin;
|
andrewm@0
|
40 static const float kDefaultOutputRangeMax;
|
andrewm@0
|
41 static const float kDefaultOutputDefault;
|
andrewm@0
|
42
|
andrewm@0
|
43 public:
|
andrewm@0
|
44 // ***** Constructor *****
|
andrewm@0
|
45
|
andrewm@0
|
46 // Default constructor, containing a reference to the PianoKeyboard class.
|
andrewm@0
|
47 TouchkeyControlMappingFactory(PianoKeyboard &keyboard, MidiKeyboardSegment& segment);
|
andrewm@0
|
48
|
andrewm@0
|
49 // ***** Destructor *****
|
andrewm@0
|
50
|
andrewm@0
|
51 ~TouchkeyControlMappingFactory();
|
andrewm@0
|
52
|
andrewm@0
|
53 // ***** Accessors / Modifiers *****
|
andrewm@0
|
54
|
andrewm@0
|
55 virtual const std::string factoryTypeName() { return "Control"; }
|
andrewm@0
|
56
|
andrewm@0
|
57 // ***** Class-Specific Methods *****
|
andrewm@0
|
58
|
andrewm@0
|
59 int getController() { return midiControllerNumber_; }
|
andrewm@0
|
60 int getInputParameter() { return inputParameter_; }
|
andrewm@0
|
61 int getInputType() { return inputType_; }
|
andrewm@0
|
62 float getRangeInputMin() { return inputRangeMin_; }
|
andrewm@0
|
63 float getRangeInputMax() { return inputRangeMax_; }
|
andrewm@0
|
64 float getRangeInputCenter() { return inputRangeCenter_; }
|
andrewm@0
|
65 float getRangeOutputMin() { return outputRangeMin_; }
|
andrewm@0
|
66 float getRangeOutputMax() { return outputRangeMax_; }
|
andrewm@0
|
67 float getRangeOutputDefault() { return outputDefault_; }
|
andrewm@0
|
68 float getThreshold() { return threshold_; }
|
andrewm@0
|
69 bool getIgnoresTwoFingers() { return ignoresTwoFingers_; }
|
andrewm@0
|
70 bool getIgnoresThreeFingers() { return ignoresThreeFingers_; }
|
andrewm@41
|
71 int getDirection();
|
andrewm@41
|
72 int getOutOfRangeBehavior() { return outOfRangeBehavior_; }
|
andrewm@41
|
73 bool getUses14BitControl() { return use14BitControl_; }
|
andrewm@0
|
74
|
andrewm@0
|
75 void setInputParameter(int inputParameter);
|
andrewm@0
|
76 void setInputType(int inputType);
|
andrewm@0
|
77 void setController(int controller);
|
andrewm@0
|
78 //void setRange(float inputMin, float inputMax, float inputCenter, float outputMin, float outputMax, float outputDefault);
|
andrewm@0
|
79 void setRangeInputMin(float inputMin);
|
andrewm@0
|
80 void setRangeInputMax(float inputMax);
|
andrewm@0
|
81 void setRangeInputCenter(float inputCenter);
|
andrewm@0
|
82 void setRangeOutputMin(float outputMin);
|
andrewm@0
|
83 void setRangeOutputMax(float outputMax);
|
andrewm@0
|
84 void setRangeOutputDefault(float outputDefault);
|
andrewm@0
|
85 void setThreshold(float threshold);
|
andrewm@0
|
86 void setIgnoresTwoFingers(bool ignoresTwo);
|
andrewm@0
|
87 void setIgnoresThreeFingers(bool ignoresThree);
|
andrewm@0
|
88 void setDirection(int direction);
|
andrewm@41
|
89 void setOutOfRangeBehavior(int behavior);
|
andrewm@41
|
90 void setUses14BitControl(bool use);
|
andrewm@0
|
91
|
andrewm@49
|
92 #ifndef TOUCHKEYS_NO_GUI
|
andrewm@0
|
93 // ***** GUI Support *****
|
andrewm@0
|
94 bool hasBasicEditor() { return true; }
|
andrewm@0
|
95 MappingEditorComponent* createBasicEditor();
|
andrewm@41
|
96 bool hasExtendedEditor() { return true; }
|
andrewm@41
|
97 MappingEditorComponent* createExtendedEditor();
|
andrewm@49
|
98 #endif
|
andrewm@49
|
99
|
andrewm@49
|
100 // ****** OSC Control Support ******
|
andrewm@49
|
101 OscMessage* oscControlMethod(const char *path, const char *types,
|
andrewm@49
|
102 int numValues, lo_arg **values, void *data);
|
andrewm@0
|
103
|
andrewm@33
|
104 // ****** Preset Save/Load ******
|
andrewm@33
|
105 XmlElement* getPreset();
|
andrewm@33
|
106 bool loadPreset(XmlElement const* preset);
|
andrewm@33
|
107
|
andrewm@0
|
108 private:
|
andrewm@0
|
109 // ***** Private Methods *****
|
andrewm@0
|
110 void initializeMappingParameters(int noteNumber, TouchkeyControlMapping *mapping);
|
andrewm@0
|
111
|
andrewm@0
|
112 int inputParameter_; // Type of input data
|
andrewm@0
|
113 int inputType_; // Whether data is absolute or relative
|
andrewm@0
|
114 float outputRangeMin_, outputRangeMax_; // Output ranges
|
andrewm@0
|
115 float outputDefault_; // Default values
|
andrewm@0
|
116 float threshold_; // Detection threshold for relative motion
|
andrewm@0
|
117 bool ignoresTwoFingers_; // Whether this mapping suspends messages when two
|
andrewm@0
|
118 bool ignoresThreeFingers_; // or three fingers are present
|
andrewm@0
|
119 int direction_; // Whether the mapping uses the absolute value in negative cases
|
andrewm@0
|
120 };
|
andrewm@0
|
121
|
andrewm@0
|
122 #endif /* defined(__touchkeys__TouchkeyControlMappingFactory__) */
|