Mercurial > hg > touchkeys
changeset 35:3f948746885a
Further updates; fix in Control and add save in Vibrato
author | Andrew McPherson <andrewm@eecs.qmul.ac.uk> |
---|---|
date | Fri, 21 Mar 2014 00:23:32 +0000 |
parents | 20c28a319dee |
children | 0deac2806a7b |
files | Source/Mappings/Control/TouchkeyControlMappingFactory.cpp Source/Mappings/Vibrato/TouchkeyVibratoMappingFactory.cpp Source/Mappings/Vibrato/TouchkeyVibratoMappingFactory.h |
diffstat | 3 files changed, 67 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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
--- 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);