Mercurial > hg > touchkeys
comparison Source/Mappings/Control/TouchkeyControlMappingFactory.cpp @ 41:85577160a0d4
Many changes: implement global application preferences on devices etc.; extended editor window support with Control mapping features for now
author | Andrew McPherson <andrewm@eecs.qmul.ac.uk> |
---|---|
date | Sat, 21 Jun 2014 23:32:33 +0100 |
parents | 3f948746885a |
children | fa39caec190b |
comparison
equal
deleted
inserted
replaced
40:50e4859d9769 | 41:85577160a0d4 |
---|---|
22 OSC control message. | 22 OSC control message. |
23 */ | 23 */ |
24 | 24 |
25 #include "TouchkeyControlMappingFactory.h" | 25 #include "TouchkeyControlMappingFactory.h" |
26 #include "TouchkeyControlMappingShortEditor.h" | 26 #include "TouchkeyControlMappingShortEditor.h" |
27 #include "TouchkeyControlMappingExtendedEditor.h" | |
27 | 28 |
28 const int TouchkeyControlMappingFactory::kDefaultController = 1; | 29 const int TouchkeyControlMappingFactory::kDefaultController = 1; |
29 const float TouchkeyControlMappingFactory::kDefaultOutputRangeMin = 0.0; | 30 const float TouchkeyControlMappingFactory::kDefaultOutputRangeMin = 0.0; |
30 const float TouchkeyControlMappingFactory::kDefaultOutputRangeMax = 127.0; | 31 const float TouchkeyControlMappingFactory::kDefaultOutputRangeMax = 127.0; |
31 const float TouchkeyControlMappingFactory::kDefaultOutputDefault = 0.0; | 32 const float TouchkeyControlMappingFactory::kDefaultOutputDefault = 0.0; |
48 TouchkeyControlMappingFactory::~TouchkeyControlMappingFactory() { | 49 TouchkeyControlMappingFactory::~TouchkeyControlMappingFactory() { |
49 | 50 |
50 } | 51 } |
51 | 52 |
52 // ***** Accessors / Modifiers ***** | 53 // ***** Accessors / Modifiers ***** |
54 | |
55 int TouchkeyControlMappingFactory::getDirection() { | |
56 // Get the direction of motion. This is always positive for | |
57 if(inputType_ == TouchkeyControlMapping::kTypeAbsolute) | |
58 return TouchkeyControlMapping::kDirectionPositive; | |
59 return direction_; | |
60 } | |
53 | 61 |
54 void TouchkeyControlMappingFactory::setInputParameter(int inputParameter) { | 62 void TouchkeyControlMappingFactory::setInputParameter(int inputParameter) { |
55 inputParameter_ = inputParameter; | 63 inputParameter_ = inputParameter; |
56 } | 64 } |
57 | 65 |
89 else | 97 else |
90 outputDefault_ = outputDefault_ * 128.0; | 98 outputDefault_ = outputDefault_ * 128.0; |
91 } | 99 } |
92 | 100 |
93 setMidiParameters(controller, inputRangeMin_, inputRangeMax_, inputRangeCenter_, | 101 setMidiParameters(controller, inputRangeMin_, inputRangeMax_, inputRangeCenter_, |
94 outputDefault_, outputRangeMin_, outputRangeMax_); | 102 outputDefault_, outputRangeMin_, outputRangeMax_, |
103 -1, use14BitControl_, outOfRangeBehavior_); | |
95 | 104 |
96 // Listen to incoming controls from the keyboard too, if this is enabled | 105 // Listen to incoming controls from the keyboard too, if this is enabled |
97 // in MidiKeyboardSegment | 106 // in MidiKeyboardSegment |
98 if(midiConverter_ != 0) { | 107 if(midiConverter_ != 0) { |
99 midiConverter_->listenToIncomingControl(midiControllerNumber_); | 108 midiConverter_->listenToIncomingControl(midiControllerNumber_); |
111 // Update control | 120 // Update control |
112 //if(midiConverter_ == 0) | 121 //if(midiConverter_ == 0) |
113 // return; | 122 // return; |
114 //midiConverter_->setControlMinValue(controlName_.c_str(), inputRangeMin_); | 123 //midiConverter_->setControlMinValue(controlName_.c_str(), inputRangeMin_); |
115 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, | 124 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, |
116 outputDefault_, outputRangeMin_, outputRangeMax_); | 125 outputDefault_, outputRangeMin_, outputRangeMax_, |
126 -1, use14BitControl_, outOfRangeBehavior_); | |
117 } | 127 } |
118 | 128 |
119 void TouchkeyControlMappingFactory::setRangeInputMax(float inputMax) { | 129 void TouchkeyControlMappingFactory::setRangeInputMax(float inputMax) { |
120 if(inputMax < -1.0) | 130 if(inputMax < -1.0) |
121 inputRangeMax_ = -1.0; | 131 inputRangeMax_ = -1.0; |
127 // Update control | 137 // Update control |
128 //if(midiConverter_ == 0) | 138 //if(midiConverter_ == 0) |
129 // return; | 139 // return; |
130 //midiConverter_->setControlMaxValue(controlName_.c_str(), inputRangeMax_); | 140 //midiConverter_->setControlMaxValue(controlName_.c_str(), inputRangeMax_); |
131 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, | 141 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, |
132 outputDefault_, outputRangeMin_, outputRangeMax_); | 142 outputDefault_, outputRangeMin_, outputRangeMax_, |
143 -1, use14BitControl_, outOfRangeBehavior_); | |
133 } | 144 } |
134 | 145 |
135 void TouchkeyControlMappingFactory::setRangeInputCenter(float inputCenter) { | 146 void TouchkeyControlMappingFactory::setRangeInputCenter(float inputCenter) { |
136 if(inputCenter < -1.0) | 147 if(inputCenter < -1.0) |
137 inputRangeCenter_ = -1.0; | 148 inputRangeCenter_ = -1.0; |
143 // Update control | 154 // Update control |
144 //if(midiConverter_ == 0) | 155 //if(midiConverter_ == 0) |
145 // return; | 156 // return; |
146 //midiConverter_->setControlCenterValue(controlName_.c_str(), inputRangeCenter_); | 157 //midiConverter_->setControlCenterValue(controlName_.c_str(), inputRangeCenter_); |
147 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, | 158 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, |
148 outputDefault_, outputRangeMin_, outputRangeMax_); | 159 outputDefault_, outputRangeMin_, outputRangeMax_, |
160 -1, use14BitControl_, outOfRangeBehavior_); | |
149 } | 161 } |
150 | 162 |
151 void TouchkeyControlMappingFactory::setRangeOutputMin(float outputMin) { | 163 void TouchkeyControlMappingFactory::setRangeOutputMin(float outputMin) { |
152 outputRangeMin_ = outputMin; | 164 outputRangeMin_ = outputMin; |
153 | 165 |
154 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, | 166 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, |
155 outputDefault_, outputRangeMin_, outputRangeMax_); | 167 outputDefault_, outputRangeMin_, outputRangeMax_, |
168 -1, use14BitControl_, outOfRangeBehavior_); | |
156 } | 169 } |
157 | 170 |
158 void TouchkeyControlMappingFactory::setRangeOutputMax(float outputMax) { | 171 void TouchkeyControlMappingFactory::setRangeOutputMax(float outputMax) { |
159 outputRangeMax_ = outputMax; | 172 outputRangeMax_ = outputMax; |
160 | 173 |
161 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, | 174 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, |
162 outputDefault_, outputRangeMin_, outputRangeMax_); | 175 outputDefault_, outputRangeMin_, outputRangeMax_, |
176 -1, use14BitControl_, outOfRangeBehavior_); | |
163 } | 177 } |
164 | 178 |
165 void TouchkeyControlMappingFactory::setRangeOutputDefault(float outputDefault) { | 179 void TouchkeyControlMappingFactory::setRangeOutputDefault(float outputDefault) { |
166 outputDefault_ = outputDefault; | 180 outputDefault_ = outputDefault; |
167 | 181 |
168 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, | 182 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, |
169 outputDefault_, outputRangeMin_, outputRangeMax_); | 183 outputDefault_, outputRangeMin_, outputRangeMax_, |
184 -1, use14BitControl_, outOfRangeBehavior_); | |
170 } | 185 } |
171 | 186 |
172 void TouchkeyControlMappingFactory::setThreshold(float threshold) { | 187 void TouchkeyControlMappingFactory::setThreshold(float threshold) { |
173 threshold_ = threshold; | 188 threshold_ = threshold; |
174 } | 189 } |
181 ignoresThreeFingers_ = ignoresThree; | 196 ignoresThreeFingers_ = ignoresThree; |
182 } | 197 } |
183 | 198 |
184 void TouchkeyControlMappingFactory::setDirection(int direction) { | 199 void TouchkeyControlMappingFactory::setDirection(int direction) { |
185 direction_ = direction; | 200 direction_ = direction; |
201 } | |
202 | |
203 void TouchkeyControlMappingFactory::setOutOfRangeBehavior(int behavior) { | |
204 outOfRangeBehavior_ = behavior; | |
205 | |
206 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, | |
207 outputDefault_, outputRangeMin_, outputRangeMax_, | |
208 -1, use14BitControl_, outOfRangeBehavior_); | |
209 } | |
210 | |
211 void TouchkeyControlMappingFactory::setUses14BitControl(bool use) { | |
212 use14BitControl_ = use; | |
213 | |
214 setMidiParameters(midiControllerNumber_, inputRangeMin_, inputRangeMax_, inputRangeCenter_, | |
215 outputDefault_, outputRangeMin_, outputRangeMax_, | |
216 -1, use14BitControl_, outOfRangeBehavior_); | |
186 } | 217 } |
187 | 218 |
188 // ***** GUI Support ***** | 219 // ***** GUI Support ***** |
189 MappingEditorComponent* TouchkeyControlMappingFactory::createBasicEditor() { | 220 MappingEditorComponent* TouchkeyControlMappingFactory::createBasicEditor() { |
190 return new TouchkeyControlMappingShortEditor(*this); | 221 return new TouchkeyControlMappingShortEditor(*this); |
191 } | 222 } |
223 | |
224 MappingEditorComponent* TouchkeyControlMappingFactory::createExtendedEditor() { | |
225 return new TouchkeyControlMappingExtendedEditor(*this); | |
226 } | |
227 | |
192 | 228 |
193 // ****** Preset Save/Load ****** | 229 // ****** Preset Save/Load ****** |
194 XmlElement* TouchkeyControlMappingFactory::getPreset() { | 230 XmlElement* TouchkeyControlMappingFactory::getPreset() { |
195 PropertySet properties; | 231 PropertySet properties; |
196 | 232 |