Mercurial > hg > touchkeys
comparison Source/Mappings/Control/TouchkeyControlMappingFactory.cpp @ 34:20c28a319dee
Further progress on save/load; now includes properties of keyboard segment and Control mapping. Others still to come.
author | Andrew McPherson <andrewm@eecs.qmul.ac.uk> |
---|---|
date | Fri, 21 Mar 2014 00:06:28 +0000 |
parents | e8965409903e |
children | 3f948746885a |
comparison
equal
deleted
inserted
replaced
33:e8965409903e | 34:20c28a319dee |
---|---|
98 if(midiConverter_ != 0) { | 98 if(midiConverter_ != 0) { |
99 midiConverter_->listenToIncomingControl(midiControllerNumber_); | 99 midiConverter_->listenToIncomingControl(midiControllerNumber_); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 /*void TouchkeyControlMappingFactory::setRange(float inputMin, float inputMax, float inputCenter, float outputMin, float outputMax, float outputDefault) { | |
104 // All possible input parameters are in the range [-1, 1], | |
105 // and actually in the range [0, 1] if absolute values are used | |
106 // (though we don't check this here) | |
107 if(inputMin < -1.0) | |
108 inputRangeMin_ = -1.0; | |
109 else if(inputMin > 1.0) | |
110 inputRangeMin_ = 1.0; | |
111 else | |
112 inputRangeMin_ = inputMin; | |
113 if(inputMax < -1.0) | |
114 inputRangeMax_ = -1.0; | |
115 else if(inputMax > 1.0) | |
116 inputRangeMax_ = 1.0; | |
117 else | |
118 inputRangeMax_ = inputMax; | |
119 if(inputCenter < -1.0) | |
120 inputRangeCenter_ = -1.0; | |
121 else if(inputCenter > 1.0) | |
122 inputRangeCenter_ = 1.0; | |
123 else | |
124 inputRangeCenter_ = inputCenter; | |
125 outputRangeMin_ = outputMin; | |
126 outputRangeMax_ = outputMax; | |
127 outputDefault_ = outputDefault; | |
128 | |
129 // Update control | |
130 if(midiConverter_ == 0) | |
131 return; | |
132 midiConverter_->removeAllControls(); | |
133 midiConverter_->addControl(controlName_.c_str(), 1, inputRangeMin_, inputRangeMax_, inputRangeCenter_, OscMidiConverter::kOutOfRangeClip); | |
134 }*/ | |
135 | |
136 void TouchkeyControlMappingFactory::setRangeInputMin(float inputMin) { | 103 void TouchkeyControlMappingFactory::setRangeInputMin(float inputMin) { |
137 if(inputMin < -1.0) | 104 if(inputMin < -1.0) |
138 inputRangeMin_ = -1.0; | 105 inputRangeMin_ = -1.0; |
139 else if(inputMin > 1.0) | 106 else if(inputMin > 1.0) |
140 inputRangeMin_ = 1.0; | 107 inputRangeMin_ = 1.0; |
223 return new TouchkeyControlMappingShortEditor(*this); | 190 return new TouchkeyControlMappingShortEditor(*this); |
224 } | 191 } |
225 | 192 |
226 // ****** Preset Save/Load ****** | 193 // ****** Preset Save/Load ****** |
227 XmlElement* TouchkeyControlMappingFactory::getPreset() { | 194 XmlElement* TouchkeyControlMappingFactory::getPreset() { |
228 XmlElement* preset = new XmlElement("MappingFactory"); | 195 PropertySet properties; |
196 | |
197 storeCommonProperties(properties); | |
198 properties.setValue("inputParameter", inputParameter_); | |
199 properties.setValue("inputType", inputType_); | |
200 properties.setValue("outputRangeMin", outputRangeMin_); | |
201 properties.setValue("outputRangeMax", outputRangeMax_); | |
202 properties.setValue("outputDefault", outputDefault_); | |
203 properties.setValue("threshold", threshold_); | |
204 properties.setValue("ignoresTwoFingers", ignoresTwoFingers_); | |
205 properties.setValue("ignoresThreeFingers", ignoresThreeFingers_); | |
206 properties.setValue("direction", direction_); | |
207 | |
208 XmlElement* preset = properties.createXml("MappingFactory"); | |
229 preset->setAttribute("type", "Control"); | 209 preset->setAttribute("type", "Control"); |
210 | |
230 return preset; | 211 return preset; |
231 } | 212 } |
232 | 213 |
233 bool TouchkeyControlMappingFactory::loadPreset(XmlElement const* preset) { | 214 bool TouchkeyControlMappingFactory::loadPreset(XmlElement const* preset) { |
215 if(preset == 0) | |
216 return false; | |
217 | |
218 PropertySet properties; | |
219 properties.restoreFromXml(*preset); | |
220 | |
221 if(!loadCommonProperties(properties)) | |
222 return false; | |
223 if(!properties.containsKey("inputParameter") || | |
224 !properties.containsKey("inputType") || | |
225 !properties.containsKey("outputRangeMin") || | |
226 !properties.containsKey("outputRangeMax") || | |
227 !properties.containsKey("outputDefault") || | |
228 !properties.containsKey("threshold") || | |
229 !properties.containsKey("ignoresTwoFingers") || | |
230 !properties.containsKey("ignoresThreeFingers") || | |
231 !properties.containsKey("direction")) | |
232 return false; | |
233 | |
234 inputParameter_ = properties.getIntValue("inputParameter"); | |
235 inputType_ = properties.getIntValue("inputType"); | |
236 outputRangeMin_ = properties.getIntValue("outputRangeMin"); | |
237 outputRangeMax_ = properties.getIntValue("outputRangeMax"); | |
238 outputDefault_ = properties.getIntValue("outputDefault"); | |
239 threshold_ = properties.getIntValue("threshold"); | |
240 ignoresTwoFingers_ = properties.getIntValue("ignoresTwoFingers"); | |
241 ignoresThreeFingers_ = properties.getIntValue("ignoresThreeFingers"); | |
242 direction_ = properties.getIntValue("direction"); | |
243 | |
244 // Update MIDI information; this doesn't actually change the controller | |
245 // (which is already set) but it adds a listener and updates the ranges | |
246 setController(midiControllerNumber_); | |
247 | |
234 return true; | 248 return true; |
235 } | 249 } |
236 | 250 |
237 // ***** Private Methods ***** | 251 // ***** Private Methods ***** |
238 | 252 |