# HG changeset patch # User Andrew McPherson # Date 1395361412 0 # Node ID 3f948746885a722341688f3ba251ad63c51dec18 # Parent 20c28a319dee6b270f8e3c0cbe67d35c02972880 Further updates; fix in Control and add save in Vibrato diff -r 20c28a319dee -r 3f948746885a Source/Mappings/Control/TouchkeyControlMappingFactory.cpp --- a/Source/Mappings/Control/TouchkeyControlMappingFactory.cpp Fri Mar 21 00:06:28 2014 +0000 +++ b/Source/Mappings/Control/TouchkeyControlMappingFactory.cpp Fri Mar 21 00:23:32 2014 +0000 @@ -233,12 +233,12 @@ inputParameter_ = properties.getIntValue("inputParameter"); inputType_ = properties.getIntValue("inputType"); - outputRangeMin_ = properties.getIntValue("outputRangeMin"); - outputRangeMax_ = properties.getIntValue("outputRangeMax"); - outputDefault_ = properties.getIntValue("outputDefault"); - threshold_ = properties.getIntValue("threshold"); - ignoresTwoFingers_ = properties.getIntValue("ignoresTwoFingers"); - ignoresThreeFingers_ = properties.getIntValue("ignoresThreeFingers"); + outputRangeMin_ = properties.getDoubleValue("outputRangeMin"); + outputRangeMax_ = properties.getDoubleValue("outputRangeMax"); + outputDefault_ = properties.getDoubleValue("outputDefault"); + threshold_ = properties.getDoubleValue("threshold"); + ignoresTwoFingers_ = properties.getBoolValue("ignoresTwoFingers"); + ignoresThreeFingers_ = properties.getBoolValue("ignoresThreeFingers"); direction_ = properties.getIntValue("direction"); // Update MIDI information; this doesn't actually change the controller diff -r 20c28a319dee -r 3f948746885a Source/Mappings/Vibrato/TouchkeyVibratoMappingFactory.cpp --- a/Source/Mappings/Vibrato/TouchkeyVibratoMappingFactory.cpp Fri Mar 21 00:06:28 2014 +0000 +++ b/Source/Mappings/Vibrato/TouchkeyVibratoMappingFactory.cpp Fri Mar 21 00:23:32 2014 +0000 @@ -161,6 +161,63 @@ return new TouchkeyVibratoMappingShortEditor(*this); } + +// ****** Preset Save/Load ****** +XmlElement* TouchkeyVibratoMappingFactory::getPreset() { + PropertySet properties; + + storeCommonProperties(properties); + properties.setValue("vibratoControl", vibratoControl_); + properties.setValue("vibratoRange", vibratoRange_); + properties.setValue("vibratoPrescaler", vibratoPrescaler_); + properties.setValue("vibratoTimeout", vibratoTimeout_); + properties.setValue("vibratoOnsetThresholdX", vibratoOnsetThresholdX_); + properties.setValue("vibratoOnsetThresholdY", vibratoOnsetThresholdY_); + properties.setValue("vibratoOnsetRatioX", vibratoOnsetRatioX_); + properties.setValue("vibratoOnsetRatioY", vibratoOnsetRatioY_); + + XmlElement* preset = properties.createXml("MappingFactory"); + preset->setAttribute("type", "Vibrato"); + + return preset; +} + +bool TouchkeyVibratoMappingFactory::loadPreset(XmlElement const* preset) { + if(preset == 0) + return false; + + PropertySet properties; + properties.restoreFromXml(*preset); + + if(!loadCommonProperties(properties)) + return false; + if(!properties.containsKey("vibratoControl") || + !properties.containsKey("vibratoRange") || + !properties.containsKey("vibratoPrescaler") || + !properties.containsKey("vibratoTimeout") || + !properties.containsKey("vibratoOnsetThresholdX") || + !properties.containsKey("vibratoOnsetThresholdY") || + !properties.containsKey("vibratoOnsetRatioX") || + !properties.containsKey("vibratoOnsetRatioY")) + return false; + + vibratoControl_ = properties.getDoubleValue("vibratoControl"); + vibratoRange_ = properties.getDoubleValue("vibratoRange"); + vibratoPrescaler_ = properties.getDoubleValue("vibratoPrescaler"); + vibratoTimeout_ = properties.getDoubleValue("vibratoTimeout"); + vibratoOnsetThresholdX_ = properties.getDoubleValue("vibratoOnsetThresholdX"); + vibratoOnsetThresholdY_ = properties.getDoubleValue("vibratoOnsetThresholdY"); + vibratoOnsetRatioX_ = properties.getDoubleValue("vibratoOnsetRatioX"); + vibratoOnsetRatioY_ = properties.getDoubleValue("vibratoOnsetRatioY"); + + // Update MIDI information; this doesn't actually change the controller + // (which is already set) but it adds a listener and updates the ranges + setVibratoControl(vibratoControl_); + + return true; +} + + // ***** Private Methods ***** // Set the initial parameters for a new mapping diff -r 20c28a319dee -r 3f948746885a Source/Mappings/Vibrato/TouchkeyVibratoMappingFactory.h --- a/Source/Mappings/Vibrato/TouchkeyVibratoMappingFactory.h Fri Mar 21 00:06:28 2014 +0000 +++ b/Source/Mappings/Vibrato/TouchkeyVibratoMappingFactory.h Fri Mar 21 00:23:32 2014 +0000 @@ -77,6 +77,10 @@ bool hasExtendedEditor() { return false; } MappingEditorComponent* createExtendedEditor() { return nullptr; } + // ****** Preset Save/Load ****** + XmlElement* getPreset(); + bool loadPreset(XmlElement const* preset); + private: // ***** Private Methods ***** void initializeMappingParameters(int noteNumber, TouchkeyVibratoMapping *mapping);