void MidiControllerAutomationHandler::restoreFromValueTree(const ValueTree &v) { if (v.getType() != Identifier("MidiAutomation")) return; clear(); for (int i = 0; i < v.getNumChildren(); i++) { ValueTree cc = v.getChild(i); int controller = cc.getProperty("Controller", 1); auto& aArray = automationData[controller]; AutomationData a; a.ccNumber = controller; a.processor = ProcessorHelpers::getFirstProcessorWithName(mc->getMainSynthChain(), cc.getProperty("Processor")); a.macroIndex = cc.getProperty("MacroIndex"); auto attributeString = cc.getProperty("Attribute", a.attribute).toString(); const bool isParameterId = attributeString.containsAnyOf("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); // The parameter was stored correctly as ID if (isParameterId && a.processor.get() != nullptr) { const Identifier pId(attributeString); for (int j = 0; j < a.processor->getNumParameters(); j++) { if (a.processor->getIdentifierForParameterIndex(j) == pId) { a.attribute = j; break; } } } else { // This tries to obtain the correct id. auto presetVersion = v.getRoot().getProperty("Version").toString(); const Identifier pId = UserPresetHelpers::getAutomationIndexFromOldVersion(presetVersion, attributeString.getIntValue()); if (pId.isNull()) { a.attribute = attributeString.getIntValue(); } else { for (int j = 0; j < a.processor->getNumParameters(); j++) { if (a.processor->getIdentifierForParameterIndex(j) == pId) { a.attribute = j; break; } } } } double start = cc.getProperty("Start"); double end = cc.getProperty("End"); double skew = cc.getProperty("Skew", a.parameterRange.skew); double interval = cc.getProperty("Interval", a.parameterRange.interval); auto fullStart = cc.getProperty("FullStart", start); auto fullEnd = cc.getProperty("FullEnd", end); a.parameterRange = NormalisableRange<double>(start, end, interval, skew); a.fullRange = NormalisableRange<double>(fullStart, fullEnd, interval, skew); a.used = true; a.inverted = cc.getProperty("Inverted", false); aArray.addIfNotAlreadyThere(a); } sendChangeMessage(); refreshAnyUsedState(); }